Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Caught internal_error: 'DhtServer::event_write called but both write queues are empty.' #141

Open
Cubittus opened this issue Dec 18, 2016 · 3 comments

Comments

@Cubittus
Copy link

I've been having rtorrent crashes occasionally just after a download completes. It's not consistent, but I have caught one with a backtrace:

Caught internal_error: 'DhtServer::event_write called but both write queues are empty.'.
---DUMP---
/usr/local/lib64/libtorrent.so.19(_ZN7torrent14internal_error10initializeERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x234) [0x7f0fe4c9fd94]
rtorrent(_ZN7torrent14internal_errorC2EPKc+0xa6) [0x451e76]
/usr/local/lib64/libtorrent.so.19(+0xa800d) [0x7f0fe4d1700d]
/usr/local/lib64/libtorrent.so.19(_ZN7torrent9PollEPoll7performEv+0xd1) [0x7f0fe4cb48b1]
/usr/local/lib64/libtorrent.so.19(_ZN7torrent9PollEPoll7do_pollEli+0x5d) [0x7f0fe4cb49cd]
/usr/local/lib64/libtorrent.so.19(_ZN7torrent11thread_base10event_loopEPS0_+0x124) [0x7f0fe4cf9d24]
rtorrent() [0x410d2e]
/lib64/libc.so.6(__libc_start_main+0xf0) [0x7f0fe2788680]
rtorrent() [0x412009]

---END---

I tried replacing the throw internal_error at libtorrent/src/dht/dht_server.cc:899 with a log notice and after a few torrents completed saw it appear in the log. rtorrent continued to function without apparent problem.

It seems that PollEPoll::perform() can sometimes call DhtServer::event_write() when there is nothing on it's queues. There is a TODO comment in that function to that effect at libtorrent/src/torrent/poll_epoll.cc:175.
The problem is that DhtServer::event_write() considers such a call to be a fatal internal error.

Here's a trivial patch that essentially ignores the calls and just logs a notice:

diff --git a/src/dht/dht_server.cc b/src/dht/dht_server.cc
index 3bd3654c..93421215 100644
--- a/src/dht/dht_server.cc
+++ b/src/dht/dht_server.cc
@@ -896,7 +896,8 @@ DhtServer::process_queue(packet_queue& queue, uint32_t* quota) {
 void
 DhtServer::event_write() {
   if (m_highQueue.empty() && m_lowQueue.empty())
-    throw internal_error("DhtServer::event_write called but both write queues are empty.");
+         lt_log_print(torrent::LOG_THREAD_NOTICE, "DhtServer::event_write called with both queues empty.", 0);
+  //  throw internal_error("DhtServer::event_write called but both write queues are empty.");

   if (!m_uploadThrottle->is_throttled(&m_uploadNode))
     throw internal_error("DhtServer::event_write called while not in throttle list.");
@jaythomas
Copy link

I've had this problem happen with a tracker experiencing network issues but am unable to reproduce consistently.

@jaythomas
Copy link

Saw the error come up again using rtorrent. It turned out the disk libtorrent was writing to was failing. From an end user point-of-view the message was a bit cryptic but I'd say that's rtorrent's fault for not catching and wrapping the error with something more helpful, not libtorrent's fault.

@HarryMuscle
Copy link

I get this error regularly. Any update on getting this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants