fix race condition in torrent_history