mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
simplify code of Curl_resolv_timeout()
This commit is contained in:
parent
64ac64e783
commit
7425db3fab
10
lib/hostip.c
10
lib/hostip.c
@ -564,12 +564,15 @@ int Curl_resolv_timeout(struct connectdata *conn,
|
||||
else
|
||||
timeout = timeoutms;
|
||||
|
||||
if(timeout && timeout < 1000)
|
||||
if(!timeout)
|
||||
/* USE_ALARM_TIMEOUT defined, but no timeout actually requested */
|
||||
return Curl_resolv(conn, hostname, port, entry);
|
||||
|
||||
if(timeout < 1000)
|
||||
/* The alarm() function only provides integer second resolution, so if
|
||||
we want to wait less than one second we must bail out already now. */
|
||||
return CURLRESOLV_TIMEDOUT;
|
||||
|
||||
if (timeout > 0) {
|
||||
/*************************************************************
|
||||
* Set signal handler to catch SIGALRM
|
||||
* Store the old value to be able to set it back later!
|
||||
@ -608,7 +611,6 @@ int Curl_resolv_timeout(struct connectdata *conn,
|
||||
rc = CURLRESOLV_ERROR;
|
||||
goto clean_up;
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef CURLRES_ASYNCH
|
||||
@ -627,7 +629,6 @@ int Curl_resolv_timeout(struct connectdata *conn,
|
||||
#ifdef USE_ALARM_TIMEOUT
|
||||
clean_up:
|
||||
|
||||
if (timeout > 0) {
|
||||
if(!prev_alarm)
|
||||
/* deactivate a possibly active alarm before uninstalling the handler */
|
||||
alarm(0);
|
||||
@ -667,7 +668,6 @@ clean_up:
|
||||
else
|
||||
alarm((unsigned int)alarm_set);
|
||||
}
|
||||
}
|
||||
#endif /* USE_ALARM_TIMEOUT */
|
||||
|
||||
return rc;
|
||||
|
Loading…
Reference in New Issue
Block a user