summaryrefslogtreecommitdiffstats
path: root/Utilities/cmcurl/lib/gopher.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-06-24 12:13:02 (GMT)
committerBrad King <brad.king@kitware.com>2020-06-24 12:13:02 (GMT)
commit0ef8fa5000cddd5b0c3908a765a2c2d482bc2fdf (patch)
tree7f02ed6d5e482522263c1ad8e027132363055678 /Utilities/cmcurl/lib/gopher.c
parent39f7cfad31aed063a1199a5d67c99c53a182b746 (diff)
parent5717fdc114a704cddae629e20e6588191360e98a (diff)
downloadCMake-0ef8fa5000cddd5b0c3908a765a2c2d482bc2fdf.zip
CMake-0ef8fa5000cddd5b0c3908a765a2c2d482bc2fdf.tar.gz
CMake-0ef8fa5000cddd5b0c3908a765a2c2d482bc2fdf.tar.bz2
Merge branch 'upstream-curl' into update-curl
* upstream-curl: curl 2020-06-23 (e9db32a0)
Diffstat (limited to 'Utilities/cmcurl/lib/gopher.c')
-rw-r--r--Utilities/cmcurl/lib/gopher.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/Utilities/cmcurl/lib/gopher.c b/Utilities/cmcurl/lib/gopher.c
index b296c62..c48098f 100644
--- a/Utilities/cmcurl/lib/gopher.c
+++ b/Utilities/cmcurl/lib/gopher.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2019, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,6 +28,7 @@
#include <curl/curl.h>
#include "transfer.h"
#include "sendf.h"
+#include "connect.h"
#include "progress.h"
#include "gopher.h"
#include "select.h"
@@ -83,8 +84,10 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
char *query = data->state.up.query;
char *sel = NULL;
char *sel_org = NULL;
+ timediff_t timeout_ms;
ssize_t amount, k;
size_t len;
+ int what;
*done = TRUE; /* unconditionally */
@@ -139,19 +142,29 @@ static CURLcode gopher_do(struct connectdata *conn, bool *done)
else
break;
+ timeout_ms = Curl_timeleft(conn->data, NULL, FALSE);
+ if(timeout_ms < 0) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ break;
+ }
+ if(!timeout_ms)
+ timeout_ms = TIMEDIFF_T_MAX;
+
/* Don't busyloop. The entire loop thing is a work-around as it causes a
BLOCKING behavior which is a NO-NO. This function should rather be
split up in a do and a doing piece where the pieces that aren't
possible to send now will be sent in the doing function repeatedly
until the entire request is sent.
-
- Wait a while for the socket to be writable. Note that this doesn't
- acknowledge the timeout.
*/
- if(SOCKET_WRITABLE(sockfd, 100) < 0) {
+ what = SOCKET_WRITABLE(sockfd, timeout_ms);
+ if(what < 0) {
result = CURLE_SEND_ERROR;
break;
}
+ else if(!what) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ break;
+ }
}
free(sel_org);