[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 173/264: socks: Fix blocking timeout logic
From: |
gnunet |
Subject: |
[gnurl] 173/264: socks: Fix blocking timeout logic |
Date: |
Thu, 30 Apr 2020 16:07:56 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 0510cce8c090920f063b85a36669d8e74cff8d52
Author: Jay Satiro <address@hidden>
AuthorDate: Sat Apr 11 23:19:55 2020 -0400
socks: Fix blocking timeout logic
- Document in Curl_timeleft's comment block that returning 0 signals no
timeout (ie there's infinite time left).
- Fix SOCKS' Curl_blockread_all for the case when no timeout was set.
Prior to this change if the timeout had a value of 0 and that was passed
to SOCKET_READABLE it would return right away instead of blocking. That
was likely because it was not well understood that when Curl_timeleft
returns 0 it is not a timeout of 0 ms but actually means no timeout.
Ref: https://github.com/curl/curl/pull/5214#issuecomment-612512360
Closes https://github.com/curl/curl/pull/5220
---
lib/connect.c | 3 ++-
lib/socks.c | 10 +++++-----
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/connect.c b/lib/connect.c
index 54c5f9e4c..421f90415 100644
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -171,7 +171,8 @@ singleipconnect(struct connectdata *conn,
/*
* Curl_timeleft() returns the amount of milliseconds left allowed for the
- * transfer/connection. If the value is negative, the timeout time has already
+ * transfer/connection. If the value is 0, there's no timeout (ie there's
+ * infinite time left). If the value is negative, the timeout time has already
* elapsed.
*
* The start time is stored in progress.t_startsingle - as set with
diff --git a/lib/socks.c b/lib/socks.c
index 5dd83631c..dfd944ef3 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -62,15 +62,15 @@ int Curl_blockread_all(struct connectdata *conn, /*
connection data */
int result;
*n = 0;
for(;;) {
- timediff_t timeleft = Curl_timeleft(conn->data, NULL, TRUE);
- if(timeleft < 0) {
+ timediff_t timeout_ms = Curl_timeleft(conn->data, NULL, TRUE);
+ if(timeout_ms < 0) {
/* we already got the timeout */
result = CURLE_OPERATION_TIMEDOUT;
break;
}
- if(timeleft > TIME_T_MAX)
- timeleft = TIME_T_MAX;
- if(SOCKET_READABLE(sockfd, (time_t)timeleft) <= 0) {
+ if(!timeout_ms || timeout_ms > TIME_T_MAX)
+ timeout_ms = TIME_T_MAX;
+ if(SOCKET_READABLE(sockfd, (time_t)timeout_ms) <= 0) {
result = ~CURLE_OK;
break;
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Windows, (continued)
- [gnurl] 165/264: tests: use Cygwin/msys PIDs for stunnel and sshd on Windows, gnunet, 2020/04/30
- [gnurl] 264/264: make gnurl-aux, gnunet, 2020/04/30
- [gnurl] 177/264: cirrus: no longer ignore test 504 which is working again, gnunet, 2020/04/30
- [gnurl] 180/264: tool: do not declare functions with Curl_ prefix, gnunet, 2020/04/30
- [gnurl] 229/264: http: free memory when Alt-Used header creation fails due to OOM, gnunet, 2020/04/30
- [gnurl] 162/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 157/264: sshserver.pl: use cached Win32 environment check variable, gnunet, 2020/04/30
- [gnurl] 175/264: test1908: avoid using fixed port number in test data, gnunet, 2020/04/30
- [gnurl] 183/264: tests: support hex encoded data and mqtt server, gnunet, 2020/04/30
- [gnurl] 156/264: appveyor: partially revert 3413a110 to keep build without proxy, gnunet, 2020/04/30
- [gnurl] 173/264: socks: Fix blocking timeout logic,
gnunet <=
- [gnurl] 190/264: RELEASE-NOTES: synced, gnunet, 2020/04/30
- [gnurl] 188/264: github/workflow: enable MQTT in the macOS debug build, gnunet, 2020/04/30
- [gnurl] 186/264: travis: add mqtt job on Linux, gnunet, 2020/04/30
- [gnurl] 230/264: server/tftpd: fix compiler warning, gnunet, 2020/04/30
- [gnurl] 263/264: Merge tag 'curl-7_70_0', gnunet, 2020/04/30
- [gnurl] 196/264: scripts/release-notes.pl: accept colon after the Fixes/Closes keywords, gnunet, 2020/04/30
- [gnurl] 169/264: tests/server: add CTRL event handler for Win32 consoles, gnunet, 2020/04/30
- [gnurl] 243/264: libcurl-multi.3: added missing full stop, gnunet, 2020/04/30
- [gnurl] 209/264: tests: move pingpong server to dynamic listening port, gnunet, 2020/04/30
- [gnurl] 184/264: tests: add the mqtt test server mqttd, gnunet, 2020/04/30