Package: libnanohttp1
Version: 1.1.0-14
Severity: normal
Currently the code has no timeout on the http connection. It has a timeout
on read operations that defaults to 10 seconds (and can be set to other
values). If a server is offline and packets are being dropped then the
kernel TCP timeout applies and that takes 189 seconds on my Lenny system -
which is generally longer than desired on modern networks.
The following patch makes the timeout that is used for reads also apply to
connect.
diff -ru libcsoap-1.1.0.bak/nanohttp/nanohttp-socket.c
libcsoap-1.1.0/nanohttp/nanohttp-socket.c
--- libcsoap-1.1.0.bak/nanohttp/nanohttp-socket.c 2009-04-18
19:06:04.000000000 +1000
+++ libcsoap-1.1.0/nanohttp/nanohttp-socket.c 2009-04-18 19:01:56.000000000
+1000
@@ -176,6 +176,10 @@
{
struct sockaddr_in address;
struct hostent *host;
+ fd_set fds;
+ struct timeval timeout;
+ int ret;
+
#define GETHOSTBYNAME_R
#ifdef GETHOSTBYNAME_R
struct hostent hostbuf;
@@ -208,10 +212,23 @@
log_verbose4("Opening %s://%s:%i", ssl ? "https" : "http", hostname, port);
/* connect to the server */
- if (connect(dsock->sock, (struct sockaddr *) &address, sizeof(address)) !=
- 0)
- return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT,
+ if (fcntl(dsock->sock, F_SETFL, O_NONBLOCK) == -1
+ || connect(dsock->sock, (struct sockaddr *) &address, sizeof(address)) != 0)
+ {
+ if(errno != EINPROGRESS)
+ return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT,
"Socket error (%s)", strerror(errno));
+ }
+
+ FD_ZERO(&fds);
+ FD_SET(dsock->sock, &fds);
+ timeout.tv_sec = httpd_get_timeout();
+ timeout.tv_usec = 0;
+ ret = select(dsock->sock + 1, NULL, &fds, NULL, &timeout);
+ if(ret == 0)
+ return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT, "Socket timeout");
+ if(ret == -1)
+ return herror_new("hsocket_open", HSOCKET_ERROR_CONNECT, "select error");
if (ssl)
{
-- System Information:
Debian Release: 5.0.1
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=ANSI_X3.4-1968)
(ignored: LC_ALL set to C)
Shell: /bin/sh linked to /bin/bash
Versions of packages libnanohttp1 depends on:
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libssl0.9.8 0.9.8g-15+lenny1 SSL shared libraries
ii libxml2 2.6.32.dfsg-5 GNOME XML library
libnanohttp1 recommends no packages.
libnanohttp1 suggests no packages.
-- debconf-show failed
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]