2008-09-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Added --connect-timeout option to specify connect timeout in 
seconds.
	This option is in effect for HTTP/FTP/proxy server. The timeout 
for
	connecting to BitTorrent peer is not controlled by this option.
	* src/AbstractProxyRequestCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HelpItemFactory.cc
	* src/HttpRequestCommand.cc
	* src/OptionHandlerFactory.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
This commit is contained in:
Tatsuhiro Tsujikawa 2008-09-09 12:13:08 +00:00
parent a91664cef8
commit 4b997228ad
10 changed files with 45 additions and 1 deletions

View File

@ -1,3 +1,18 @@
2008-09-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added --connect-timeout option to specify connect timeout in seconds.
This option is in effect for HTTP/FTP/proxy server. The timeout for
connecting to BitTorrent peer is not controlled by this option.
* src/AbstractProxyRequestCommand.cc
* src/FtpNegotiationCommand.cc
* src/HelpItemFactory.cc
* src/HttpRequestCommand.cc
* src/OptionHandlerFactory.cc
* src/option_processing.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2008-09-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added help message for -R option.

View File

@ -51,7 +51,9 @@ AbstractProxyRequestCommand::AbstractProxyRequestCommand(int cuid,
RequestGroup* requestGroup,
DownloadEngine* e,
const SocketHandle& s)
:AbstractCommand(cuid, req, requestGroup, e, s) {
:AbstractCommand(cuid, req, requestGroup, e, s)
{
setTimeout(e->option->getAsInt(PREF_CONNECT_TIMEOUT));
disableReadCheckSocket();
setWriteCheckSocket(socket);
}

View File

@ -71,6 +71,9 @@ FtpNegotiationCommand::FtpNegotiationCommand(int32_t cuid,
AbstractCommand(cuid, req, requestGroup, e, s), sequence(seq),
ftp(new FtpConnection(cuid, socket, req, e->option))
{
if(seq == SEQ_RECV_GREETING) {
setTimeout(e->option->getAsInt(PREF_CONNECT_TIMEOUT));
}
disableReadCheckSocket();
setWriteCheckSocket(socket);
}
@ -112,6 +115,7 @@ bool FtpNegotiationCommand::executeInternal() {
}
bool FtpNegotiationCommand::recvGreeting() {
setTimeout(e->option->getAsInt(PREF_TIMEOUT));
socket->setBlockingMode();
disableWriteCheckSocket();
setReadCheckSocket(socket);

View File

@ -83,6 +83,13 @@ TagContainerHandle HelpItemFactory::createHelpItems(const Option* op)
item->addTag(TAG_FTP);
tc->addItem(item);
}
{
HelpItemHandle item(new HelpItem(PREF_CONNECT_TIMEOUT, TEXT_CONNECT_TIMEOUT,
op->get(PREF_CONNECT_TIMEOUT)));
item->addTag(TAG_HTTP);
item->addTag(TAG_FTP);
tc->addItem(item);
}
{
HelpItemHandle item(new HelpItem(PREF_TIMEOUT, TEXT_TIMEOUT));
item->addTag(TAG_HTTP);

View File

@ -61,6 +61,7 @@ HttpRequestCommand::HttpRequestCommand
:AbstractCommand(cuid, req, requestGroup, e, s),
_httpConnection(httpConnection)
{
setTimeout(e->option->getAsInt(PREF_CONNECT_TIMEOUT));
disableReadCheckSocket();
setWriteCheckSocket(socket);
}

View File

@ -155,6 +155,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
handlers.push_back(SH(new DefaultOptionHandler(PREF_SERVER_STAT_IF)));
handlers.push_back(SH(new DefaultOptionHandler(PREF_SERVER_STAT_OF)));
handlers.push_back(SH(new BooleanOptionHandler(PREF_REMOTE_TIME)));
handlers.push_back(SH(new NumberOptionHandler(PREF_CONNECT_TIMEOUT, 1, 600)));
return handlers;
}

View File

@ -98,6 +98,7 @@ Option* createDefaultOption()
op->put(PREF_RETRY_WAIT, "5");
op->put(PREF_TIMEOUT, "60");
op->put(PREF_DNS_TIMEOUT, "30");
op->put(PREF_CONNECT_TIMEOUT, "60");
op->put(PREF_PEER_CONNECTION_TIMEOUT, "20");
op->put(PREF_BT_TIMEOUT, "180");
op->put(PREF_BT_REQUEST_TIMEOUT, "60");
@ -241,6 +242,7 @@ Option* option_processing(int argc, char* const argv[])
{ PREF_SERVER_STAT_OF.c_str(), required_argument, &lopt, 222 },
{ PREF_SERVER_STAT_TIMEOUT.c_str(), required_argument, &lopt, 223 },
{ PREF_REMOTE_TIME.c_str(), optional_argument, 0, 'R' },
{ PREF_CONNECT_TIMEOUT.c_str(), required_argument, &lopt, 224 },
#if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
{ PREF_SHOW_FILES.c_str(), no_argument, NULL, 'S' },
{ PREF_SELECT_FILE.c_str(), required_argument, &lopt, 21 },
@ -483,6 +485,9 @@ Option* option_processing(int argc, char* const argv[])
case 223:
cmdstream << PREF_SERVER_STAT_TIMEOUT << "=" << optarg << "\n";
break;
case 224:
cmdstream << PREF_CONNECT_TIMEOUT << "=" << optarg << "\n";
break;
}
break;
}

View File

@ -54,6 +54,8 @@ const std::string PREF_TIMEOUT("timeout");
// values: 1*digit
const std::string PREF_DNS_TIMEOUT("dns-timeout");
// values: 1*digit
const std::string PREF_CONNECT_TIMEOUT("connect-timeout");
// values: 1*digit
const std::string PREF_MAX_TRIES("max-tries");
// values: 1*digit
const std::string PREF_MIN_SEGMENT_SIZE("min-segment-size");

View File

@ -58,6 +58,8 @@ extern const std::string PREF_TIMEOUT;
// values: 1*digit
extern const std::string PREF_DNS_TIMEOUT;
// values: 1*digit
extern const std::string PREF_CONNECT_TIMEOUT;
// values: 1*digit
extern const std::string PREF_MAX_TRIES;
// values: 1*digit
extern const std::string PREF_MIN_SEGMENT_SIZE;

View File

@ -360,3 +360,8 @@ _(" --log-level=LEVEL Set log level to output.")
_(" -R, --remote-time[=true|false] Retrieve timestamp of the remote file from the\n"\
" remote HTTP/FTP server and if it is available,\n"\
" apply it to the local file.")
#define TEXT_CONNECT_TIMEOUT \
_(" --connect-timeout=SEC Set the connect timeout in seconds to establish\n"\
" connection to HTTP/FTP/proxy server. After the\n"\
" connection is established, this option makes no\n"\
" effect and --timeout option is used instead.")