test 5:
I added MSG_DONTWAIT to the send and recv calls in case they forgot the
socket is non-blocking. If that doesn't work, there's now the catch-all
solution: another thread monitors the send/recv thread and terminates
and restarts it if it stops. It prints "*** Restarting
ThreadSocketHandler ***" in debug.log, and an error message displays on
the status bar for a while.
Before terminating, it tries closing the socket that's hung. If that
works, it doesn't have to resort to terminating.
I ran a test where it terminated the thread about 1000 times without
trouble, so it should be safe. The terminate on linux is
pthread_cancel, which throws it into C++'s exception handler.
The thread calls we were using didn't have terminate, so I created our
own wrappers in util.h to use CreateThread on windows and pthread_create
on linux, instead of:
_beginthread is windows only and lacks terminate
boost::thread is really attractive, but lacks terminate
wxThread requires you to create a class for every function you might
call (yuck)
File attached in the next e-mail
linux-0.1.6-test5 fix for zombie sockets
Private email with Martti Malmi (sirius-m) · 1 message · from 12 November 2009 · with Satoshi Nakamoto
Read in Satoshi Mail Archive source