diff options
author | Daniel Stenberg <daniel@haxx.se> | 2004-05-05 07:17:37 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2004-05-05 07:17:37 +0000 |
commit | 7591e07b7c3715d92cc6b4fce664883b3f50898f (patch) | |
tree | a5b50ca9863884c22b76467c95c3053916757197 | |
parent | 35ab93f48462cf6e5dc06c58b21342cb6870cbef (diff) |
do the alarm time-left math using unsigned longs since that is what alarm()
returns and uses as input and converting to signed generates warnings and
actually risks loss of accuracy
-rw-r--r-- | lib/url.c | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -3174,14 +3174,16 @@ static CURLcode CreateConnection(struct SessionHandle *data, the time we spent until now! */ if(prev_alarm) { /* there was an alarm() set before us, now put it back */ - long elapsed_ms = Curl_tvdiff(Curl_tvnow(), conn->created); - long alarm_set; + unsigned long elapsed_ms = Curl_tvdiff(Curl_tvnow(), conn->created); + unsigned long alarm_set; /* the alarm period is counted in even number of seconds */ alarm_set = prev_alarm - elapsed_ms/1000; - - if(alarm_set<=0) { - /* if it turned negative, we should fire off a SIGALRM here, but we + + if(!alarm_set || + ((alarm_set >= 0x80000000) && (prev_alarm < 0x80000000)) ) { + /* if the alarm time-left reached zero or turned "negative" (counted + with unsigned values), we should fire off a SIGALRM here, but we won't, and zero would be to switch it off so we never set it to less than 1! */ alarm(1); |