aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-10-08 13:03:26 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-10-08 13:03:26 +0000
commit512db1bc545fa7fc7289968a66ae8b82c5fae657 (patch)
tree2f155771db3173140ee5069edf2a290a35f21b66 /lib
parente157aabd4dc8c28b89f7a0627ebc8718bd5d160c (diff)
Added timeout support for the non-windows version.
Diffstat (limited to 'lib')
-rw-r--r--lib/telnet.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/telnet.c b/lib/telnet.c
index 55d2c9a43..0267235d8 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -1050,6 +1050,7 @@ CURLcode Curl_telnet(struct connectdata *conn)
char *buf = data->state.buffer;
ssize_t nread;
struct TELNET *tn;
+ struct timeval now; /* current time */
code = init_telnet(conn);
if(code)
@@ -1149,9 +1150,13 @@ CURLcode Curl_telnet(struct connectdata *conn)
keepfd = readfd;
while (keepon) {
+ struct timeval interval;
+
readfd = keepfd; /* set this every lap in the loop */
+ interval.tv_sec = 1;
+ interval.tv_usec = 0;
- switch (select (sockfd + 1, &readfd, NULL, NULL, NULL)) {
+ switch (select (sockfd + 1, &readfd, NULL, NULL, &interval)) {
case -1: /* error, stop reading */
keepon = FALSE;
continue;
@@ -1199,10 +1204,20 @@ CURLcode Curl_telnet(struct connectdata *conn)
}
}
}
+ if(data->set.timeout) {
+ now = Curl_tvnow();
+ if(Curl_tvdiff(now, conn->created)/1000 >= data->set.timeout) {
+ failf(data, "Time-out");
+ code = CURLE_OPERATION_TIMEOUTED;
+ keepon = FALSE;
+ }
+ }
}
#endif
/* mark this as "no further transfer wanted" */
- return Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+ Curl_Transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
+
+ return code;
}
/*