mirror of
https://github.com/curl/curl.git
synced 2026-08-25 22:13:33 +03:00
Now uses sigsetjmp() and siglongjmp() to bail out from slow name lookups in
case a timeout is set. This seems to work. God knows if it is good enough or what kind of side-effects we introduce here and now. I'll close my eyes and cross my fingers. Hard.
This commit is contained in:
parent
4cfffd6c4a
commit
3c49b405de
3 changed files with 63 additions and 22 deletions
17
lib/hostip.c
17
lib/hostip.c
|
|
@ -56,6 +56,10 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SETJMP_H
|
||||
#include <setjmp.h>
|
||||
#endif
|
||||
|
||||
#include "urldata.h"
|
||||
#include "sendf.h"
|
||||
#include "hostip.h"
|
||||
|
|
@ -191,6 +195,11 @@ hostcache_prune(curl_hash *hostcache, int cache_timeout, int now)
|
|||
return (__v); \
|
||||
}
|
||||
|
||||
#ifdef HAVE_SIGSETJMP
|
||||
/* Beware this is a global and unique instance */
|
||||
sigjmp_buf curl_jmpenv;
|
||||
#endif
|
||||
|
||||
Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
|
||||
char *hostname,
|
||||
int port)
|
||||
|
|
@ -201,6 +210,14 @@ Curl_addrinfo *Curl_resolv(struct SessionHandle *data,
|
|||
time_t now;
|
||||
char *bufp;
|
||||
|
||||
#ifdef HAVE_SIGSETJMP
|
||||
if(sigsetjmp(curl_jmpenv, 1) != 0) {
|
||||
/* this is coming from a siglongjmp() */
|
||||
failf(data, "name lookup time-outed");
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* If the host cache timeout is 0, we don't do DNS cach'ing
|
||||
so fall through */
|
||||
if (data->set.dns_cache_timeout == 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue