mirror of
https://github.com/curl/curl.git
synced 2026-01-18 17:21:26 +01:00
lib: fix formatting nits (part 1)
From `lib/a*` to `lib/cs*`. Closes #19764
This commit is contained in:
@@ -64,7 +64,6 @@ const char *Curl_alpnid2str(enum alpnid id)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void altsvc_free(struct altsvc *as)
|
||||
{
|
||||
curlx_free(as->src.host);
|
||||
|
||||
@@ -68,7 +68,7 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
|
||||
const int versions); /* CURLALTSVC_H* bits */
|
||||
#else
|
||||
/* disabled */
|
||||
#define Curl_altsvc_save(a,b,c)
|
||||
#define Curl_altsvc_save(a, b, c)
|
||||
#define Curl_altsvc_cleanup(x)
|
||||
#endif /* !CURL_DISABLE_HTTP && !CURL_DISABLE_ALTSVC */
|
||||
#endif /* HEADER_CURL_ALTSVC_H */
|
||||
|
||||
@@ -120,8 +120,7 @@ void Curl_amiga_cleanup(void)
|
||||
* allocates memory also.
|
||||
*/
|
||||
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
int port)
|
||||
struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname, int port)
|
||||
{
|
||||
struct Curl_addrinfo *ai = NULL;
|
||||
struct hostent *h;
|
||||
@@ -144,7 +143,7 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef CURLRES_THREADED
|
||||
#ifdef CURLRES_THREADED
|
||||
/* gethostbyname() is not thread safe, so we need to reopen bsdsocket
|
||||
* on the thread's context
|
||||
*/
|
||||
@@ -160,13 +159,13 @@ struct Curl_addrinfo *Curl_ipv4_resolve_r(const char *hostname,
|
||||
}
|
||||
CloseLibrary(base);
|
||||
}
|
||||
#else
|
||||
#else
|
||||
/* not using threaded resolver - safe to use this as-is */
|
||||
h = gethostbyname(hostname);
|
||||
if(h) {
|
||||
ai = Curl_he2ai(h, port);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
return ai;
|
||||
@@ -219,8 +218,7 @@ CURLcode Curl_amiga_init(void)
|
||||
}
|
||||
|
||||
if(SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))), (ULONG)&errno,
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl",
|
||||
TAG_DONE)) {
|
||||
SBTM_SETVAL(SBTC_LOGTAGPTR), (ULONG)"curl", TAG_DONE)) {
|
||||
CURL_AMIGA_REQUEST("SocketBaseTags ERROR");
|
||||
return CURLE_FAILED_INIT;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
/*
|
||||
* The telnet options represented as strings
|
||||
*/
|
||||
static const char * const telnetoptions[]=
|
||||
{
|
||||
static const char * const telnetoptions[] = {
|
||||
"BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD",
|
||||
"NAME", "STATUS", "TIMING MARK", "RCTE",
|
||||
"NAOL", "NAOP", "NAOCRD", "NAOHTS",
|
||||
@@ -86,8 +85,7 @@ static const char * const telnetoptions[]=
|
||||
/*
|
||||
* Then those numbers represented as strings:
|
||||
*/
|
||||
static const char * const telnetcmds[]=
|
||||
{
|
||||
static const char * const telnetcmds[] = {
|
||||
"EOF", "SUSP", "ABORT", "EOR", "SE",
|
||||
"NOP", "DMARK", "BRK", "IP", "AO",
|
||||
"AYT", "EC", "EL", "GA", "SB",
|
||||
@@ -103,11 +101,11 @@ static const char * const telnetcmds[]=
|
||||
#define CURL_TELQUAL_INFO 2
|
||||
#define CURL_TELQUAL_NAME 3
|
||||
|
||||
#define CURL_TELCMD_OK(x) ( ((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
|
||||
((unsigned int)(x) <= CURL_TELCMD_MAXIMUM) )
|
||||
#define CURL_TELCMD_OK(x) (((unsigned int)(x) >= CURL_TELCMD_MINIMUM) && \
|
||||
((unsigned int)(x) <= CURL_TELCMD_MAXIMUM))
|
||||
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
#define CURL_TELCMD(x) telnetcmds[(x)-CURL_TELCMD_MINIMUM]
|
||||
#define CURL_TELCMD(x) telnetcmds[(x) - CURL_TELCMD_MINIMUM]
|
||||
#else
|
||||
#define CURL_TELCMD(x) ""
|
||||
#endif
|
||||
|
||||
@@ -140,7 +140,6 @@ void Curl_async_global_cleanup(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static void sock_state_cb(void *data, ares_socket_t socket_fd,
|
||||
int readable, int writable)
|
||||
{
|
||||
@@ -309,12 +308,12 @@ CURLcode Curl_async_is_resolved(struct Curl_easy *data,
|
||||
/* Now that we have checked for any last minute results above, see if there
|
||||
are any responses still pending when the EXPIRE_HAPPY_EYEBALLS_DNS timer
|
||||
expires. */
|
||||
if(ares->num_pending
|
||||
if(ares->num_pending &&
|
||||
/* This is only set to non-zero if the timer was started. */
|
||||
&& (ares->happy_eyeballs_dns_time.tv_sec
|
||||
|| ares->happy_eyeballs_dns_time.tv_usec)
|
||||
&& (curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time)
|
||||
>= HAPPY_EYEBALLS_DNS_TIMEOUT)) {
|
||||
(ares->happy_eyeballs_dns_time.tv_sec ||
|
||||
ares->happy_eyeballs_dns_time.tv_usec) &&
|
||||
(curlx_timediff_ms(curlx_now(), ares->happy_eyeballs_dns_time) >=
|
||||
HAPPY_EYEBALLS_DNS_TIMEOUT)) {
|
||||
/* Remember that the EXPIRE_HAPPY_EYEBALLS_DNS timer is no longer
|
||||
running. */
|
||||
memset(&ares->happy_eyeballs_dns_time, 0,
|
||||
@@ -418,8 +417,8 @@ CURLcode Curl_async_await(struct Curl_easy *data,
|
||||
itimeout_ms = (int)timeout_ms;
|
||||
#endif
|
||||
|
||||
max_timeout.tv_sec = itimeout_ms/1000;
|
||||
max_timeout.tv_usec = (itimeout_ms%1000)*1000;
|
||||
max_timeout.tv_sec = itimeout_ms / 1000;
|
||||
max_timeout.tv_usec = (itimeout_ms % 1000) * 1000;
|
||||
|
||||
real_timeout = ares_timeout(ares->channel, &max_timeout, &time_buf);
|
||||
|
||||
@@ -427,7 +426,7 @@ CURLcode Curl_async_await(struct Curl_easy *data,
|
||||
second is left, otherwise just use 1000ms to make sure the progress
|
||||
callback gets called frequent enough */
|
||||
if(!real_timeout->tv_sec)
|
||||
call_timeout_ms = (timediff_t)(real_timeout->tv_usec/1000);
|
||||
call_timeout_ms = (timediff_t)(real_timeout->tv_usec / 1000);
|
||||
else
|
||||
call_timeout_ms = 1000;
|
||||
|
||||
@@ -518,7 +517,7 @@ static void async_ares_hostbyname_cb(void *user_data,
|
||||
if(ARES_SUCCESS == status) {
|
||||
ares->ares_status = status; /* one success overrules any error */
|
||||
async_addr_concat(&ares->temp_ai,
|
||||
Curl_he2ai(hostent, data->state.async.port));
|
||||
Curl_he2ai(hostent, data->state.async.port));
|
||||
}
|
||||
else if(ares->ares_status != ARES_SUCCESS) {
|
||||
/* no success so far, remember last error */
|
||||
@@ -586,8 +585,7 @@ static void async_ares_hostbyname_cb(void *user_data,
|
||||
c-ares retry cycle each request is.
|
||||
*/
|
||||
ares->happy_eyeballs_dns_time = curlx_now();
|
||||
Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT,
|
||||
EXPIRE_HAPPY_EYEBALLS_DNS);
|
||||
Curl_expire(data, HAPPY_EYEBALLS_DNS_TIMEOUT, EXPIRE_HAPPY_EYEBALLS_DNS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@
|
||||
**********************************************************************/
|
||||
#ifdef CURLRES_ASYNCH
|
||||
|
||||
|
||||
#ifdef USE_ARES
|
||||
|
||||
#if ARES_VERSION < 0x010600
|
||||
@@ -122,8 +121,7 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data,
|
||||
*
|
||||
* return number of sockets it worked on, or -1 on error
|
||||
*/
|
||||
int Curl_ares_perform(ares_channel channel,
|
||||
timediff_t timeout_ms)
|
||||
int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms)
|
||||
{
|
||||
int nfds;
|
||||
int bitmask;
|
||||
@@ -142,11 +140,11 @@ int Curl_ares_perform(ares_channel channel,
|
||||
pfd[i].revents = 0;
|
||||
if(ARES_GETSOCK_READABLE(bitmask, i)) {
|
||||
pfd[i].fd = socks[i];
|
||||
pfd[i].events |= POLLRDNORM|POLLIN;
|
||||
pfd[i].events |= POLLRDNORM | POLLIN;
|
||||
}
|
||||
if(ARES_GETSOCK_WRITABLE(bitmask, i)) {
|
||||
pfd[i].fd = socks[i];
|
||||
pfd[i].events |= POLLWRNORM|POLLOUT;
|
||||
pfd[i].events |= POLLWRNORM | POLLOUT;
|
||||
}
|
||||
if(pfd[i].events)
|
||||
num++;
|
||||
|
||||
@@ -45,13 +45,13 @@
|
||||
#endif
|
||||
|
||||
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
|
||||
# include <pthread.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
# define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */
|
||||
#define RESOLVER_ENOMEM EAI_MEMORY /* = WSA_NOT_ENOUGH_MEMORY on Windows */
|
||||
#else
|
||||
# define RESOLVER_ENOMEM SOCKENOMEM
|
||||
#define RESOLVER_ENOMEM SOCKENOMEM
|
||||
#endif
|
||||
|
||||
#include "urldata.h"
|
||||
@@ -245,7 +245,6 @@ static CURL_THREAD_RETURN_T CURL_STDCALL getaddrinfo_thread(void *arg)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
addr_ctx_unlink(&addr_ctx, NULL);
|
||||
@@ -486,8 +485,8 @@ static void async_thrdd_shutdown(struct Curl_easy *data)
|
||||
|
||||
Curl_mutex_acquire(&addr_ctx->mutx);
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
if(!addr_ctx->do_abort)
|
||||
Curl_multi_will_close(data, addr_ctx->sock_pair[0]);
|
||||
if(!addr_ctx->do_abort)
|
||||
Curl_multi_will_close(data, addr_ctx->sock_pair[0]);
|
||||
#endif
|
||||
addr_ctx->do_abort = TRUE;
|
||||
done = addr_ctx->thrd_done;
|
||||
@@ -703,7 +702,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps)
|
||||
|
||||
if(!thrd_done) {
|
||||
#ifndef CURL_DISABLE_SOCKETPAIR
|
||||
/* return read fd to client for polling the DNS resolution status */
|
||||
/* return read fd to client for polling the DNS resolution status */
|
||||
result = Curl_pollset_add_in(data, ps, thrdd->addr->sock_pair[0]);
|
||||
#else
|
||||
timediff_t milli;
|
||||
@@ -711,7 +710,7 @@ CURLcode Curl_async_pollset(struct Curl_easy *data, struct easy_pollset *ps)
|
||||
if(ms < 3)
|
||||
milli = 0;
|
||||
else if(ms <= 50)
|
||||
milli = ms/3;
|
||||
milli = ms / 3;
|
||||
else if(ms <= 250)
|
||||
milli = 50;
|
||||
else
|
||||
|
||||
20
lib/asyn.h
20
lib/asyn.h
@@ -129,19 +129,18 @@ CURLcode Curl_ares_pollset(struct Curl_easy *data,
|
||||
ares_channel channel,
|
||||
struct easy_pollset *ps);
|
||||
|
||||
int Curl_ares_perform(ares_channel channel,
|
||||
timediff_t timeout_ms);
|
||||
int Curl_ares_perform(ares_channel channel, timediff_t timeout_ms);
|
||||
#endif
|
||||
|
||||
#ifdef CURLRES_ARES
|
||||
/* async resolving implementation using c-ares alone */
|
||||
struct async_ares_ctx {
|
||||
ares_channel channel;
|
||||
int num_pending; /* number of outstanding c-ares requests */
|
||||
int num_pending; /* number of outstanding c-ares requests */
|
||||
struct Curl_addrinfo *temp_ai; /* intermediary result while fetching c-ares
|
||||
parts */
|
||||
int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */
|
||||
CURLcode result; /* CURLE_OK or error handling response */
|
||||
int ares_status; /* ARES_SUCCESS, ARES_ENOTFOUND, etc. */
|
||||
CURLcode result; /* CURLE_OK or error handling response */
|
||||
#ifndef HAVE_CARES_GETADDRINFO
|
||||
struct curltime happy_eyeballs_dns_time; /* when this timer started, or 0 */
|
||||
#endif
|
||||
@@ -223,11 +222,11 @@ struct doh_probes;
|
||||
#else /* CURLRES_ASYNCH */
|
||||
|
||||
/* convert these functions if an asynch resolver is not used */
|
||||
#define Curl_async_get_impl(x,y) (*(y) = NULL, CURLE_OK)
|
||||
#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
|
||||
#define Curl_async_await(x,y) CURLE_COULDNT_RESOLVE_HOST
|
||||
#define Curl_async_global_init() CURLE_OK
|
||||
#define Curl_async_global_cleanup() Curl_nop_stmt
|
||||
#define Curl_async_get_impl(x, y) (*(y) = NULL, CURLE_OK)
|
||||
#define Curl_async_is_resolved(x,y) CURLE_COULDNT_RESOLVE_HOST
|
||||
#define Curl_async_await(x, y) CURLE_COULDNT_RESOLVE_HOST
|
||||
#define Curl_async_global_init() CURLE_OK
|
||||
#define Curl_async_global_cleanup() Curl_nop_stmt
|
||||
|
||||
#endif /* !CURLRES_ASYNCH */
|
||||
|
||||
@@ -270,6 +269,5 @@ void Curl_async_destroy(struct Curl_easy *data);
|
||||
#define Curl_async_destroy(x) Curl_nop_stmt
|
||||
#endif /* USE_CURL_ASYNC */
|
||||
|
||||
|
||||
/********** end of generic resolver interface functions *****************/
|
||||
#endif /* HEADER_CURL_ASYN_H */
|
||||
|
||||
@@ -143,7 +143,6 @@ static void chunk_list_free(struct buf_chunk **anchor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Curl_bufcp_init(struct bufc_pool *pool,
|
||||
size_t chunk_size, size_t spare_max)
|
||||
{
|
||||
@@ -330,7 +329,7 @@ static void prune_head(struct bufq *q)
|
||||
--q->chunk_count;
|
||||
}
|
||||
else if((q->chunk_count > q->max_chunks) ||
|
||||
(q->opts & BUFQ_OPT_NO_SPARES)) {
|
||||
(q->opts & BUFQ_OPT_NO_SPARES)) {
|
||||
/* SOFT_LIMIT allowed us more than max. free spares until
|
||||
* we are at max again. Or free them if we are configured
|
||||
* to not use spares. */
|
||||
|
||||
@@ -38,7 +38,7 @@ struct buf_chunk {
|
||||
size_t r_offset; /* first unread bytes */
|
||||
size_t w_offset; /* one after last written byte */
|
||||
union {
|
||||
uint8_t data[1]; /* the buffer for `dlen` bytes */
|
||||
uint8_t data[1]; /* the buffer for `dlen` bytes */
|
||||
void *dummy; /* alignment */
|
||||
} x;
|
||||
};
|
||||
|
||||
@@ -76,7 +76,7 @@ void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len,
|
||||
DEBUGASSERT(len <= CURL_MAX_INPUT_LENGTH);
|
||||
|
||||
Curl_bufref_free(br);
|
||||
br->ptr = (const unsigned char *) ptr;
|
||||
br->ptr = (const unsigned char *)ptr;
|
||||
br->len = len;
|
||||
br->dtor = dtor;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ struct bufref {
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
void Curl_bufref_init(struct bufref *br);
|
||||
void Curl_bufref_set(struct bufref *br, const void *ptr, size_t len,
|
||||
void (*dtor)(void *));
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
|
||||
|
||||
typedef enum {
|
||||
H1_TUNNEL_INIT, /* init/default/no tunnel state */
|
||||
H1_TUNNEL_CONNECT, /* CONNECT request is being send */
|
||||
H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */
|
||||
H1_TUNNEL_RESPONSE, /* CONNECT response received completely */
|
||||
H1_TUNNEL_ESTABLISHED,
|
||||
H1_TUNNEL_FAILED
|
||||
H1_TUNNEL_INIT, /* init/default/no tunnel state */
|
||||
H1_TUNNEL_CONNECT, /* CONNECT request is being send */
|
||||
H1_TUNNEL_RECEIVE, /* CONNECT answer is being received */
|
||||
H1_TUNNEL_RESPONSE, /* CONNECT response received completely */
|
||||
H1_TUNNEL_ESTABLISHED,
|
||||
H1_TUNNEL_FAILED
|
||||
} h1_tunnel_state;
|
||||
|
||||
/* struct for HTTP CONNECT tunneling */
|
||||
@@ -74,7 +74,6 @@ struct h1_tunnel_state {
|
||||
BIT(close_connection);
|
||||
};
|
||||
|
||||
|
||||
static bool tunnel_is_established(struct h1_tunnel_state *ts)
|
||||
{
|
||||
return ts && (ts->tunnel_state == H1_TUNNEL_ESTABLISHED);
|
||||
@@ -209,9 +208,9 @@ static CURLcode start_CONNECT(struct Curl_cfilter *cf,
|
||||
int http_minor;
|
||||
CURLcode result;
|
||||
|
||||
/* This only happens if we have looped here due to authentication
|
||||
reasons, and we do not really use the newly cloned URL here
|
||||
then. Just free it. */
|
||||
/* This only happens if we have looped here due to authentication
|
||||
reasons, and we do not really use the newly cloned URL here
|
||||
then. Just free it. */
|
||||
Curl_safefree(data->req.newurl);
|
||||
|
||||
result = Curl_http_proxy_create_CONNECT(&req, cf, data, 1);
|
||||
@@ -281,10 +280,8 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
|
||||
struct SingleRequest *k = &data->req;
|
||||
(void)cf;
|
||||
|
||||
if((checkprefix("WWW-Authenticate:", header) &&
|
||||
(401 == k->httpcode)) ||
|
||||
(checkprefix("Proxy-authenticate:", header) &&
|
||||
(407 == k->httpcode))) {
|
||||
if((checkprefix("WWW-Authenticate:", header) && (401 == k->httpcode)) ||
|
||||
(checkprefix("Proxy-authenticate:", header) && (407 == k->httpcode))) {
|
||||
|
||||
bool proxy = (k->httpcode == 407);
|
||||
char *auth = Curl_copy_header_value(header);
|
||||
@@ -300,7 +297,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
|
||||
return result;
|
||||
}
|
||||
else if(checkprefix("Content-Length:", header)) {
|
||||
if(k->httpcode/100 == 2) {
|
||||
if(k->httpcode / 100 == 2) {
|
||||
/* A client MUST ignore any Content-Length or Transfer-Encoding
|
||||
header fields received in a successful response to CONNECT.
|
||||
"Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
|
||||
@@ -319,7 +316,7 @@ static CURLcode on_resp_header(struct Curl_cfilter *cf,
|
||||
STRCONST("Connection:"), STRCONST("close")))
|
||||
ts->close_connection = TRUE;
|
||||
else if(checkprefix("Transfer-Encoding:", header)) {
|
||||
if(k->httpcode/100 == 2) {
|
||||
if(k->httpcode / 100 == 2) {
|
||||
/* A client MUST ignore any Content-Length or Transfer-Encoding
|
||||
header fields received in a successful response to CONNECT.
|
||||
"Successful" described as: 2xx (Successful). RFC 7231 4.3.6 */
|
||||
@@ -493,8 +490,8 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
|
||||
ts->keepon = KEEPON_DONE;
|
||||
}
|
||||
|
||||
DEBUGASSERT(ts->keepon == KEEPON_IGNORE
|
||||
|| ts->keepon == KEEPON_DONE);
|
||||
DEBUGASSERT(ts->keepon == KEEPON_IGNORE ||
|
||||
ts->keepon == KEEPON_DONE);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -508,7 +505,7 @@ static CURLcode recv_CONNECT_resp(struct Curl_cfilter *cf,
|
||||
if(error)
|
||||
result = CURLE_RECV_ERROR;
|
||||
*done = (ts->keepon == KEEPON_DONE);
|
||||
if(!result && *done && data->info.httpproxycode/100 != 2) {
|
||||
if(!result && *done && data->info.httpproxycode / 100 != 2) {
|
||||
/* Deal with the possibly already received authenticate
|
||||
headers. 'newurl' is set to a new URL if we must loop. */
|
||||
result = Curl_http_auth_act(data);
|
||||
@@ -603,7 +600,7 @@ static CURLcode H1_CONNECT(struct Curl_cfilter *cf,
|
||||
} while(data->req.newurl);
|
||||
|
||||
DEBUGASSERT(ts->tunnel_state == H1_TUNNEL_RESPONSE);
|
||||
if(data->info.httpproxycode/100 != 2) {
|
||||
if(data->info.httpproxycode / 100 != 2) {
|
||||
/* a non-2xx response and we have no next URL to try. */
|
||||
Curl_safefree(data->req.newurl);
|
||||
h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data);
|
||||
@@ -716,10 +713,9 @@ static void cf_h1_proxy_close(struct Curl_cfilter *cf,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct Curl_cftype Curl_cft_h1_proxy = {
|
||||
"H1-PROXY",
|
||||
CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
|
||||
CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
|
||||
0,
|
||||
cf_h1_proxy_destroy,
|
||||
cf_h1_proxy_connect,
|
||||
|
||||
@@ -33,7 +33,6 @@ CURLcode Curl_cf_h1_proxy_insert_after(struct Curl_cfilter *cf,
|
||||
|
||||
extern struct Curl_cftype Curl_cft_h1_proxy;
|
||||
|
||||
|
||||
#endif /* !CURL_DISABLE_PROXY && !CURL_DISABLE_HTTP */
|
||||
|
||||
#endif /* HEADER_CURL_H1_PROXY_H */
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
#include "curlx/warnless.h"
|
||||
#include "cf-h2-proxy.h"
|
||||
|
||||
#define PROXY_H2_CHUNK_SIZE (16*1024)
|
||||
#define PROXY_H2_CHUNK_SIZE (16 * 1024)
|
||||
|
||||
#define PROXY_HTTP2_HUGE_WINDOW_SIZE (100 * 1024 * 1024)
|
||||
#define H2_TUNNEL_WINDOW_SIZE (10 * 1024 * 1024)
|
||||
|
||||
#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
|
||||
#define PROXY_H2_NW_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
|
||||
#define PROXY_H2_NW_SEND_CHUNKS 1
|
||||
|
||||
#define H2_TUNNEL_RECV_CHUNKS (H2_TUNNEL_WINDOW_SIZE / PROXY_H2_CHUNK_SIZE)
|
||||
@@ -58,11 +58,11 @@
|
||||
|
||||
|
||||
typedef enum {
|
||||
H2_TUNNEL_INIT, /* init/default/no tunnel state */
|
||||
H2_TUNNEL_CONNECT, /* CONNECT request is being send */
|
||||
H2_TUNNEL_RESPONSE, /* CONNECT response received completely */
|
||||
H2_TUNNEL_ESTABLISHED,
|
||||
H2_TUNNEL_FAILED
|
||||
H2_TUNNEL_INIT, /* init/default/no tunnel state */
|
||||
H2_TUNNEL_CONNECT, /* CONNECT request is being send */
|
||||
H2_TUNNEL_RESPONSE, /* CONNECT response received completely */
|
||||
H2_TUNNEL_ESTABLISHED,
|
||||
H2_TUNNEL_FAILED
|
||||
} h2_tunnel_state;
|
||||
|
||||
struct tunnel_stream {
|
||||
@@ -94,7 +94,7 @@ static CURLcode tunnel_stream_init(struct Curl_cfilter *cf,
|
||||
Curl_http_proxy_get_destination(cf, &hostname, &port, &ipv6_ip);
|
||||
|
||||
/* host:port with IPv6 support */
|
||||
ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[":"", hostname,
|
||||
ts->authority = curl_maprintf("%s%s%s:%d", ipv6_ip ? "[" : "", hostname,
|
||||
ipv6_ip ? "]" : "", port);
|
||||
if(!ts->authority)
|
||||
return CURLE_OUT_OF_MEMORY;
|
||||
@@ -184,8 +184,7 @@ struct cf_h2_proxy_ctx {
|
||||
|
||||
/* How to access `call_data` from a cf_h2 filter */
|
||||
#undef CF_CTX_CALL_DATA
|
||||
#define CF_CTX_CALL_DATA(cf) \
|
||||
((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
|
||||
#define CF_CTX_CALL_DATA(cf) ((struct cf_h2_proxy_ctx *)(cf)->ctx)->call_data
|
||||
|
||||
static void cf_h2_proxy_ctx_clear(struct cf_h2_proxy_ctx *ctx)
|
||||
{
|
||||
@@ -542,70 +541,70 @@ static int proxy_h2_fr_print(const nghttp2_frame *frame,
|
||||
char *buffer, size_t blen)
|
||||
{
|
||||
switch(frame->hd.type) {
|
||||
case NGHTTP2_DATA: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[DATA, len=%d, eos=%d, padlen=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
|
||||
(int)frame->data.padlen);
|
||||
case NGHTTP2_DATA: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[DATA, len=%d, eos=%d, padlen=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM),
|
||||
(int)frame->data.padlen);
|
||||
}
|
||||
case NGHTTP2_HEADERS: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
|
||||
}
|
||||
case NGHTTP2_PRIORITY: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PRIORITY, len=%d, flags=%d]",
|
||||
(int)frame->hd.length, frame->hd.flags);
|
||||
}
|
||||
case NGHTTP2_RST_STREAM: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
|
||||
(int)frame->hd.length, frame->hd.flags,
|
||||
frame->rst_stream.error_code);
|
||||
}
|
||||
case NGHTTP2_SETTINGS: {
|
||||
if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
|
||||
return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
|
||||
}
|
||||
case NGHTTP2_HEADERS: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[HEADERS, len=%d, hend=%d, eos=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS),
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_STREAM));
|
||||
}
|
||||
case NGHTTP2_PRIORITY: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PRIORITY, len=%d, flags=%d]",
|
||||
(int)frame->hd.length, frame->hd.flags);
|
||||
}
|
||||
case NGHTTP2_RST_STREAM: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[RST_STREAM, len=%d, flags=%d, error=%u]",
|
||||
(int)frame->hd.length, frame->hd.flags,
|
||||
frame->rst_stream.error_code);
|
||||
}
|
||||
case NGHTTP2_SETTINGS: {
|
||||
if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
|
||||
return curl_msnprintf(buffer, blen, "FRAME[SETTINGS, ack=1]");
|
||||
}
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
|
||||
}
|
||||
case NGHTTP2_PUSH_PROMISE:
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PUSH_PROMISE, len=%d, hend=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
|
||||
case NGHTTP2_PING:
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PING, len=%d, ack=%d]",
|
||||
(int)frame->hd.length,
|
||||
frame->hd.flags & NGHTTP2_FLAG_ACK);
|
||||
case NGHTTP2_GOAWAY: {
|
||||
char scratch[128];
|
||||
size_t s_len = CURL_ARRAYSIZE(scratch);
|
||||
size_t len = (frame->goaway.opaque_data_len < s_len) ?
|
||||
frame->goaway.opaque_data_len : s_len-1;
|
||||
if(len)
|
||||
memcpy(scratch, frame->goaway.opaque_data, len);
|
||||
scratch[len] = '\0';
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[GOAWAY, error=%d, reason='%s', "
|
||||
"last_stream=%d]", frame->goaway.error_code,
|
||||
scratch, frame->goaway.last_stream_id);
|
||||
}
|
||||
case NGHTTP2_WINDOW_UPDATE: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[WINDOW_UPDATE, incr=%d]",
|
||||
frame->window_update.window_size_increment);
|
||||
}
|
||||
default:
|
||||
return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
|
||||
frame->hd.type, (int)frame->hd.length,
|
||||
frame->hd.flags);
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[SETTINGS, len=%d]", (int)frame->hd.length);
|
||||
}
|
||||
case NGHTTP2_PUSH_PROMISE:
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PUSH_PROMISE, len=%d, hend=%d]",
|
||||
(int)frame->hd.length,
|
||||
!!(frame->hd.flags & NGHTTP2_FLAG_END_HEADERS));
|
||||
case NGHTTP2_PING:
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[PING, len=%d, ack=%d]",
|
||||
(int)frame->hd.length,
|
||||
frame->hd.flags & NGHTTP2_FLAG_ACK);
|
||||
case NGHTTP2_GOAWAY: {
|
||||
char scratch[128];
|
||||
size_t s_len = CURL_ARRAYSIZE(scratch);
|
||||
size_t len = (frame->goaway.opaque_data_len < s_len) ?
|
||||
frame->goaway.opaque_data_len : s_len-1;
|
||||
if(len)
|
||||
memcpy(scratch, frame->goaway.opaque_data, len);
|
||||
scratch[len] = '\0';
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[GOAWAY, error=%d, reason='%s', "
|
||||
"last_stream=%d]", frame->goaway.error_code,
|
||||
scratch, frame->goaway.last_stream_id);
|
||||
}
|
||||
case NGHTTP2_WINDOW_UPDATE: {
|
||||
return curl_msnprintf(buffer, blen,
|
||||
"FRAME[WINDOW_UPDATE, incr=%d]",
|
||||
frame->window_update.window_size_increment);
|
||||
}
|
||||
default:
|
||||
return curl_msnprintf(buffer, blen, "FRAME[%d, len=%d, flags=%d]",
|
||||
frame->hd.type, (int)frame->hd.length,
|
||||
frame->hd.flags);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -621,7 +620,7 @@ static int proxy_h2_on_frame_send(nghttp2_session *session,
|
||||
if(data && Curl_trc_cf_is_verbose(cf, data)) {
|
||||
char buffer[256];
|
||||
int len;
|
||||
len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
|
||||
len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1);
|
||||
buffer[len] = 0;
|
||||
CURL_TRC_CF(data, cf, "[%d] -> %s", frame->hd.stream_id, buffer);
|
||||
}
|
||||
@@ -644,9 +643,9 @@ static int proxy_h2_on_frame_recv(nghttp2_session *session,
|
||||
if(Curl_trc_cf_is_verbose(cf, data)) {
|
||||
char buffer[256];
|
||||
int len;
|
||||
len = proxy_h2_fr_print(frame, buffer, sizeof(buffer)-1);
|
||||
len = proxy_h2_fr_print(frame, buffer, sizeof(buffer) - 1);
|
||||
buffer[len] = 0;
|
||||
CURL_TRC_CF(data, cf, "[%d] <- %s",frame->hd.stream_id, buffer);
|
||||
CURL_TRC_CF(data, cf, "[%d] <- %s", frame->hd.stream_id, buffer);
|
||||
}
|
||||
#endif /* !CURL_DISABLE_VERBOSE_STRINGS */
|
||||
|
||||
@@ -962,7 +961,7 @@ static CURLcode inspect_response(struct Curl_cfilter *cf,
|
||||
(void)cf;
|
||||
|
||||
DEBUGASSERT(ts->resp);
|
||||
if(ts->resp->status/100 == 2) {
|
||||
if(ts->resp->status / 100 == 2) {
|
||||
infof(data, "CONNECT tunnel established, response %d", ts->resp->status);
|
||||
h2_tunnel_go_state(cf, ts, H2_TUNNEL_ESTABLISHED, data);
|
||||
return CURLE_OK;
|
||||
@@ -1220,7 +1219,7 @@ static CURLcode cf_h2_proxy_adjust_pollset(struct Curl_cfilter *cf,
|
||||
c_exhaust = !nghttp2_session_get_remote_window_size(ctx->h2);
|
||||
s_exhaust = ctx->tunnel.stream_id >= 0 &&
|
||||
!nghttp2_session_get_stream_remote_window_size(
|
||||
ctx->h2, ctx->tunnel.stream_id);
|
||||
ctx->h2, ctx->tunnel.stream_id);
|
||||
want_recv = (want_recv || c_exhaust || s_exhaust);
|
||||
want_send = (!s_exhaust && want_send) ||
|
||||
(!c_exhaust && nghttp2_session_want_write(ctx->h2)) ||
|
||||
@@ -1414,7 +1413,7 @@ out:
|
||||
"h2 windows %d-%d (stream-conn), buffers %zu-%zu (stream-conn)",
|
||||
ctx->tunnel.stream_id, len, result, *pnwritten,
|
||||
nghttp2_session_get_stream_remote_window_size(
|
||||
ctx->h2, ctx->tunnel.stream_id),
|
||||
ctx->h2, ctx->tunnel.stream_id),
|
||||
nghttp2_session_get_remote_window_size(ctx->h2),
|
||||
Curl_bufq_len(&ctx->tunnel.sendbuf),
|
||||
Curl_bufq_len(&ctx->outbufq));
|
||||
@@ -1566,7 +1565,7 @@ static CURLcode cf_h2_proxy_cntrl(struct Curl_cfilter *cf,
|
||||
|
||||
struct Curl_cftype Curl_cft_h2_proxy = {
|
||||
"H2-PROXY",
|
||||
CF_TYPE_IP_CONNECT|CF_TYPE_PROXY,
|
||||
CF_TYPE_IP_CONNECT | CF_TYPE_PROXY,
|
||||
CURL_LOG_LVL_NONE,
|
||||
cf_h2_proxy_destroy,
|
||||
cf_h2_proxy_connect,
|
||||
|
||||
@@ -36,9 +36,9 @@
|
||||
|
||||
|
||||
typedef enum {
|
||||
HAPROXY_INIT, /* init/default/no tunnel state */
|
||||
HAPROXY_SEND, /* data_out being sent */
|
||||
HAPROXY_DONE /* all work done */
|
||||
HAPROXY_INIT, /* init/default/no tunnel state */
|
||||
HAPROXY_SEND, /* data_out being sent */
|
||||
HAPROXY_DONE /* all work done */
|
||||
} haproxy_state;
|
||||
|
||||
struct cf_haproxy_ctx {
|
||||
@@ -61,7 +61,7 @@ static void cf_haproxy_ctx_free(struct cf_haproxy_ctx *ctx)
|
||||
}
|
||||
}
|
||||
|
||||
static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter*cf,
|
||||
static CURLcode cf_haproxy_date_out_set(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
struct cf_haproxy_ctx *ctx = cf->ctx;
|
||||
|
||||
@@ -108,7 +108,6 @@ void Curl_debug_set_transport_provider(uint8_t transport,
|
||||
}
|
||||
#endif /* UNITTESTS */
|
||||
|
||||
|
||||
struct cf_ai_iter {
|
||||
const struct Curl_addrinfo *head;
|
||||
const struct Curl_addrinfo *last;
|
||||
@@ -423,9 +422,9 @@ evaluate:
|
||||
int ai_family = 0;
|
||||
#ifdef USE_IPV6
|
||||
if((bs->last_attempt_ai_family == AF_INET) ||
|
||||
!cf_ai_iter_has_more(&bs->addr_iter)) {
|
||||
addr = cf_ai_iter_next(&bs->ipv6_iter);
|
||||
ai_family = bs->ipv6_iter.ai_family;
|
||||
!cf_ai_iter_has_more(&bs->addr_iter)) {
|
||||
addr = cf_ai_iter_next(&bs->ipv6_iter);
|
||||
ai_family = bs->ipv6_iter.ai_family;
|
||||
}
|
||||
#endif
|
||||
if(!addr) {
|
||||
@@ -629,7 +628,6 @@ struct cf_ip_happy_ctx {
|
||||
struct curltime started;
|
||||
};
|
||||
|
||||
|
||||
static CURLcode is_connected(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
bool *connected)
|
||||
@@ -774,50 +772,50 @@ static CURLcode cf_ip_happy_connect(struct Curl_cfilter *cf,
|
||||
*done = FALSE;
|
||||
|
||||
switch(ctx->state) {
|
||||
case SCFST_INIT:
|
||||
DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data));
|
||||
DEBUGASSERT(!cf->connected);
|
||||
result = start_connect(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
ctx->state = SCFST_WAITING;
|
||||
FALLTHROUGH();
|
||||
case SCFST_WAITING:
|
||||
result = is_connected(cf, data, done);
|
||||
if(!result && *done) {
|
||||
DEBUGASSERT(ctx->ballers.winner);
|
||||
DEBUGASSERT(ctx->ballers.winner->cf);
|
||||
DEBUGASSERT(ctx->ballers.winner->cf->connected);
|
||||
/* we have a winner. Install and activate it.
|
||||
* close/free all others. */
|
||||
ctx->state = SCFST_DONE;
|
||||
cf->connected = TRUE;
|
||||
cf->next = ctx->ballers.winner->cf;
|
||||
ctx->ballers.winner->cf = NULL;
|
||||
cf_ip_happy_ctx_clear(cf, data);
|
||||
Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS);
|
||||
case SCFST_INIT:
|
||||
DEBUGASSERT(CURL_SOCKET_BAD == Curl_conn_cf_get_socket(cf, data));
|
||||
DEBUGASSERT(!cf->connected);
|
||||
result = start_connect(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
ctx->state = SCFST_WAITING;
|
||||
FALLTHROUGH();
|
||||
case SCFST_WAITING:
|
||||
result = is_connected(cf, data, done);
|
||||
if(!result && *done) {
|
||||
DEBUGASSERT(ctx->ballers.winner);
|
||||
DEBUGASSERT(ctx->ballers.winner->cf);
|
||||
DEBUGASSERT(ctx->ballers.winner->cf->connected);
|
||||
/* we have a winner. Install and activate it.
|
||||
* close/free all others. */
|
||||
ctx->state = SCFST_DONE;
|
||||
cf->connected = TRUE;
|
||||
cf->next = ctx->ballers.winner->cf;
|
||||
ctx->ballers.winner->cf = NULL;
|
||||
cf_ip_happy_ctx_clear(cf, data);
|
||||
Curl_expire_done(data, EXPIRE_HAPPY_EYEBALLS);
|
||||
|
||||
if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
|
||||
Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
|
||||
if(cf->conn->handler->protocol & PROTO_FAMILY_SSH)
|
||||
Curl_pgrsTime(data, TIMER_APPCONNECT); /* we are connected already */
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
if(Curl_trc_cf_is_verbose(cf, data)) {
|
||||
struct ip_quadruple ipquad;
|
||||
bool is_ipv6;
|
||||
if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
|
||||
const char *host;
|
||||
int port;
|
||||
Curl_conn_get_current_host(data, cf->sockindex, &host, &port);
|
||||
CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
|
||||
host, ipquad.remote_ip, ipquad.remote_port);
|
||||
}
|
||||
if(Curl_trc_cf_is_verbose(cf, data)) {
|
||||
struct ip_quadruple ipquad;
|
||||
bool is_ipv6;
|
||||
if(!Curl_conn_cf_get_ip_info(cf->next, data, &is_ipv6, &ipquad)) {
|
||||
const char *host;
|
||||
int port;
|
||||
Curl_conn_get_current_host(data, cf->sockindex, &host, &port);
|
||||
CURL_TRC_CF(data, cf, "Connected to %s (%s) port %u",
|
||||
host, ipquad.remote_ip, ipquad.remote_port);
|
||||
}
|
||||
#endif
|
||||
data->info.numconnects++; /* to track the # of connections made */
|
||||
}
|
||||
break;
|
||||
case SCFST_DONE:
|
||||
*done = TRUE;
|
||||
break;
|
||||
#endif
|
||||
data->info.numconnects++; /* to track the # of connections made */
|
||||
}
|
||||
break;
|
||||
case SCFST_DONE:
|
||||
*done = TRUE;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
117
lib/cf-socket.c
117
lib/cf-socket.c
@@ -96,7 +96,7 @@ static void set_ipv6_v6only(curl_socket_t sockfd, int on)
|
||||
(void)setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, (void *)&on, sizeof(on));
|
||||
}
|
||||
#else
|
||||
#define set_ipv6_v6only(x,y)
|
||||
#define set_ipv6_v6only(x, y)
|
||||
#endif
|
||||
|
||||
static void tcpnodelay(struct Curl_cfilter *cf,
|
||||
@@ -104,7 +104,7 @@ static void tcpnodelay(struct Curl_cfilter *cf,
|
||||
curl_socket_t sockfd)
|
||||
{
|
||||
#if defined(TCP_NODELAY) && defined(CURL_TCP_NODELAY_SUPPORTED)
|
||||
curl_socklen_t onoff = (curl_socklen_t) 1;
|
||||
curl_socklen_t onoff = (curl_socklen_t)1;
|
||||
int level = IPPROTO_TCP;
|
||||
char buffer[STRERROR_LEN];
|
||||
|
||||
@@ -142,7 +142,7 @@ static void nosigpipe(struct Curl_cfilter *cf,
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define nosigpipe(x,y,z) Curl_nop_stmt
|
||||
#define nosigpipe(x, y, z) Curl_nop_stmt
|
||||
#endif
|
||||
|
||||
#if defined(USE_WINSOCK) || \
|
||||
@@ -156,10 +156,9 @@ static void nosigpipe(struct Curl_cfilter *cf,
|
||||
#define KEEPALIVE_FACTOR(x)
|
||||
#endif
|
||||
|
||||
static void
|
||||
tcpkeepalive(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
curl_socket_t sockfd)
|
||||
static void tcpkeepalive(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
curl_socket_t sockfd)
|
||||
{
|
||||
int optval = data->set.tcp_keepalive ? 1 : 0;
|
||||
|
||||
@@ -202,7 +201,7 @@ tcpkeepalive(struct Curl_cfilter *cf,
|
||||
{
|
||||
/* Offered by mingw-w64 and MS SDK. Latter only when targeting Win7+. */
|
||||
#ifndef SIO_KEEPALIVE_VALS
|
||||
#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR,4)
|
||||
#define SIO_KEEPALIVE_VALS _WSAIOW(IOC_VENDOR, 4)
|
||||
struct tcp_keepalive {
|
||||
u_long onoff;
|
||||
u_long keepalivetime;
|
||||
@@ -342,15 +341,15 @@ static CURLcode socket_open(struct Curl_easy *data,
|
||||
DEBUGASSERT(data);
|
||||
DEBUGASSERT(data->conn);
|
||||
if(data->set.fopensocket) {
|
||||
/*
|
||||
* If the opensocket callback is set, all the destination address
|
||||
* information is passed to the callback. Depending on this information the
|
||||
* callback may opt to abort the connection, this is indicated returning
|
||||
* CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When
|
||||
* the callback returns a valid socket the destination address information
|
||||
* might have been changed and this 'new' address will actually be used
|
||||
* here to connect.
|
||||
*/
|
||||
/*
|
||||
* If the opensocket callback is set, all the destination address
|
||||
* information is passed to the callback. Depending on this information the
|
||||
* callback may opt to abort the connection, this is indicated returning
|
||||
* CURL_SOCKET_BAD; otherwise it will return a not-connected socket. When
|
||||
* the callback returns a valid socket the destination address information
|
||||
* might have been changed and this 'new' address will actually be used
|
||||
* here to connect.
|
||||
*/
|
||||
Curl_set_in_callback(data, TRUE);
|
||||
*sockfd = data->set.fopensocket(data->set.opensocket_client,
|
||||
CURLSOCKTYPE_IPCXN,
|
||||
@@ -600,7 +599,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
|
||||
if(!iface && !host && !port)
|
||||
/* no local kind of binding was requested */
|
||||
return CURLE_OK;
|
||||
else if(iface && (strlen(iface) >= 255) )
|
||||
else if(iface && (strlen(iface) >= 255))
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
|
||||
memset(&sa, 0, sizeof(struct Curl_sockaddr_storage));
|
||||
@@ -640,33 +639,33 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
|
||||
/* Discover IP from input device, then bind to it */
|
||||
if2ip_result = Curl_if2ip(af,
|
||||
#ifdef USE_IPV6
|
||||
scope, conn->scope_id,
|
||||
scope, conn->scope_id,
|
||||
#endif
|
||||
iface, myhost, sizeof(myhost));
|
||||
iface, myhost, sizeof(myhost));
|
||||
}
|
||||
switch(if2ip_result) {
|
||||
case IF2IP_NOT_FOUND:
|
||||
if(iface_input && !host_input) {
|
||||
/* Do not fall back to treating it as a hostname */
|
||||
char buffer[STRERROR_LEN];
|
||||
data->state.os_errno = error = SOCKERRNO;
|
||||
failf(data, "Could not bind to interface '%s' with errno %d: %s",
|
||||
iface, error, curlx_strerror(error, buffer, sizeof(buffer)));
|
||||
return CURLE_INTERFACE_FAILED;
|
||||
}
|
||||
break;
|
||||
case IF2IP_AF_NOT_SUPPORTED:
|
||||
/* Signal the caller to try another address family if available */
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
case IF2IP_FOUND:
|
||||
/*
|
||||
* We now have the numerical IP address in the 'myhost' buffer
|
||||
*/
|
||||
host = myhost;
|
||||
infof(data, "Local Interface %s is ip %s using address family %i",
|
||||
iface, host, af);
|
||||
done = 1;
|
||||
break;
|
||||
case IF2IP_NOT_FOUND:
|
||||
if(iface_input && !host_input) {
|
||||
/* Do not fall back to treating it as a hostname */
|
||||
char buffer[STRERROR_LEN];
|
||||
data->state.os_errno = error = SOCKERRNO;
|
||||
failf(data, "Could not bind to interface '%s' with errno %d: %s",
|
||||
iface, error, curlx_strerror(error, buffer, sizeof(buffer)));
|
||||
return CURLE_INTERFACE_FAILED;
|
||||
}
|
||||
break;
|
||||
case IF2IP_AF_NOT_SUPPORTED:
|
||||
/* Signal the caller to try another address family if available */
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
case IF2IP_FOUND:
|
||||
/*
|
||||
* We now have the numerical IP address in the 'myhost' buffer
|
||||
*/
|
||||
host = myhost;
|
||||
infof(data, "Local Interface %s is ip %s using address family %i",
|
||||
iface, host, af);
|
||||
done = 1;
|
||||
break;
|
||||
}
|
||||
if(!iface_input || host_input) {
|
||||
/*
|
||||
@@ -728,7 +727,7 @@ static CURLcode bindlocal(struct Curl_easy *data, struct connectdata *conn,
|
||||
present, is known to be numeric */
|
||||
curl_off_t scope_id;
|
||||
if(curlx_str_number((const char **)CURL_UNCONST(&scope_ptr),
|
||||
&scope_id, UINT_MAX))
|
||||
&scope_id, UINT_MAX))
|
||||
return CURLE_UNSUPPORTED_PROTOCOL;
|
||||
si6->sin6_scope_id = (unsigned int)scope_id;
|
||||
}
|
||||
@@ -921,7 +920,7 @@ struct cf_socket_ctx {
|
||||
int wblock_percent; /* percent of writes doing EAGAIN */
|
||||
int wpartial_percent; /* percent of bytes written in send */
|
||||
int rblock_percent; /* percent of reads doing EAGAIN */
|
||||
size_t recv_max; /* max enforced read size */
|
||||
size_t recv_max; /* max enforced read size */
|
||||
#endif
|
||||
BIT(got_first_byte); /* if first byte was received */
|
||||
BIT(listening); /* socket is listening */
|
||||
@@ -1043,12 +1042,12 @@ static void set_local_ip(struct Curl_cfilter *cf,
|
||||
curl_socklen_t slen = sizeof(struct Curl_sockaddr_storage);
|
||||
|
||||
memset(&ssloc, 0, sizeof(ssloc));
|
||||
if(getsockname(ctx->sock, (struct sockaddr*) &ssloc, &slen)) {
|
||||
if(getsockname(ctx->sock, (struct sockaddr *)&ssloc, &slen)) {
|
||||
int error = SOCKERRNO;
|
||||
infof(data, "getsockname() failed with errno %d: %s",
|
||||
error, curlx_strerror(error, buffer, sizeof(buffer)));
|
||||
}
|
||||
else if(!Curl_addr2string((struct sockaddr*)&ssloc, slen,
|
||||
else if(!Curl_addr2string((struct sockaddr *)&ssloc, slen,
|
||||
ctx->ip.local_ip, &ctx->ip.local_port)) {
|
||||
infof(data, "ssloc inet_ntop() failed with errno %d: %s",
|
||||
errno, curlx_strerror(errno, buffer, sizeof(buffer)));
|
||||
@@ -1123,8 +1122,8 @@ static CURLcode cf_socket_open(struct Curl_cfilter *cf,
|
||||
infof(data, " Trying %s:%d...", ctx->ip.remote_ip, ctx->ip.remote_port);
|
||||
|
||||
#ifdef USE_IPV6
|
||||
is_tcp = (ctx->addr.family == AF_INET
|
||||
|| ctx->addr.family == AF_INET6) &&
|
||||
is_tcp = (ctx->addr.family == AF_INET ||
|
||||
ctx->addr.family == AF_INET6) &&
|
||||
ctx->addr.socktype == SOCK_STREAM;
|
||||
#else
|
||||
is_tcp = (ctx->addr.family == AF_INET) &&
|
||||
@@ -1320,8 +1319,7 @@ static CURLcode cf_tcp_connect(struct Curl_cfilter *cf,
|
||||
rc = SOCKET_WRITABLE(ctx->sock, 0);
|
||||
|
||||
if(rc == 0) { /* no connection yet */
|
||||
CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T,
|
||||
ctx->sock);
|
||||
CURL_TRC_CF(data, cf, "not connected yet on fd=%" FMT_SOCKET_T, ctx->sock);
|
||||
return CURLE_OK;
|
||||
}
|
||||
else if(rc == CURL_CSELECT_OUT || cf->conn->bits.tcp_fastopen) {
|
||||
@@ -1411,7 +1409,7 @@ static void win_update_sndbuf_size(struct cf_socket_ctx *ctx)
|
||||
|
||||
if(curlx_timediff_ms(n, ctx->last_sndbuf_query_at) > 1000) {
|
||||
if(!WSAIoctl(ctx->sock, SIO_IDEAL_SEND_BACKLOG_QUERY, 0, 0,
|
||||
&ideal, sizeof(ideal), &ideallen, 0, 0) &&
|
||||
&ideal, sizeof(ideal), &ideallen, 0, 0) &&
|
||||
ideal != ctx->sndbuf_size &&
|
||||
!setsockopt(ctx->sock, SOL_SOCKET, SO_SNDBUF,
|
||||
(const char *)&ideal, sizeof(ideal))) {
|
||||
@@ -1443,7 +1441,7 @@ static CURLcode cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
if(ctx->wblock_percent > 0) {
|
||||
unsigned char c = 0;
|
||||
Curl_rand_bytes(data, FALSE, &c, 1);
|
||||
if(c >= ((100-ctx->wblock_percent)*256/100)) {
|
||||
if(c >= ((100 - ctx->wblock_percent) * 256 / 100)) {
|
||||
CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE EWOULDBLOCK", orig_len);
|
||||
cf->conn->sock[cf->sockindex] = fdsave;
|
||||
return CURLE_AGAIN;
|
||||
@@ -1520,7 +1518,7 @@ static CURLcode cf_socket_recv(struct Curl_cfilter *cf, struct Curl_easy *data,
|
||||
if(cf->cft != &Curl_cft_udp && ctx->rblock_percent > 0) {
|
||||
unsigned char c = 0;
|
||||
Curl_rand(data, &c, 1);
|
||||
if(c >= ((100-ctx->rblock_percent)*256/100)) {
|
||||
if(c >= ((100 - ctx->rblock_percent) * 256 / 100)) {
|
||||
CURL_TRC_CF(data, cf, "recv(len=%zu) SIMULATE EWOULDBLOCK", len);
|
||||
return CURLE_AGAIN;
|
||||
}
|
||||
@@ -1634,7 +1632,7 @@ static bool cf_socket_conn_is_alive(struct Curl_cfilter *cf,
|
||||
|
||||
/* Check with 0 timeout if there are any events pending on the socket */
|
||||
pfd[0].fd = ctx->sock;
|
||||
pfd[0].events = POLLRDNORM|POLLIN|POLLRDBAND|POLLPRI;
|
||||
pfd[0].events = POLLRDNORM | POLLIN | POLLRDBAND | POLLPRI;
|
||||
pfd[0].revents = 0;
|
||||
|
||||
r = Curl_poll(pfd, 1, 0);
|
||||
@@ -1646,7 +1644,7 @@ static bool cf_socket_conn_is_alive(struct Curl_cfilter *cf,
|
||||
CURL_TRC_CF(data, cf, "is_alive: poll timeout, assume alive");
|
||||
return TRUE;
|
||||
}
|
||||
else if(pfd[0].revents & (POLLERR|POLLHUP|POLLPRI|POLLNVAL)) {
|
||||
else if(pfd[0].revents & (POLLERR | POLLHUP | POLLPRI | POLLNVAL)) {
|
||||
CURL_TRC_CF(data, cf, "is_alive: err/hup/etc events, assume dead");
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1814,7 +1812,6 @@ static void linux_quic_gro(struct cf_socket_ctx *ctx)
|
||||
#define linux_quic_gro(x)
|
||||
#endif
|
||||
|
||||
|
||||
static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
@@ -2035,13 +2032,13 @@ static void cf_tcp_set_accepted_remote_ip(struct Curl_cfilter *cf,
|
||||
ctx->ip.remote_port = 0;
|
||||
plen = sizeof(ssrem);
|
||||
memset(&ssrem, 0, plen);
|
||||
if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) {
|
||||
if(getpeername(ctx->sock, (struct sockaddr *)&ssrem, &plen)) {
|
||||
int error = SOCKERRNO;
|
||||
failf(data, "getpeername() failed with errno %d: %s",
|
||||
error, curlx_strerror(error, buffer, sizeof(buffer)));
|
||||
return;
|
||||
}
|
||||
if(!Curl_addr2string((struct sockaddr*)&ssrem, plen,
|
||||
if(!Curl_addr2string((struct sockaddr *)&ssrem, plen,
|
||||
ctx->ip.remote_ip, &ctx->ip.remote_port)) {
|
||||
failf(data, "ssrem inet_ntop() failed with errno %d: %s",
|
||||
errno, curlx_strerror(errno, buffer, sizeof(buffer)));
|
||||
@@ -2111,10 +2108,10 @@ static CURLcode cf_tcp_accept_connect(struct Curl_cfilter *cf,
|
||||
|
||||
size = sizeof(add);
|
||||
#ifdef HAVE_ACCEPT4
|
||||
s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *) &add, &size,
|
||||
s_accepted = CURL_ACCEPT4(ctx->sock, (struct sockaddr *)&add, &size,
|
||||
SOCK_NONBLOCK | SOCK_CLOEXEC);
|
||||
#else
|
||||
s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *) &add, &size);
|
||||
s_accepted = CURL_ACCEPT(ctx->sock, (struct sockaddr *)&add, &size);
|
||||
#endif
|
||||
|
||||
if(CURL_SOCKET_BAD == s_accepted) {
|
||||
|
||||
@@ -57,7 +57,7 @@ struct Curl_sockaddr_ex {
|
||||
|
||||
/*
|
||||
* Parse interface option, and return the interface name and the host part.
|
||||
*/
|
||||
*/
|
||||
CURLcode Curl_parse_interface(const char *input,
|
||||
char **dev, char **iface, char **host);
|
||||
|
||||
|
||||
@@ -511,8 +511,7 @@ CURLcode Curl_conn_connect(struct Curl_easy *data,
|
||||
goto out;
|
||||
}
|
||||
else if(result) {
|
||||
CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d",
|
||||
result);
|
||||
CURL_TRC_CF(data, cf, "Curl_conn_connect(), filter returned %d", result);
|
||||
conn_report_connect_stats(cf, data);
|
||||
goto out;
|
||||
}
|
||||
@@ -653,7 +652,7 @@ bool Curl_conn_is_multiplex(struct connectdata *conn, int sockindex)
|
||||
for(; cf; cf = cf->next) {
|
||||
if(cf->cft->flags & CF_TYPE_MULTIPLEX)
|
||||
return TRUE;
|
||||
if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL))
|
||||
if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL))
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
@@ -691,7 +690,7 @@ unsigned char Curl_conn_http_version(struct Curl_easy *data,
|
||||
v = (unsigned char)value;
|
||||
break;
|
||||
}
|
||||
if(cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_SSL))
|
||||
if(cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_SSL))
|
||||
break;
|
||||
}
|
||||
return (unsigned char)(result ? 0 : v);
|
||||
@@ -803,9 +802,9 @@ void Curl_conn_get_current_host(struct Curl_easy *data, int sockindex,
|
||||
cf = CONN_SOCK_IDX_VALID(sockindex) ? data->conn->cfilter[sockindex] : NULL;
|
||||
/* Find the "lowest" tunneling proxy filter that has not connected yet. */
|
||||
while(cf && !cf->connected) {
|
||||
if((cf->cft->flags & (CF_TYPE_IP_CONNECT|CF_TYPE_PROXY)) ==
|
||||
(CF_TYPE_IP_CONNECT|CF_TYPE_PROXY))
|
||||
cf_proxy = cf;
|
||||
if((cf->cft->flags & (CF_TYPE_IP_CONNECT | CF_TYPE_PROXY)) ==
|
||||
(CF_TYPE_IP_CONNECT | CF_TYPE_PROXY))
|
||||
cf_proxy = cf;
|
||||
cf = cf->next;
|
||||
}
|
||||
/* cf_proxy (!= NULL) is not connected yet. It is talking
|
||||
@@ -945,8 +944,7 @@ static CURLcode cf_cntrl_all(struct connectdata *conn,
|
||||
|
||||
CURLcode Curl_conn_ev_data_setup(struct Curl_easy *data)
|
||||
{
|
||||
return cf_cntrl_all(data->conn, data, FALSE,
|
||||
CF_CTRL_DATA_SETUP, 0, NULL);
|
||||
return cf_cntrl_all(data->conn, data, FALSE, CF_CTRL_DATA_SETUP, 0, NULL);
|
||||
}
|
||||
|
||||
CURLcode Curl_conn_flush(struct Curl_easy *data, int sockindex)
|
||||
@@ -1100,8 +1098,7 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex,
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
#ifdef DEBUGBUILD
|
||||
if(write_len) {
|
||||
/* Allow debug builds to override this logic to force short sends
|
||||
*/
|
||||
/* Allow debug builds to override this logic to force short sends */
|
||||
const char *p = getenv("CURL_SMALLSENDS");
|
||||
if(p) {
|
||||
curl_off_t altsize;
|
||||
|
||||
@@ -116,16 +116,16 @@ typedef CURLcode Curl_cft_conn_keep_alive(struct Curl_cfilter *cf,
|
||||
* "ignored" meaning return values are ignored and the event is distributed
|
||||
* to all filters in the chain. Overall result is always CURLE_OK.
|
||||
*/
|
||||
/* data event arg1 arg2 return */
|
||||
#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
|
||||
/* unused now 5 */
|
||||
#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
|
||||
#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
|
||||
#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
|
||||
/* data event arg1 arg2 return */
|
||||
#define CF_CTRL_DATA_SETUP 4 /* 0 NULL first fail */
|
||||
/* unused now 5 */
|
||||
#define CF_CTRL_DATA_PAUSE 6 /* on/off NULL first fail */
|
||||
#define CF_CTRL_DATA_DONE 7 /* premature NULL ignored */
|
||||
#define CF_CTRL_DATA_DONE_SEND 8 /* 0 NULL ignored */
|
||||
/* update conn info at connection and data */
|
||||
#define CF_CTRL_CONN_INFO_UPDATE (256+0) /* 0 NULL ignored */
|
||||
#define CF_CTRL_FORGET_SOCKET (256+1) /* 0 NULL ignored */
|
||||
#define CF_CTRL_FLUSH (256+2) /* 0 NULL first fail */
|
||||
#define CF_CTRL_CONN_INFO_UPDATE (256 + 0) /* 0 NULL ignored */
|
||||
#define CF_CTRL_FORGET_SOCKET (256 + 1) /* 0 NULL ignored */
|
||||
#define CF_CTRL_FLUSH (256 + 2) /* 0 NULL first fail */
|
||||
|
||||
/**
|
||||
* Handle event/control for the filter.
|
||||
@@ -135,7 +135,6 @@ typedef CURLcode Curl_cft_cntrl(struct Curl_cfilter *cf,
|
||||
struct Curl_easy *data,
|
||||
int event, int arg1, void *arg2);
|
||||
|
||||
|
||||
/**
|
||||
* Queries to ask via a `Curl_cft_query *query` method on a cfilter chain.
|
||||
* - MAX_CONCURRENT: the maximum number of parallel transfers the filter
|
||||
@@ -210,21 +209,21 @@ typedef CURLcode Curl_cft_query(struct Curl_cfilter *cf,
|
||||
|
||||
/* A connection filter type, e.g. specific implementation. */
|
||||
struct Curl_cftype {
|
||||
const char *name; /* name of the filter type */
|
||||
int flags; /* flags of filter type */
|
||||
int log_level; /* log level for such filters */
|
||||
Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
|
||||
Curl_cft_connect *do_connect; /* establish connection */
|
||||
Curl_cft_close *do_close; /* close conn */
|
||||
Curl_cft_shutdown *do_shutdown; /* shutdown conn */
|
||||
const char *name; /* name of the filter type */
|
||||
int flags; /* flags of filter type */
|
||||
int log_level; /* log level for such filters */
|
||||
Curl_cft_destroy_this *destroy; /* destroy resources of this cf */
|
||||
Curl_cft_connect *do_connect; /* establish connection */
|
||||
Curl_cft_close *do_close; /* close conn */
|
||||
Curl_cft_shutdown *do_shutdown; /* shutdown conn */
|
||||
Curl_cft_adjust_pollset *adjust_pollset; /* adjust transfer poll set */
|
||||
Curl_cft_data_pending *has_data_pending;/* conn has data pending */
|
||||
Curl_cft_send *do_send; /* send data */
|
||||
Curl_cft_recv *do_recv; /* receive data */
|
||||
Curl_cft_cntrl *cntrl; /* events/control */
|
||||
Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
|
||||
Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
|
||||
Curl_cft_query *query; /* query filter chain */
|
||||
Curl_cft_data_pending *has_data_pending; /* conn has data pending */
|
||||
Curl_cft_send *do_send; /* send data */
|
||||
Curl_cft_recv *do_recv; /* receive data */
|
||||
Curl_cft_cntrl *cntrl; /* events/control */
|
||||
Curl_cft_conn_is_alive *is_alive; /* FALSE if conn is dead, Jim! */
|
||||
Curl_cft_conn_keep_alive *keep_alive; /* try to keep it alive */
|
||||
Curl_cft_query *query; /* query filter chain */
|
||||
};
|
||||
|
||||
/* A connection filter instance, e.g. registered at a connection */
|
||||
@@ -426,7 +425,7 @@ const char *Curl_conn_get_alpn_negotiated(struct Curl_easy *data,
|
||||
|
||||
/**
|
||||
* Close the filter chain at `sockindex` for connection `data->conn`.
|
||||
* Filters remain in place and may be connected again afterwards.
|
||||
* Filters remain in place and may be connected again afterwards.
|
||||
*/
|
||||
void Curl_conn_close(struct Curl_easy *data, int sockindex);
|
||||
|
||||
@@ -622,7 +621,6 @@ CURLcode Curl_conn_send(struct Curl_easy *data, int sockindex,
|
||||
const void *buf, size_t blen, bool eos,
|
||||
size_t *pnwritten);
|
||||
|
||||
|
||||
/**
|
||||
* Types and macros used to keep the current easy handle in filter calls,
|
||||
* allowing for nested invocations. See #10336.
|
||||
@@ -654,7 +652,7 @@ struct cf_call_data {
|
||||
* a member in the cfilter's `ctx`.
|
||||
*
|
||||
* #define CF_CTX_CALL_DATA(cf) -> struct cf_call_data instance
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef DEBUGBUILD
|
||||
|
||||
@@ -688,7 +686,6 @@ struct cf_call_data {
|
||||
|
||||
#endif /* !DEBUGBUILD */
|
||||
|
||||
#define CF_DATA_CURRENT(cf) \
|
||||
((cf)? (CF_CTX_CALL_DATA(cf).data) : NULL)
|
||||
#define CF_DATA_CURRENT(cf) ((cf) ? (CF_CTX_CALL_DATA(cf).data) : NULL)
|
||||
|
||||
#endif /* HEADER_CURL_CFILTERS_H */
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define CPOOL_UNLOCK(c,d) \
|
||||
#define CPOOL_UNLOCK(c,d) \
|
||||
do { \
|
||||
if((c)) { \
|
||||
DEBUGASSERT((c)->locked); \
|
||||
@@ -161,7 +161,6 @@ static struct connectdata *cpool_get_first(struct cpool *cpool)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static struct cpool_bundle *cpool_find_bundle(struct cpool *cpool,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
@@ -178,7 +177,6 @@ static void cpool_remove_bundle(struct cpool *cpool,
|
||||
Curl_hash_delete(&cpool->dest2bundle, bundle->dest, bundle->dest_len);
|
||||
}
|
||||
|
||||
|
||||
static void cpool_remove_conn(struct cpool *cpool,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
@@ -260,8 +258,8 @@ void Curl_cpool_xfer_init(struct Curl_easy *data)
|
||||
}
|
||||
}
|
||||
|
||||
static struct cpool_bundle *
|
||||
cpool_add_bundle(struct cpool *cpool, struct connectdata *conn)
|
||||
static struct cpool_bundle *cpool_add_bundle(struct cpool *cpool,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
struct cpool_bundle *bundle;
|
||||
|
||||
@@ -341,7 +339,6 @@ static struct connectdata *cpool_get_oldest_idle(struct cpool *cpool)
|
||||
return oldest_idle;
|
||||
}
|
||||
|
||||
|
||||
int Curl_cpool_check_limits(struct Curl_easy *data,
|
||||
struct connectdata *conn)
|
||||
{
|
||||
@@ -386,10 +383,10 @@ int Curl_cpool_check_limits(struct Curl_easy *data,
|
||||
if(!oldest_idle)
|
||||
break;
|
||||
/* disconnect the old conn and continue */
|
||||
CURL_TRC_M(data, "Discarding connection #%"
|
||||
FMT_OFF_T " from %zu to reach destination "
|
||||
"limit of %zu", oldest_idle->connection_id,
|
||||
Curl_llist_count(&bundle->conns), dest_limit);
|
||||
CURL_TRC_M(data, "Discarding connection #%" FMT_OFF_T
|
||||
" from %zu to reach destination limit of %zu",
|
||||
oldest_idle->connection_id,
|
||||
Curl_llist_count(&bundle->conns), dest_limit);
|
||||
Curl_conn_terminate(cpool->idata, oldest_idle, FALSE);
|
||||
|
||||
/* in case the bundle was destroyed in disconnect, look it up again */
|
||||
@@ -704,7 +701,6 @@ void Curl_conn_terminate(struct Curl_easy *data,
|
||||
CPOOL_UNLOCK(cpool, data);
|
||||
}
|
||||
|
||||
|
||||
struct cpool_reaper_ctx {
|
||||
struct curltime now;
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ void Curl_conn_terminate(struct Curl_easy *data,
|
||||
bool aborted);
|
||||
|
||||
struct cpool {
|
||||
/* the pooled connections, bundled per destination */
|
||||
/* the pooled connections, bundled per destination */
|
||||
struct Curl_hash dest2bundle;
|
||||
size_t num_conn;
|
||||
curl_off_t next_connection_id;
|
||||
@@ -166,5 +166,4 @@ void Curl_cpool_do_locked(struct Curl_easy *data,
|
||||
/* Close all unused connections, prevent reuse of existing ones. */
|
||||
void Curl_cpool_nw_changed(struct Curl_easy *data);
|
||||
|
||||
|
||||
#endif /* HEADER_CURL_CONNCACHE_H */
|
||||
|
||||
@@ -247,36 +247,35 @@ bool Curl_addr2string(struct sockaddr *sa, curl_socklen_t salen,
|
||||
#endif
|
||||
|
||||
switch(sa->sa_family) {
|
||||
case AF_INET:
|
||||
si = (struct sockaddr_in *)(void *) sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
|
||||
*port = ntohs(si->sin_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case AF_INET:
|
||||
si = (struct sockaddr_in *)(void *)sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si->sin_addr, addr, MAX_IPADR_LEN)) {
|
||||
*port = ntohs(si->sin_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
#ifdef USE_IPV6
|
||||
case AF_INET6:
|
||||
si6 = (struct sockaddr_in6 *)(void *) sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr,
|
||||
MAX_IPADR_LEN)) {
|
||||
*port = ntohs(si6->sin6_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case AF_INET6:
|
||||
si6 = (struct sockaddr_in6 *)(void *)sa;
|
||||
if(curlx_inet_ntop(sa->sa_family, &si6->sin6_addr, addr, MAX_IPADR_LEN)) {
|
||||
*port = ntohs(si6->sin6_port);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if (defined(HAVE_SYS_UN_H) || defined(WIN32_SOCKADDR_UN)) && defined(AF_UNIX)
|
||||
case AF_UNIX:
|
||||
if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
|
||||
su = (struct sockaddr_un*)sa;
|
||||
curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
|
||||
}
|
||||
else
|
||||
addr[0] = 0; /* socket with no name */
|
||||
*port = 0;
|
||||
return TRUE;
|
||||
case AF_UNIX:
|
||||
if(salen > (curl_socklen_t)sizeof(CURL_SA_FAMILY_T)) {
|
||||
su = (struct sockaddr_un *)sa;
|
||||
curl_msnprintf(addr, MAX_IPADR_LEN, "%s", su->sun_path);
|
||||
}
|
||||
else
|
||||
addr[0] = 0; /* socket with no name */
|
||||
*port = 0;
|
||||
return TRUE;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addr[0] = '\0';
|
||||
@@ -338,7 +337,7 @@ void Curl_conncontrol(struct connectdata *conn,
|
||||
#endif
|
||||
is_multiplex = Curl_conn_is_multiplex(conn, FIRSTSOCKET);
|
||||
closeit = (ctrl == CONNCTRL_CONNECTION) ||
|
||||
((ctrl == CONNCTRL_STREAM) && !is_multiplex);
|
||||
((ctrl == CONNCTRL_STREAM) && !is_multiplex);
|
||||
if((ctrl == CONNCTRL_STREAM) && is_multiplex)
|
||||
; /* stream signal on multiplex conn never affects close state */
|
||||
else if((bit)closeit != conn->bits.close) {
|
||||
@@ -409,8 +408,8 @@ connect_sub_chain:
|
||||
|
||||
if(ctx->state < CF_SETUP_CNNCT_HTTP_PROXY && cf->conn->bits.httpproxy) {
|
||||
#ifdef USE_SSL
|
||||
if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype)
|
||||
&& !Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
|
||||
if(IS_HTTPS_PROXY(cf->conn->http_proxy.proxytype) &&
|
||||
!Curl_conn_is_ssl(cf->conn, cf->sockindex)) {
|
||||
result = Curl_cf_ssl_proxy_insert_after(cf, data);
|
||||
if(result)
|
||||
return result;
|
||||
@@ -450,9 +449,9 @@ connect_sub_chain:
|
||||
|
||||
if(ctx->state < CF_SETUP_CNNCT_SSL) {
|
||||
#ifdef USE_SSL
|
||||
if((ctx->ssl_mode == CURL_CF_SSL_ENABLE
|
||||
|| (ctx->ssl_mode != CURL_CF_SSL_DISABLE
|
||||
&& cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */
|
||||
if((ctx->ssl_mode == CURL_CF_SSL_ENABLE ||
|
||||
(ctx->ssl_mode != CURL_CF_SSL_DISABLE &&
|
||||
cf->conn->handler->flags & PROTOPT_SSL)) /* we want SSL */
|
||||
&& !Curl_conn_is_ssl(cf->conn, cf->sockindex)) { /* it is missing */
|
||||
result = Curl_cf_ssl_insert_after(cf, data);
|
||||
if(result)
|
||||
@@ -494,7 +493,6 @@ static void cf_setup_destroy(struct Curl_cfilter *cf, struct Curl_easy *data)
|
||||
Curl_safefree(ctx);
|
||||
}
|
||||
|
||||
|
||||
struct Curl_cftype Curl_cft_setup = {
|
||||
"SETUP",
|
||||
0,
|
||||
|
||||
@@ -100,13 +100,13 @@ void Curl_conncontrol(struct connectdata *conn,
|
||||
);
|
||||
|
||||
#if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
|
||||
#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
|
||||
#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
|
||||
#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
|
||||
#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM, y)
|
||||
#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION, y)
|
||||
#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP, y)
|
||||
#else /* if !DEBUGBUILD || CURL_DISABLE_VERBOSE_STRINGS */
|
||||
#define streamclose(x,y) Curl_conncontrol(x, CONNCTRL_STREAM)
|
||||
#define connclose(x,y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
|
||||
#define connkeep(x,y) Curl_conncontrol(x, CONNCTRL_KEEP)
|
||||
#define streamclose(x, y) Curl_conncontrol(x, CONNCTRL_STREAM)
|
||||
#define connclose(x, y) Curl_conncontrol(x, CONNCTRL_CONNECTION)
|
||||
#define connkeep(x, y) Curl_conncontrol(x, CONNCTRL_KEEP)
|
||||
#endif
|
||||
|
||||
CURLcode Curl_cf_setup_insert_after(struct Curl_cfilter *cf_at,
|
||||
|
||||
61
lib/cookie.c
61
lib/cookie.c
@@ -45,7 +45,7 @@
|
||||
static void strstore(char **str, const char *newstr, size_t len);
|
||||
|
||||
/* number of seconds in 400 days */
|
||||
#define COOKIES_MAXAGE (400*24*3600)
|
||||
#define COOKIES_MAXAGE (400 * 24 * 3600)
|
||||
|
||||
/* Make sure cookies never expire further away in time than 400 days into the
|
||||
future. (from RFC6265bis draft-19)
|
||||
@@ -59,7 +59,7 @@ static void cap_expires(time_t now, struct Cookie *co)
|
||||
timediff_t cap = now + COOKIES_MAXAGE;
|
||||
if(co->expires > cap) {
|
||||
cap += 30;
|
||||
co->expires = (cap/60)*60;
|
||||
co->expires = (cap / 60) * 60;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ static bool cookie_tailmatch(const char *cookie_domain,
|
||||
return FALSE;
|
||||
|
||||
if(!curl_strnequal(cookie_domain,
|
||||
hostname + hostname_len-cookie_domain_len,
|
||||
hostname + hostname_len - cookie_domain_len,
|
||||
cookie_domain_len))
|
||||
return FALSE;
|
||||
|
||||
@@ -428,8 +428,8 @@ parse_cookie_header(struct Curl_easy *data,
|
||||
* combination of name + contents. Chrome and Firefox support 4095 or
|
||||
* 4096 bytes combo
|
||||
*/
|
||||
if(curlx_strlen(&name) >= (MAX_NAME-1) ||
|
||||
curlx_strlen(&val) >= (MAX_NAME-1) ||
|
||||
if(curlx_strlen(&name) >= (MAX_NAME - 1) ||
|
||||
curlx_strlen(&val) >= (MAX_NAME - 1) ||
|
||||
((curlx_strlen(&name) + curlx_strlen(&val)) > MAX_NAME)) {
|
||||
infof(data, "oversized cookie dropped, name/val %zu + %zu bytes",
|
||||
curlx_strlen(&name), curlx_strlen(&val));
|
||||
@@ -530,11 +530,11 @@ parse_cookie_header(struct Curl_easy *data,
|
||||
|
||||
is_ip = Curl_host_is_ipnum(domain ? domain : curlx_str(&val));
|
||||
|
||||
if(!domain
|
||||
|| (is_ip && !strncmp(curlx_str(&val), domain,
|
||||
curlx_strlen(&val)) &&
|
||||
(curlx_strlen(&val) == strlen(domain)))
|
||||
|| (!is_ip && cookie_tailmatch(curlx_str(&val),
|
||||
if(!domain ||
|
||||
(is_ip &&
|
||||
!strncmp(curlx_str(&val), domain, curlx_strlen(&val)) &&
|
||||
(curlx_strlen(&val) == strlen(domain))) ||
|
||||
(!is_ip && cookie_tailmatch(curlx_str(&val),
|
||||
curlx_strlen(&val), domain))) {
|
||||
strstore(&co->domain, curlx_str(&val), curlx_strlen(&val));
|
||||
if(!co->domain)
|
||||
@@ -689,7 +689,7 @@ parse_netscape(struct Cookie *co,
|
||||
co->httponly = TRUE;
|
||||
}
|
||||
|
||||
if(lineptr[0]=='#')
|
||||
if(lineptr[0] == '#')
|
||||
/* do not even try the comments */
|
||||
return CURLE_OK;
|
||||
|
||||
@@ -704,7 +704,7 @@ parse_netscape(struct Cookie *co,
|
||||
next = (ptr[len] == '\t' ? &ptr[len + 1] : NULL);
|
||||
switch(fields) {
|
||||
case 0:
|
||||
if(ptr[0]=='.') { /* skip preceding dots */
|
||||
if(ptr[0] == '.') { /* skip preceding dots */
|
||||
ptr++;
|
||||
len--;
|
||||
}
|
||||
@@ -792,10 +792,9 @@ parse_netscape(struct Cookie *co,
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_public_suffix(struct Curl_easy *data,
|
||||
struct Cookie *co,
|
||||
const char *domain)
|
||||
static bool is_public_suffix(struct Curl_easy *data,
|
||||
struct Cookie *co,
|
||||
const char *domain)
|
||||
{
|
||||
#ifdef USE_LIBPSL
|
||||
/*
|
||||
@@ -899,7 +898,7 @@ static bool replace_existing(struct Curl_easy *data,
|
||||
|
||||
if(clist->domain && co->domain) {
|
||||
if(curl_strequal(clist->domain, co->domain) &&
|
||||
(clist->tailmatch == co->tailmatch))
|
||||
(clist->tailmatch == co->tailmatch))
|
||||
/* The domains are identical */
|
||||
replace_old = TRUE;
|
||||
}
|
||||
@@ -1059,7 +1058,6 @@ fail:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Curl_cookie_init()
|
||||
*
|
||||
@@ -1195,7 +1193,6 @@ CURLcode Curl_cookie_loadfiles(struct Curl_easy *data)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* cookie_sort
|
||||
*
|
||||
@@ -1291,8 +1288,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data,
|
||||
/* at first, remove expired cookies */
|
||||
remove_expired(ci);
|
||||
|
||||
for(n = Curl_llist_head(&ci->cookielist[myhash]);
|
||||
n; n = Curl_node_next(n)) {
|
||||
for(n = Curl_llist_head(&ci->cookielist[myhash]); n; n = Curl_node_next(n)) {
|
||||
struct Cookie *co = Curl_node_elem(n);
|
||||
|
||||
/* if the cookie requires we are secure we must only continue if we are! */
|
||||
@@ -1302,7 +1298,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data,
|
||||
if(!co->domain ||
|
||||
(co->tailmatch && !is_ip &&
|
||||
cookie_tailmatch(co->domain, strlen(co->domain), host)) ||
|
||||
((!co->tailmatch || is_ip) && curl_strequal(host, co->domain)) ) {
|
||||
((!co->tailmatch || is_ip) && curl_strequal(host, co->domain))) {
|
||||
/*
|
||||
* the right part of the host matches the domain stuff in the
|
||||
* cookie data
|
||||
@@ -1312,7 +1308,7 @@ CURLcode Curl_cookie_getlist(struct Curl_easy *data,
|
||||
* now check the left part of the path with the cookies path
|
||||
* requirement
|
||||
*/
|
||||
if(!co->spath || pathmatch(co->spath, path) ) {
|
||||
if(!co->spath || pathmatch(co->spath, path)) {
|
||||
|
||||
/*
|
||||
* This is a match and we add it to the return-linked-list
|
||||
@@ -1445,14 +1441,14 @@ void Curl_cookie_cleanup(struct CookieInfo *ci)
|
||||
static char *get_netscape_format(const struct Cookie *co)
|
||||
{
|
||||
return curl_maprintf(
|
||||
"%s" /* httponly preamble */
|
||||
"%s%s\t" /* domain */
|
||||
"%s\t" /* tailmatch */
|
||||
"%s\t" /* path */
|
||||
"%s\t" /* secure */
|
||||
"%" FMT_OFF_T "\t" /* expires */
|
||||
"%s\t" /* name */
|
||||
"%s", /* value */
|
||||
"%s" /* httponly preamble */
|
||||
"%s%s\t" /* domain */
|
||||
"%s\t" /* tailmatch */
|
||||
"%s\t" /* path */
|
||||
"%s\t" /* secure */
|
||||
"%" FMT_OFF_T "\t" /* expires */
|
||||
"%s\t" /* name */
|
||||
"%s", /* value */
|
||||
co->httponly ? "#HttpOnly_" : "",
|
||||
/*
|
||||
* Make sure all domains are prefixed with a dot if they allow
|
||||
@@ -1522,8 +1518,7 @@ static CURLcode cookie_output(struct Curl_easy *data,
|
||||
|
||||
/* only sort the cookies with a domain property */
|
||||
for(i = 0; i < COOKIE_HASH_SIZE; i++) {
|
||||
for(n = Curl_llist_head(&ci->cookielist[i]); n;
|
||||
n = Curl_node_next(n)) {
|
||||
for(n = Curl_llist_head(&ci->cookielist[i]); n; n = Curl_node_next(n)) {
|
||||
struct Cookie *co = Curl_node_elem(n);
|
||||
if(!co->domain)
|
||||
continue;
|
||||
|
||||
40
lib/cookie.h
40
lib/cookie.h
@@ -30,29 +30,29 @@
|
||||
#include "llist.h"
|
||||
|
||||
struct Cookie {
|
||||
struct Curl_llist_node node; /* for the main cookie list */
|
||||
struct Curl_llist_node node; /* for the main cookie list */
|
||||
struct Curl_llist_node getnode; /* for getlist */
|
||||
char *name; /* <this> = value */
|
||||
char *value; /* name = <this> */
|
||||
char *path; /* path = <this> which is in Set-Cookie: */
|
||||
char *spath; /* sanitized cookie path */
|
||||
char *domain; /* domain = <this> */
|
||||
curl_off_t expires; /* expires = <this> */
|
||||
unsigned int creationtime; /* time when the cookie was written */
|
||||
BIT(tailmatch); /* tail-match the domain name */
|
||||
BIT(secure); /* the 'secure' keyword was used */
|
||||
BIT(livecookie); /* updated from a server, not a stored file */
|
||||
BIT(httponly); /* the httponly directive is present */
|
||||
BIT(prefix_secure); /* secure prefix is set */
|
||||
BIT(prefix_host); /* host prefix is set */
|
||||
char *name; /* <this> = value */
|
||||
char *value; /* name = <this> */
|
||||
char *path; /* path = <this> which is in Set-Cookie: */
|
||||
char *spath; /* sanitized cookie path */
|
||||
char *domain; /* domain = <this> */
|
||||
curl_off_t expires; /* expires = <this> */
|
||||
unsigned int creationtime; /* time when the cookie was written */
|
||||
BIT(tailmatch); /* tail-match the domain name */
|
||||
BIT(secure); /* the 'secure' keyword was used */
|
||||
BIT(livecookie); /* updated from server, not a stored file */
|
||||
BIT(httponly); /* the httponly directive is present */
|
||||
BIT(prefix_secure); /* secure prefix is set */
|
||||
BIT(prefix_host); /* host prefix is set */
|
||||
};
|
||||
|
||||
/*
|
||||
* Available cookie prefixes, as defined in
|
||||
* draft-ietf-httpbis-rfc6265bis-02
|
||||
*/
|
||||
#define COOKIE_PREFIX__SECURE (1<<0)
|
||||
#define COOKIE_PREFIX__HOST (1<<1)
|
||||
#define COOKIE_PREFIX__SECURE (1 << 0)
|
||||
#define COOKIE_PREFIX__HOST (1 << 1)
|
||||
|
||||
#define COOKIE_HASH_SIZE 63
|
||||
|
||||
@@ -60,9 +60,9 @@ struct CookieInfo {
|
||||
/* linked lists of cookies we know of */
|
||||
struct Curl_llist cookielist[COOKIE_HASH_SIZE];
|
||||
curl_off_t next_expiration; /* the next time at which expiration happens */
|
||||
unsigned int numcookies; /* number of cookies in the "jar" */
|
||||
unsigned int lastct; /* last creation-time used in the jar */
|
||||
BIT(running); /* state info, for cookie adding information */
|
||||
unsigned int numcookies; /* number of cookies in the "jar" */
|
||||
unsigned int lastct; /* last creation-time used in the jar */
|
||||
BIT(running); /* state info, for cookie adding information */
|
||||
BIT(newsession); /* new session, discard session cookies on load */
|
||||
};
|
||||
|
||||
@@ -130,7 +130,7 @@ void Curl_cookie_clearsess(struct CookieInfo *cookies);
|
||||
#define Curl_cookie_init() NULL
|
||||
#define Curl_cookie_run(x) Curl_nop_stmt
|
||||
#define Curl_cookie_cleanup(x) Curl_nop_stmt
|
||||
#define Curl_flush_cookies(x,y) Curl_nop_stmt
|
||||
#define Curl_flush_cookies(x, y) Curl_nop_stmt
|
||||
#else
|
||||
void Curl_flush_cookies(struct Curl_easy *data, bool cleanup);
|
||||
void Curl_cookie_cleanup(struct CookieInfo *c);
|
||||
|
||||
@@ -119,7 +119,6 @@ void Curl_cshutdn_run_once(struct Curl_easy *data,
|
||||
Curl_detach_connection(data);
|
||||
}
|
||||
|
||||
|
||||
void Curl_cshutdn_terminate(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
bool do_shutdown)
|
||||
@@ -227,7 +226,6 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void cshutdn_perform(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
@@ -270,7 +268,6 @@ static void cshutdn_perform(struct cshutdn *cshutdn,
|
||||
Curl_expire_ex(data, nowp, next_expire_ms, EXPIRE_SHUTDOWN);
|
||||
}
|
||||
|
||||
|
||||
static void cshutdn_terminate_all(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data,
|
||||
int timeout_ms)
|
||||
@@ -301,7 +298,7 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
|
||||
spent_ms = curlx_timediff_ms(curlx_now(), started);
|
||||
if(spent_ms >= (timediff_t)timeout_ms) {
|
||||
CURL_TRC_M(data, "[SHUTDOWN] shutdown finished, %s",
|
||||
(timeout_ms > 0) ? "timeout" : "best effort done");
|
||||
(timeout_ms > 0) ? "timeout" : "best effort done");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -325,7 +322,6 @@ static void cshutdn_terminate_all(struct cshutdn *cshutdn,
|
||||
sigpipe_restore(&pipe_st);
|
||||
}
|
||||
|
||||
|
||||
int Curl_cshutdn_init(struct cshutdn *cshutdn,
|
||||
struct Curl_multi *multi)
|
||||
{
|
||||
@@ -336,7 +332,6 @@ int Curl_cshutdn_init(struct cshutdn *cshutdn,
|
||||
return 0; /* good */
|
||||
}
|
||||
|
||||
|
||||
void Curl_cshutdn_destroy(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data)
|
||||
{
|
||||
@@ -388,7 +383,6 @@ size_t Curl_cshutdn_dest_count(struct Curl_easy *data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data,
|
||||
struct connectdata *conn)
|
||||
@@ -404,7 +398,6 @@ static CURLMcode cshutdn_update_ev(struct cshutdn *cshutdn,
|
||||
return mresult;
|
||||
}
|
||||
|
||||
|
||||
void Curl_cshutdn_add(struct cshutdn *cshutdn,
|
||||
struct connectdata *conn,
|
||||
size_t conns_in_pool)
|
||||
@@ -436,7 +429,6 @@ void Curl_cshutdn_add(struct cshutdn *cshutdn,
|
||||
conn->connection_id, Curl_llist_count(&cshutdn->list));
|
||||
}
|
||||
|
||||
|
||||
static void cshutdn_multi_socket(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data,
|
||||
curl_socket_t s)
|
||||
@@ -461,7 +453,6 @@ static void cshutdn_multi_socket(struct cshutdn *cshutdn,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Curl_cshutdn_perform(struct cshutdn *cshutdn,
|
||||
struct Curl_easy *data,
|
||||
curl_socket_t s)
|
||||
@@ -483,8 +474,7 @@ void Curl_cshutdn_setfds(struct cshutdn *cshutdn,
|
||||
struct easy_pollset ps;
|
||||
|
||||
Curl_pollset_init(&ps);
|
||||
for(e = Curl_llist_head(&cshutdn->list); e;
|
||||
e = Curl_node_next(e)) {
|
||||
for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
|
||||
unsigned int i;
|
||||
struct connectdata *conn = Curl_node_elem(e);
|
||||
CURLcode result;
|
||||
@@ -535,8 +525,7 @@ unsigned int Curl_cshutdn_add_waitfds(struct cshutdn *cshutdn,
|
||||
CURLcode result;
|
||||
|
||||
Curl_pollset_init(&ps);
|
||||
for(e = Curl_llist_head(&cshutdn->list); e;
|
||||
e = Curl_node_next(e)) {
|
||||
for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
|
||||
conn = Curl_node_elem(e);
|
||||
Curl_pollset_reset(&ps);
|
||||
Curl_attach_connection(data, conn);
|
||||
@@ -563,8 +552,7 @@ CURLcode Curl_cshutdn_add_pollfds(struct cshutdn *cshutdn,
|
||||
struct connectdata *conn;
|
||||
|
||||
Curl_pollset_init(&ps);
|
||||
for(e = Curl_llist_head(&cshutdn->list); e;
|
||||
e = Curl_node_next(e)) {
|
||||
for(e = Curl_llist_head(&cshutdn->list); e; e = Curl_node_next(e)) {
|
||||
conn = Curl_node_elem(e);
|
||||
Curl_pollset_reset(&ps);
|
||||
Curl_attach_connection(data, conn);
|
||||
|
||||
Reference in New Issue
Block a user