[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 172/264: gopher: check remaining time left during write busy loo
From: |
gnunet |
Subject: |
[gnurl] 172/264: gopher: check remaining time left during write busy loop |
Date: |
Thu, 30 Apr 2020 16:07:55 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit be28bc2241212bbcbe4b7ac67ee1882955b5f7f3
Author: Marc Hoersken <address@hidden>
AuthorDate: Sun Apr 12 14:03:38 2020 +0200
gopher: check remaining time left during write busy loop
Prior to this change gopher's blocking code would block forever,
ignoring any set timeout value.
Assisted-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Similar to #5220 and #5221
Closes #5214
---
lib/gopher.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/lib/gopher.c b/lib/gopher.c
index b296c62d1..1c613934d 100644
--- a/lib/gopher.c
+++ b/lib/gopher.c
@@ -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 > TIME_T_MAX)
+ timeout_ms = TIME_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, (time_t)timeout_ms);
+ if(what < 0) {
result = CURLE_SEND_ERROR;
break;
}
+ else if(!what) {
+ result = CURLE_OPERATION_TIMEDOUT;
+ break;
+ }
}
free(sel_org);
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 261/264: THANKS: synced with the 7.70.0 release, (continued)
- [gnurl] 261/264: THANKS: synced with the 7.70.0 release, gnunet, 2020/04/30
- [gnurl] 249/264: runtests: when <killserver> mentions http, kill http/2 too, gnunet, 2020/04/30
- [gnurl] 260/264: headers: copyright range fix, gnunet, 2020/04/30
- [gnurl] 251/264: lib: clean up whitespace, gnunet, 2020/04/30
- [gnurl] 257/264: travis: bump the wolfssl CI build to use 4.4.0, gnunet, 2020/04/30
- [gnurl] 217/264: runtests: use a unix domain socket path with the pid in the name, gnunet, 2020/04/30
- [gnurl] 220/264: ensure all references to ports are replaced by vars, gnunet, 2020/04/30
- [gnurl] 221/264: release-notes.pl: fix parsing typo, gnunet, 2020/04/30
- [gnurl] 222/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 225/264: tests: run the TFTP test server on a dynamic port number, gnunet, 2020/04/30
- [gnurl] 172/264: gopher: check remaining time left during write busy loop,
gnunet <=
- [gnurl] 187/264: azure: add mqtt support to one of the Windows builds, gnunet, 2020/04/30
- [gnurl] 168/264: tests/server: move all signal handling routines to util.[ch], gnunet, 2020/04/30
- [gnurl] 171/264: gnutls: ensure TLS 1.3 when SRP isn't requested, gnunet, 2020/04/30
- [gnurl] 206/264: tests: introduce preprocessed test cases, gnunet, 2020/04/30
- [gnurl] 207/264: test1448: work with dynamic HTTP server port, gnunet, 2020/04/30
- [gnurl] 208/264: test1056: work with dynamic HTTP ipv6 port, gnunet, 2020/04/30