diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/asyn-ares.c | 5 | ||||
-rw-r--r-- | lib/asyn-base.c | 6 | ||||
-rw-r--r-- | lib/bufq.c | 3 | ||||
-rw-r--r-- | lib/easy.c | 57 | ||||
-rw-r--r-- | lib/vquic/vquic.c | 35 |
5 files changed, 65 insertions, 41 deletions
diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index bb3f4af0b..3eb769d93 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -280,8 +280,9 @@ void Curl_async_ares_destroy(struct Curl_easy *data) CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps) { struct async_ares_ctx *ares = &data->state.async.ares; - DEBUGASSERT(ares->channel); - return Curl_ares_pollset(data, ares->channel, ps); + if(ares->channel) + return Curl_ares_pollset(data, ares->channel, ps); + return CURLE_OK; } /* diff --git a/lib/asyn-base.c b/lib/asyn-base.c index c0df7aac5..eb2240b81 100644 --- a/lib/asyn-base.c +++ b/lib/asyn-base.c @@ -91,6 +91,10 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data, timediff_t milli; CURLcode result = CURLE_OK; + DEBUGASSERT(channel); + if(!channel) + return CURLE_FAILED_INIT; + bitmap = ares_getsock(channel, (ares_socket_t *)sockets, CURL_ARRAYSIZE(sockets)); for(i = 0; i < CURL_ARRAYSIZE(sockets); ++i) { @@ -107,6 +111,8 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data, } timeout = ares_timeout(channel, &maxtime, &timebuf); + if(!timeout) + timeout = &maxtime; milli = curlx_tvtoms(timeout); Curl_expire(data, milli, EXPIRE_ASYNC_NAME); return result; diff --git a/lib/bufq.c b/lib/bufq.c index c97640a63..40d1af0c1 100644 --- a/lib/bufq.c +++ b/lib/bufq.c @@ -602,8 +602,7 @@ static CURLcode bufq_slurpn(struct bufq *q, size_t max_len, break; } else if(n == 0) { - /* eof */ - result = CURLE_OK; + /* eof, result remains CURLE_OK */ break; } *pnread += n; diff --git a/lib/easy.c b/lib/easy.c index b526e6cff..b9b8d5275 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -567,6 +567,39 @@ static unsigned int populate_fds(struct pollfd *fds, struct events *ev) return numfds; } +/* poll_fds() + * + * poll the fds[] array + */ +static CURLcode poll_fds(struct events *ev, + struct pollfd *fds, + const unsigned int numfds, + int *pollrc) +{ + if(numfds) { + /* wait for activity or timeout */ +#if DEBUG_EV_POLL + fprintf(stderr, "poll(numfds=%u, timeout=%ldms)\n", numfds, ev->ms); +#endif + *pollrc = Curl_poll(fds, numfds, ev->ms); +#if DEBUG_EV_POLL + fprintf(stderr, "poll(numfds=%u, timeout=%ldms) -> %d\n", + numfds, ev->ms, *pollrc); +#endif + if(*pollrc < 0) + return CURLE_UNRECOVERABLE_POLL; + } + else { +#if DEBUG_EV_POLL + fprintf(stderr, "poll, but no fds, wait timeout=%ldms\n", ev->ms); +#endif + *pollrc = 0; + if(ev->ms > 0) + curlx_wait_ms(ev->ms); + } + return CURLE_OK; +} + /* wait_or_timeout() * * waits for activity on any of the given sockets, or the timeout to trigger. @@ -587,27 +620,9 @@ static CURLcode wait_or_timeout(struct Curl_multi *multi, struct events *ev) /* get the time stamp to use to figure out how long poll takes */ before = curlx_now(); - if(numfds) { - /* wait for activity or timeout */ -#if DEBUG_EV_POLL - fprintf(stderr, "poll(numfds=%u, timeout=%ldms)\n", numfds, ev->ms); -#endif - pollrc = Curl_poll(fds, numfds, ev->ms); -#if DEBUG_EV_POLL - fprintf(stderr, "poll(numfds=%u, timeout=%ldms) -> %d\n", - numfds, ev->ms, pollrc); -#endif - if(pollrc < 0) - return CURLE_UNRECOVERABLE_POLL; - } - else { -#if DEBUG_EV_POLL - fprintf(stderr, "poll, but no fds, wait timeout=%ldms\n", ev->ms); -#endif - pollrc = 0; - if(ev->ms > 0) - curlx_wait_ms(ev->ms); - } + result = poll_fds(ev, fds, numfds, &pollrc); + if(result) + return result; ev->msbump = FALSE; /* reset here */ diff --git a/lib/vquic/vquic.c b/lib/vquic/vquic.c index 43a2c9502..f3a02f63a 100644 --- a/lib/vquic/vquic.c +++ b/lib/vquic/vquic.c @@ -30,6 +30,9 @@ #ifdef HAVE_FCNTL_H #include <fcntl.h> #endif +#ifdef USE_NGHTTP3 +#include <nghttp3/nghttp3.h> +#endif #include "../urldata.h" #include "../bufq.h" #include "../curlx/dynbuf.h" @@ -726,55 +729,55 @@ CURLcode Curl_conn_may_http3(struct Curl_easy *data, #if defined(USE_NGTCP2) || defined(USE_NGHTTP3) -static void *Curl_ngtcp2_malloc(size_t size, void *user_data) +static void *vquic_ngtcp2_malloc(size_t size, void *user_data) { (void)user_data; return Curl_cmalloc(size); } -static void Curl_ngtcp2_free(void *ptr, void *user_data) +static void vquic_ngtcp2_free(void *ptr, void *user_data) { (void)user_data; Curl_cfree(ptr); } -static void *Curl_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data) +static void *vquic_ngtcp2_calloc(size_t nmemb, size_t size, void *user_data) { (void)user_data; return Curl_ccalloc(nmemb, size); } -static void *Curl_ngtcp2_realloc(void *ptr, size_t size, void *user_data) +static void *vquic_ngtcp2_realloc(void *ptr, size_t size, void *user_data) { (void)user_data; return Curl_crealloc(ptr, size); } #ifdef USE_NGTCP2 -static struct ngtcp2_mem curl_ngtcp2_mem = { +static struct ngtcp2_mem vquic_ngtcp2_mem = { NULL, - Curl_ngtcp2_malloc, - Curl_ngtcp2_free, - Curl_ngtcp2_calloc, - Curl_ngtcp2_realloc + vquic_ngtcp2_malloc, + vquic_ngtcp2_free, + vquic_ngtcp2_calloc, + vquic_ngtcp2_realloc }; struct ngtcp2_mem *Curl_ngtcp2_mem(void) { - return &curl_ngtcp2_mem; + return &vquic_ngtcp2_mem; } #endif #ifdef USE_NGHTTP3 -static struct nghttp3_mem curl_nghttp3_mem = { +static struct nghttp3_mem vquic_nghttp3_mem = { NULL, - Curl_ngtcp2_malloc, - Curl_ngtcp2_free, - Curl_ngtcp2_calloc, - Curl_ngtcp2_realloc + vquic_ngtcp2_malloc, + vquic_ngtcp2_free, + vquic_ngtcp2_calloc, + vquic_ngtcp2_realloc }; struct nghttp3_mem *Curl_nghttp3_mem(void) { - return &curl_nghttp3_mem; + return &vquic_nghttp3_mem; } #endif |