aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-03-04 16:34:20 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-03-04 16:34:20 +0000
commitcf8704ccdf60a34ba7862a0848724b9862158c86 (patch)
treef553b638347df8e1b1c129e5dc51a840bcb2ce1a /lib
parent5543c2f11fe9ae27db2f367ac99422888a3e526d (diff)
7.7 alpha 2 commit
Diffstat (limited to 'lib')
-rw-r--r--lib/url.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/url.c b/lib/url.c
index 9318d4132..123e5d480 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -576,6 +576,32 @@ CURLcode curl_disconnect(CURLconnect *c_connect)
}
/*
+ * This function should return TRUE if the socket is to be assumed to
+ * be dead. Most commonly this happens when the server has closed the
+ * connection due to inactivity.
+ */
+static bool SocketIsDead(int sock)
+{
+ int sval;
+ bool ret_val = TRUE;
+ fd_set check_set;
+ struct timeval to;
+
+ FD_ZERO(&check_set);
+ FD_SET(sock,&check_set);
+
+ to.tv_sec = 0;
+ to.tv_usec = 1;
+
+ sval = select(sock + 1, &check_set, 0, 0, &to);
+ if(sval == 0)
+ /* timeout */
+ ret_val = FALSE;
+
+ return ret_val;
+}
+
+/*
* Given one filled in connection struct, this function should detect if there
* already is one that have all the significant details exactly the same and
* thus should be used instead.
@@ -609,6 +635,16 @@ ConnectionExists(struct UrlData *data,
continue;
}
}
+ {
+ bool dead;
+ dead = SocketIsDead(check->firstsocket);
+ if(dead) {
+ infof(data, "Connection %d seems to be dead!\n", i);
+ curl_disconnect(check); /* disconnect resources */
+ data->connects[i]=NULL; /* nothing here */
+ continue; /* try another one now */
+ }
+ }
*usethis = check;
return TRUE; /* yes, we found one to use! */
}
@@ -909,7 +945,6 @@ static CURLcode ConnectPlease(struct UrlData *data,
return CURLE_OK;
}
-
static CURLcode _connect(CURL *curl,
CURLconnect **in_connect,
bool allow_port) /* allow data->use_port ? */