aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2017-10-26 15:24:50 +0200
committerDaniel Stenberg <daniel@haxx.se>2017-10-28 10:40:51 +0200
commit0d85eed3dfbbce18303900385d17f84d939cef00 (patch)
treee86f91d28fd31de4cc625fc1db9e2650f5feef11
parent9dfc541dd7d11870d51b69c93083b805de30239f (diff)
Curl_timeleft: change return type to timediff_t
returning 'time_t' is problematic when that type is unsigned and we return values less than zero to signal "already expired", used in several places in the code. Closes #2021
-rw-r--r--lib/asyn-ares.c2
-rwxr-xr-xlib/connect.c10
-rw-r--r--lib/connect.h7
-rw-r--r--lib/ftp.c6
-rw-r--r--lib/multi.c2
-rw-r--r--lib/socks.c4
-rw-r--r--lib/ssh.c2
-rw-r--r--lib/tftp.c2
-rw-r--r--lib/url.c2
9 files changed, 19 insertions, 18 deletions
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c
index dd7dc4028..38ede999c 100644
--- a/lib/asyn-ares.c
+++ b/lib/asyn-ares.c
@@ -354,7 +354,7 @@ CURLcode Curl_resolver_wait_resolv(struct connectdata *conn,
{
CURLcode result = CURLE_OK;
struct Curl_easy *data = conn->data;
- long timeout;
+ timediff_t timeout;
struct curltime now = Curl_now();
struct Curl_dns_entry *temp_entry;
diff --git a/lib/connect.c b/lib/connect.c
index 5f545f230..787026942 100755
--- a/lib/connect.c
+++ b/lib/connect.c
@@ -179,12 +179,12 @@ singleipconnect(struct connectdata *conn,
*
* @unittest: 1303
*/
-time_t Curl_timeleft(struct Curl_easy *data,
- struct curltime *nowp,
- bool duringconnect)
+timediff_t Curl_timeleft(struct Curl_easy *data,
+ struct curltime *nowp,
+ bool duringconnect)
{
int timeout_set = 0;
- time_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
+ timediff_t timeout_ms = duringconnect?DEFAULT_CONNECT_TIMEOUT:0;
struct curltime now;
/* if a timeout is set, use the most restrictive one */
@@ -1148,7 +1148,7 @@ CURLcode Curl_connecthost(struct connectdata *conn, /* context */
struct curltime before = Curl_now();
CURLcode result = CURLE_COULDNT_CONNECT;
- time_t timeout_ms = Curl_timeleft(data, &before, TRUE);
+ timediff_t timeout_ms = Curl_timeleft(data, &before, TRUE);
if(timeout_ms < 0) {
/* a precaution, no need to continue if time already is up */
diff --git a/lib/connect.h b/lib/connect.h
index 3f05c3978..397448636 100644
--- a/lib/connect.h
+++ b/lib/connect.h
@@ -25,6 +25,7 @@
#include "nonblock.h" /* for curlx_nonblock(), formerly Curl_nonblock() */
#include "sockaddr.h"
+#include "timeval.h"
CURLcode Curl_is_connected(struct connectdata *conn,
int sockindex,
@@ -35,9 +36,9 @@ CURLcode Curl_connecthost(struct connectdata *conn,
/* generic function that returns how much time there's left to run, according
to the timeouts set */
-time_t Curl_timeleft(struct Curl_easy *data,
- struct curltime *nowp,
- bool duringconnect);
+timediff_t Curl_timeleft(struct Curl_easy *data,
+ struct curltime *nowp,
+ bool duringconnect);
#define DEFAULT_CONNECT_TIMEOUT 300000 /* milliseconds == five minutes */
#define HAPPY_EYEBALLS_TIMEOUT 200 /* milliseconds to wait between
diff --git a/lib/ftp.c b/lib/ftp.c
index 5c7df2b4c..8042edf48 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -333,10 +333,10 @@ static CURLcode AcceptServerConnect(struct connectdata *conn)
* Curl_pgrsTime(..., TIMER_STARTACCEPT);
*
*/
-static time_t ftp_timeleft_accept(struct Curl_easy *data)
+static timediff_t ftp_timeleft_accept(struct Curl_easy *data)
{
- time_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
- time_t other;
+ timediff_t timeout_ms = DEFAULT_ACCEPT_TIMEOUT;
+ timediff_t other;
struct curltime now;
if(data->set.accepttimeout > 0)
diff --git a/lib/multi.c b/lib/multi.c
index 658a18b15..262f192ca 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1318,7 +1318,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
struct SingleRequest *k;
time_t timeout_ms;
time_t recv_timeout_ms;
- time_t send_timeout_ms;
+ timediff_t send_timeout_ms;
int control;
if(!GOOD_EASY_HANDLE(data))
diff --git a/lib/socks.c b/lib/socks.c
index e64cb98d4..ac4270eac 100644
--- a/lib/socks.c
+++ b/lib/socks.c
@@ -57,7 +57,7 @@ int Curl_blockread_all(struct connectdata *conn, /* connection data */
ssize_t nread;
ssize_t allread = 0;
int result;
- time_t timeleft;
+ timediff_t timeleft;
*n = 0;
for(;;) {
timeleft = Curl_timeleft(conn->data, NULL, TRUE);
@@ -382,7 +382,7 @@ CURLcode Curl_SOCKS5(const char *proxy_user,
CURLcode code;
curl_socket_t sock = conn->sock[sockindex];
struct Curl_easy *data = conn->data;
- time_t timeout;
+ timediff_t timeout;
bool socks5_resolve_local =
(conn->socks_proxy.proxytype == CURLPROXY_SOCKS5) ? TRUE : FALSE;
const size_t hostname_len = strlen(hostname);
diff --git a/lib/ssh.c b/lib/ssh.c
index e225ed297..c4a369997 100644
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -2833,7 +2833,7 @@ static CURLcode ssh_block_statemach(struct connectdata *conn,
while((sshc->state != SSH_STOP) && !result) {
bool block;
- time_t left = 1000;
+ timediff_t left = 1000;
struct curltime now = Curl_now();
result = ssh_statemach_act(conn, &block);
diff --git a/lib/tftp.c b/lib/tftp.c
index a47c24162..20dc60040 100644
--- a/lib/tftp.c
+++ b/lib/tftp.c
@@ -200,7 +200,7 @@ const struct Curl_handler Curl_handler_tftp = {
static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
{
time_t maxtime, timeout;
- time_t timeout_ms;
+ timediff_t timeout_ms;
bool start = (state->state == TFTP_STATE_START) ? TRUE : FALSE;
time(&state->start_time);
diff --git a/lib/url.c b/lib/url.c
index 03ee0855a..5a11e423b 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -6323,7 +6323,7 @@ static CURLcode resolve_server(struct Curl_easy *data,
bool *async)
{
CURLcode result = CURLE_OK;
- time_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
+ timediff_t timeout_ms = Curl_timeleft(data, NULL, TRUE);
/*************************************************************
* Resolve the name of the server or proxy