From 76d660ebd336d3dd47dd555ebbaa721a4cc978b2 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Mon, 6 Jun 2011 20:35:01 +0200 Subject: Faster timeout when connecting 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. --- src/init.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/init.cpp') diff --git a/src/init.cpp b/src/init.cpp index a510460191..0e2113e7cb 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -151,6 +151,7 @@ bool AppInit2(int argc, char* argv[]) " -gen=0 \t\t " + _("Don't generate coins\n") + " -min \t\t " + _("Start minimized\n") + " -datadir= \t\t " + _("Specify data directory\n") + + " -timeout= \t " + _("Specify connection timeout (in milliseconds)\n") + " -proxy= \t " + _("Connect through socks4 proxy\n") + " -dns \t " + _("Allow DNS lookups for addnode and connect\n") + " -addnode= \t " + _("Add a node to connect to\n") + @@ -414,6 +415,13 @@ bool AppInit2(int argc, char* argv[]) return false; } + if (mapArgs.count("-timeout")) + { + int nNewTimeout = GetArg("-timeout", 5000); + if (nNewTimeout > 0 && nNewTimeout < 600000) + nConnectTimeout = nNewTimeout; + } + if (mapArgs.count("-printblock")) { string strMatch = mapArgs["-printblock"]; -- cgit v1.2.3