non-blocking connect (by phantomcircuit)#300
Conversation
|
As devrandom pointed out, tor latency could be much greater than 5s. Maybe add if (fProxy) timeout = 20s? |
|
Maybe this can be done adaptively: start with a timeout=100ms, and each time N connection attempts have failed through time-out (and not enough connections are established), double the timeout. |
|
I think making it a command line override option would be a better way of handling it. In general you want to avoid connecting to other nodes where your network path is that latent. That way people who have known-latent paths can manually bump the timeout but it works as expected for most users. |
|
@jrmithdobbs: good suggestion - implemented. |
|
I'd prefer removing the nConnectTimeout global variable and just calling GetArg("-timeout", 5000) in ConnectSocket. |
|
My name is phantomcircuit and I approve this patch. |
|
@gavinandresen: I disagree - I don't like global variables, but doing parsing of command-line options all over the place is even worse. |
|
bleh, this is overkill. Use select with timeout -- as net.cpp already does -- and eliminate that polling loop. In all of linux/osx/winsock, you issue a non-blocking connect(2), and then select(2) the socket for writing. |
|
ACK final result. Needs to be rebased though... |
|
ACK -- looks OK, but I haven't had time to compile and test. |
Use non-blocking connects, and a select() call to wait a predefined time (5s by default, but configurable with -timeout) for either success or failure. This allows much more connections to be tried per time unit. Based on a patch by phantomcircuit.
|
Now using select() instead of looping. Tested on Linux and Windows. |
non-blocking connect (by phantomcircuit)
Trivial: Update copyright year to 2017
Trivial: Update copyright year to 2017 (cherry picked from commit 52c6f73)
c01500c protobump (rejectedpromise) Tree-SHA512: ad0a5f4e6d1ff0a4df54d310e675c044b7a400efab0398beb88868b1aab3c9b3d299a7ec4247b471d63c01106120d03ae517971541d699a07d3b8cd16f346a51
…ue-300 Fixing issue bitcoin#300 (by soft-disabling the -prune and -txindex flags)
…xindex flags)" This reverts commit bbc7530.
commas, formatting
Use non-blocking connects, and a select() call to wait a predefined
time (5s by default, but configurable with -timeout) for either
success or failure. This allows much more connections to be tried
per time unit.
Based on a patch by phantomcircuit.