diff options
author | aozeritsky <aozeritsky@yandex-team.ru> | 2022-02-10 16:46:39 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:39 +0300 |
commit | 4a6816dea1bcaee46ce29a51a5fd7d3495012858 (patch) | |
tree | d98d6003e190b9e761bd77a83cd98428f9657b35 /contrib/libs/libevent | |
parent | 7aa4cf700385ff96999c5cc301171ff157974773 (diff) | |
download | ydb-4a6816dea1bcaee46ce29a51a5fd7d3495012858.tar.gz |
Restoring authorship annotation for <aozeritsky@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/libevent')
-rw-r--r-- | contrib/libs/libevent/evutil.c | 8 | ||||
-rw-r--r-- | contrib/libs/libevent/http-internal.h | 12 | ||||
-rw-r--r-- | contrib/libs/libevent/http.c | 226 | ||||
-rw-r--r-- | contrib/libs/libevent/include/event2/http.h | 78 | ||||
-rw-r--r-- | contrib/libs/libevent/include/event2/http_struct.h | 6 |
5 files changed, 165 insertions, 165 deletions
diff --git a/contrib/libs/libevent/evutil.c b/contrib/libs/libevent/evutil.c index 9976e79beb..159dd08609 100644 --- a/contrib/libs/libevent/evutil.c +++ b/contrib/libs/libevent/evutil.c @@ -1250,11 +1250,11 @@ evutil_adjust_hints_for_addrconfig_(struct evutil_addrinfo *hints) #ifdef USE_NATIVE_GETADDRINFO static int need_numeric_port_hack_=0; static int need_socktype_protocol_hack_=0; -#ifdef WIN32 -static int tested_for_getaddrinfo_hacks=1; -#else +#ifdef WIN32 +static int tested_for_getaddrinfo_hacks=1; +#else static int tested_for_getaddrinfo_hacks=0; -#endif +#endif /* Some older BSDs (like OpenBSD up to 4.6) used to believe that giving a numeric port without giving an ai_socktype was verboten. We test for this so we can apply an appropriate workaround. If it diff --git a/contrib/libs/libevent/http-internal.h b/contrib/libs/libevent/http-internal.h index 85760eafc2..95d70525ec 100644 --- a/contrib/libs/libevent/http-internal.h +++ b/contrib/libs/libevent/http-internal.h @@ -13,7 +13,7 @@ #include "event2/event_struct.h" #include "util-internal.h" #include "defer-internal.h" -#include "event2/http.h" +#include "event2/http.h" #define HTTP_CONNECT_TIMEOUT 45 #define HTTP_WRITE_TIMEOUT 50 @@ -56,8 +56,8 @@ struct evhttp_connection { evutil_socket_t fd; struct bufferevent *bufev; - bev_factory_cb bufcb; - void *bufcb_arg; + bev_factory_cb bufcb; + void *bufcb_arg; struct event retry_ev; /* for retrying connects */ @@ -112,7 +112,7 @@ struct evhttp_cb { TAILQ_ENTRY(evhttp_cb) next; char *what; - int chunked; + int chunked; void (*cb)(struct evhttp_request *req, void *); void *cbarg; @@ -169,8 +169,8 @@ struct evhttp { don't match. */ void (*gencb)(struct evhttp_request *req, void *); void *gencbarg; - struct bufferevent* (*bevcb)(struct event_base *, void *); - void *bevcbarg; + struct bufferevent* (*bevcb)(struct event_base *, void *); + void *bevcbarg; struct event_base *base; }; diff --git a/contrib/libs/libevent/http.c b/contrib/libs/libevent/http.c index b750d491c9..e3ce49f0ba 100644 --- a/contrib/libs/libevent/http.c +++ b/contrib/libs/libevent/http.c @@ -200,9 +200,9 @@ static void evhttp_write_buffer(struct evhttp_connection *, void (*)(struct evhttp_connection *, void *), void *); static void evhttp_make_header(struct evhttp_connection *, struct evhttp_request *); -static struct evhttp_cb * -evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req, int chunked); - +static struct evhttp_cb * +evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req, int chunked); + /* callbacks for bufferevent */ static void evhttp_read_cb(struct bufferevent *, void *); static void evhttp_write_cb(struct bufferevent *, void *); @@ -983,7 +983,7 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf) req->ntoread = -1; if (req->chunk_cb != NULL) { req->flags |= EVHTTP_REQ_DEFER_FREE; - (*req->chunk_cb)(req, req->chunk_cb_arg); + (*req->chunk_cb)(req, req->chunk_cb_arg); evbuffer_drain(req->input_buffer, evbuffer_get_length(req->input_buffer)); req->flags &= ~EVHTTP_REQ_DEFER_FREE; @@ -993,12 +993,12 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf) } } - if (req->chunk_cb != NULL) { - req->flags |= EVHTTP_REQ_PROCESS_CHUNKS_END; - (*req->chunk_cb)(req, req->chunk_cb_arg); - req->flags &= ~EVHTTP_REQ_PROCESS_CHUNKS_END; - } - + if (req->chunk_cb != NULL) { + req->flags |= EVHTTP_REQ_PROCESS_CHUNKS_END; + (*req->chunk_cb)(req, req->chunk_cb_arg); + req->flags &= ~EVHTTP_REQ_PROCESS_CHUNKS_END; + } + return (MORE_DATA_EXPECTED); } @@ -1112,7 +1112,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req) if (evbuffer_get_length(req->input_buffer) > 0 && req->chunk_cb != NULL) { req->flags |= EVHTTP_REQ_DEFER_FREE; - (*req->chunk_cb)(req, req->chunk_cb_arg); + (*req->chunk_cb)(req, req->chunk_cb_arg); req->flags &= ~EVHTTP_REQ_DEFER_FREE; evbuffer_drain(req->input_buffer, evbuffer_get_length(req->input_buffer)); @@ -1364,23 +1364,23 @@ evhttp_connection_reset_(struct evhttp_connection *evcon) if (evhttp_connected(evcon) && evcon->closecb != NULL) (*evcon->closecb)(evcon, evcon->closecb_arg); - /* if we have a bufferevent factory callback set, get a new bufferevent */ - if (NULL != evcon->bufcb && -1 != bufferevent_getfd(evcon->bufev)) { - struct bufferevent *bev = (*evcon->bufcb)(evcon->bufcb_arg); - - if (NULL == bev) { - event_warn("%s: bufferevent factory callback failed", __func__); - } - else { - if (bufferevent_get_base(bev) != evcon->base) { - bufferevent_base_set(evcon->base, bev); - } - - bufferevent_free(evcon->bufev); - evcon->bufev = bev; - } - } - + /* if we have a bufferevent factory callback set, get a new bufferevent */ + if (NULL != evcon->bufcb && -1 != bufferevent_getfd(evcon->bufev)) { + struct bufferevent *bev = (*evcon->bufcb)(evcon->bufcb_arg); + + if (NULL == bev) { + event_warn("%s: bufferevent factory callback failed", __func__); + } + else { + if (bufferevent_get_base(bev) != evcon->base) { + bufferevent_base_set(evcon->base, bev); + } + + bufferevent_free(evcon->bufev); + evcon->bufev = bev; + } + } + shutdown(evcon->fd, EVUTIL_SHUT_WR); evutil_closesocket(evcon->fd); evcon->fd = -1; @@ -1585,7 +1585,7 @@ evhttp_error_cb(struct bufferevent *bufev, short what, void *arg) } evhttp_connection_fail_(evcon, EVREQ_HTTP_EOF); - } else if (what == BEV_EVENT_CONNECTED) { + } else if (what == BEV_EVENT_CONNECTED) { } else { evhttp_connection_fail_(evcon, EVREQ_HTTP_BUFFER_ERROR); } @@ -1918,13 +1918,13 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len) !evhttp_find_vhost(req->evcon->http_server, NULL, hostname)) req->flags |= EVHTTP_PROXY_REQUEST; - { - struct evhttp_cb * chunkcb = evhttp_dispatch_callback(&req->evcon->http_server->callbacks, req, 1); - if (chunkcb) { - req->chunk_cb = chunkcb->cb; - req->chunk_cb_arg = chunkcb->cbarg; - } - } + { + struct evhttp_cb * chunkcb = evhttp_dispatch_callback(&req->evcon->http_server->callbacks, req, 1); + if (chunkcb) { + req->chunk_cb = chunkcb->cb; + req->chunk_cb_arg = chunkcb->cbarg; + } + } return 0; } @@ -2403,30 +2403,30 @@ evhttp_read_header(struct evhttp_connection *evcon, * happen elsewhere. */ -struct evhttp_connection *evhttp_connection_base_bufferevent_factory_new( - struct event_base *base, struct evdns_base *dnsbase, - bev_factory_cb cb, void * arg, const char *address, unsigned short port) -{ - struct bufferevent *bev = NULL; - - if (NULL != cb) { - if (NULL == (bev = (*cb)(arg))) { - event_warn("%s: bufferevent factory callback failed", __func__); - return (NULL); - } - } - - struct evhttp_connection *ret = - evhttp_connection_base_bufferevent_new(base, dnsbase, bev, address, port); - - if (NULL != ret) { - ret->bufcb = cb; - ret->bufcb_arg = arg; - } - - return (ret); -} - +struct evhttp_connection *evhttp_connection_base_bufferevent_factory_new( + struct event_base *base, struct evdns_base *dnsbase, + bev_factory_cb cb, void * arg, const char *address, unsigned short port) +{ + struct bufferevent *bev = NULL; + + if (NULL != cb) { + if (NULL == (bev = (*cb)(arg))) { + event_warn("%s: bufferevent factory callback failed", __func__); + return (NULL); + } + } + + struct evhttp_connection *ret = + evhttp_connection_base_bufferevent_new(base, dnsbase, bev, address, port); + + if (NULL != ret) { + ret->bufcb = cb; + ret->bufcb_arg = arg; + } + + return (ret); +} + struct evhttp_connection * evhttp_connection_new(const char *address, ev_uint16_t port) { @@ -2434,7 +2434,7 @@ evhttp_connection_new(const char *address, ev_uint16_t port) } struct evhttp_connection * -evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, +evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port) { struct evhttp_connection *evcon = NULL; @@ -2460,11 +2460,11 @@ evhttp_connection_base_bufferevent_new(struct event_base *base, struct evdns_bas goto error; } - if (bev == NULL) { + if (bev == NULL) { if (!(bev = bufferevent_socket_new(base, -1, 0))) { event_warn("%s: bufferevent_socket_new failed", __func__); - goto error; - } + goto error; + } } bufferevent_setcb(bev, evhttp_read_cb, evhttp_write_cb, evhttp_error_cb, evcon); @@ -2505,17 +2505,17 @@ struct bufferevent* evhttp_connection_get_bufferevent(struct evhttp_connection * struct evhttp * evhttp_connection_get_server(struct evhttp_connection *evcon) -{ +{ return evcon->http_server; } - -struct evhttp_connection * -evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, + +struct evhttp_connection * +evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, const char *address, ev_uint16_t port) -{ - return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port); -} - +{ + return evhttp_connection_base_bufferevent_new(base, dnsbase, NULL, address, port); +} + void evhttp_connection_set_family(struct evhttp_connection *evcon, int family) { @@ -3390,7 +3390,7 @@ evhttp_parse_query_str(const char *uri, struct evkeyvalq *headers) } static struct evhttp_cb * -evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req, int chunked) +evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req, int chunked) { struct evhttp_cb *cb; size_t offset = 0; @@ -3407,13 +3407,13 @@ evhttp_dispatch_callback(struct httpcbq *callbacks, struct evhttp_request *req, TAILQ_FOREACH(cb, callbacks, next) { if (!strcmp(cb->what, translated)) { - if (chunked < 0) { - mm_free(translated); - return (cb); - } else if (chunked == cb->chunked) { - mm_free(translated); - return (cb); - } + if (chunked < 0) { + mm_free(translated); + return (cb); + } else if (chunked == cb->chunked) { + mm_free(translated); + return (cb); + } } } @@ -3554,7 +3554,7 @@ evhttp_handle_request(struct evhttp_request *req, void *arg) evhttp_find_vhost(http, &http, hostname); } - if ((cb = evhttp_dispatch_callback(&http->callbacks, req, -1)) != NULL) { + if ((cb = evhttp_dispatch_callback(&http->callbacks, req, -1)) != NULL) { (*cb->cb)(req, cb->cbarg); return; } @@ -3974,8 +3974,8 @@ evhttp_set_allowed_methods(struct evhttp* http, ev_uint16_t methods) } int -evhttp_set_cb_internal(struct evhttp *http, const char *uri, - void (*cb)(struct evhttp_request *, void *), void *cbarg, int chunked) +evhttp_set_cb_internal(struct evhttp *http, const char *uri, + void (*cb)(struct evhttp_request *, void *), void *cbarg, int chunked) { struct evhttp_cb *http_cb; @@ -3997,7 +3997,7 @@ evhttp_set_cb_internal(struct evhttp *http, const char *uri, } http_cb->cb = cb; http_cb->cbarg = cbarg; - http_cb->chunked = chunked; + http_cb->chunked = chunked; TAILQ_INSERT_TAIL(&http->callbacks, http_cb, next); @@ -4005,19 +4005,19 @@ evhttp_set_cb_internal(struct evhttp *http, const char *uri, } int -evhttp_set_cb(struct evhttp *http, const char *uri, - void (*cb)(struct evhttp_request *, void *), void *cbarg) -{ - return evhttp_set_cb_internal(http, uri, cb, cbarg, 0); -} - -int evhttp_set_chunk_cb(struct evhttp *http, const char *path, - void (*chunk_cb)(struct evhttp_request *, void *), void *cb_arg) -{ - return evhttp_set_cb_internal(http, path, chunk_cb, cb_arg, 1); -} - -int +evhttp_set_cb(struct evhttp *http, const char *uri, + void (*cb)(struct evhttp_request *, void *), void *cbarg) +{ + return evhttp_set_cb_internal(http, uri, cb, cbarg, 0); +} + +int evhttp_set_chunk_cb(struct evhttp *http, const char *path, + void (*chunk_cb)(struct evhttp_request *, void *), void *cb_arg) +{ + return evhttp_set_cb_internal(http, path, chunk_cb, cb_arg, 1); +} + +int evhttp_del_cb(struct evhttp *http, const char *uri) { struct evhttp_cb *http_cb; @@ -4044,14 +4044,14 @@ evhttp_set_gencb(struct evhttp *http, http->gencbarg = cbarg; } -void -evhttp_set_bevcb(struct evhttp *http, - struct bufferevent* (*cb)(struct event_base *, void *), void *cbarg) -{ - http->bevcb = cb; - http->bevcbarg = cbarg; -} - +void +evhttp_set_bevcb(struct evhttp *http, + struct bufferevent* (*cb)(struct event_base *, void *), void *cbarg) +{ + http->bevcb = cb; + http->bevcbarg = cbarg; +} + /* * Request related functions */ @@ -4166,10 +4166,10 @@ evhttp_connection_get_base(struct evhttp_connection *conn) void evhttp_request_set_chunked_cb(struct evhttp_request *req, - void (*cb)(struct evhttp_request *, void *), void *arg) + void (*cb)(struct evhttp_request *, void *), void *arg) { req->chunk_cb = cb; - req->chunk_cb_arg = arg; + req->chunk_cb_arg = arg; } void @@ -4305,7 +4305,7 @@ evhttp_get_request_connection( { struct evhttp_connection *evcon; char *hostname = NULL, *portname = NULL; - struct bufferevent* bev = NULL; + struct bufferevent* bev = NULL; #ifdef EVENT__HAVE_STRUCT_SOCKADDR_UN if (sa->sa_family == AF_UNIX) { @@ -4325,11 +4325,11 @@ evhttp_get_request_connection( __func__, hostname, portname, EV_SOCK_ARG(fd))); /* we need a connection object to put the http request on */ - if (http->bevcb != NULL) { - bev = (*http->bevcb)(http->base, http->bevcbarg); - } - evcon = evhttp_connection_base_bufferevent_new( - http->base, NULL, bev, hostname, atoi(portname)); + if (http->bevcb != NULL) { + bev = (*http->bevcb)(http->base, http->bevcbarg); + } + evcon = evhttp_connection_base_bufferevent_new( + http->base, NULL, bev, hostname, atoi(portname)); mm_free(hostname); mm_free(portname); if (evcon == NULL) diff --git a/contrib/libs/libevent/include/event2/http.h b/contrib/libs/libevent/include/event2/http.h index 40d411ddd2..c98cd98f62 100644 --- a/contrib/libs/libevent/include/event2/http.h +++ b/contrib/libs/libevent/include/event2/http.h @@ -38,7 +38,7 @@ extern "C" { /* In case we haven't included the right headers yet. */ struct evbuffer; struct event_base; -struct bufferevent; +struct bufferevent; struct evhttp_connection; /** @file event2/http.h @@ -72,7 +72,7 @@ struct evhttp_request; struct evkeyvalq; struct evhttp_bound_socket; struct evconnlistener; -struct evdns_base; +struct evdns_base; /** * Create a new HTTP server. @@ -265,9 +265,9 @@ int evhttp_set_cb(struct evhttp *http, const char *path, void (*cb)(struct evhttp_request *, void *), void *cb_arg); EVENT2_EXPORT_SYMBOL -int evhttp_set_chunk_cb(struct evhttp *http, const char *path, - void (*chunk_cb)(struct evhttp_request *, void *), void *cb_arg); - +int evhttp_set_chunk_cb(struct evhttp *http, const char *path, + void (*chunk_cb)(struct evhttp_request *, void *), void *cb_arg); + /** Removes the callback for a specified URI */ EVENT2_EXPORT_SYMBOL int evhttp_del_cb(struct evhttp *, const char *); @@ -302,9 +302,9 @@ void evhttp_set_gencb(struct evhttp *http, @param arg an context argument for the callback */ EVENT2_EXPORT_SYMBOL -void evhttp_set_bevcb(struct evhttp *http, +void evhttp_set_bevcb(struct evhttp *http, struct bufferevent *(*cb)(struct event_base *, void *), void *arg); - + /** Adds a virtual host to the http server. @@ -537,38 +537,38 @@ struct evhttp_connection *evhttp_connection_base_bufferevent_new( struct event_base *base, struct evdns_base *dnsbase, struct bufferevent* bev, const char *address, ev_uint16_t port); /** - * Creates and returns a new bufferevent object. - */ -typedef struct bufferevent* (*bev_factory_cb)(void *); - -/** - * Create and return a connection object that can be used for making HTTP - * requests. The connection object tries to resolve address and establish the - * connection when it is given an http request object. The specified factory - * function is called with the user-supplied argument to retrieve a new - * bufferevent whenever the underlying HTTP connection needs to be - * reestablished. This is what you want if, for example, you have a bufferevent - * that needs to perform some setup for new connections, such as an SSL - * bufferevent. - * - * @param base the event_base to use for handling the connection - * @param dnsbase the dns_base to use for resolving host names; if not - * specified host name resolution will block. - * @param cb a callback that returns a new bufferevent to use for connecting to - * the server; if NULL, behavior is the same as in calling - * evhttp_connection_base_bufferevent_new with a NULL bufferevent. The - * returned bufferevents will be freed as necessary. The returned - * bufferevents must have no fd set on them. - * @param arg the argument to supply to the callback - * @param address the address to which to connect - * @param port the port to connect to - * @return an evhttp_connection object that can be used for making requests - */ -struct evhttp_connection *evhttp_connection_base_bufferevent_factory_new( - struct event_base *base, struct evdns_base *dnsbase, - bev_factory_cb cb, void * arg, const char *address, unsigned short port); - -/** + * Creates and returns a new bufferevent object. + */ +typedef struct bufferevent* (*bev_factory_cb)(void *); + +/** + * Create and return a connection object that can be used for making HTTP + * requests. The connection object tries to resolve address and establish the + * connection when it is given an http request object. The specified factory + * function is called with the user-supplied argument to retrieve a new + * bufferevent whenever the underlying HTTP connection needs to be + * reestablished. This is what you want if, for example, you have a bufferevent + * that needs to perform some setup for new connections, such as an SSL + * bufferevent. + * + * @param base the event_base to use for handling the connection + * @param dnsbase the dns_base to use for resolving host names; if not + * specified host name resolution will block. + * @param cb a callback that returns a new bufferevent to use for connecting to + * the server; if NULL, behavior is the same as in calling + * evhttp_connection_base_bufferevent_new with a NULL bufferevent. The + * returned bufferevents will be freed as necessary. The returned + * bufferevents must have no fd set on them. + * @param arg the argument to supply to the callback + * @param address the address to which to connect + * @param port the port to connect to + * @return an evhttp_connection object that can be used for making requests + */ +struct evhttp_connection *evhttp_connection_base_bufferevent_factory_new( + struct event_base *base, struct evdns_base *dnsbase, + bev_factory_cb cb, void * arg, const char *address, unsigned short port); + +/** * Return the bufferevent that an evhttp_connection is using. */ EVENT2_EXPORT_SYMBOL diff --git a/contrib/libs/libevent/include/event2/http_struct.h b/contrib/libs/libevent/include/event2/http_struct.h index 2691c8c037..ff2538354b 100644 --- a/contrib/libs/libevent/include/event2/http_struct.h +++ b/contrib/libs/libevent/include/event2/http_struct.h @@ -78,8 +78,8 @@ struct { /** The request should be freed upstack */ #define EVHTTP_REQ_NEEDS_FREE 0x0010 -#define EVHTTP_REQ_PROCESS_CHUNKS_END 0x0024 - +#define EVHTTP_REQ_PROCESS_CHUNKS_END 0x0024 + struct evkeyvalq *input_headers; struct evkeyvalq *output_headers; @@ -122,7 +122,7 @@ struct { * the regular callback. */ void (*chunk_cb)(struct evhttp_request *, void *); - void *chunk_cb_arg; + void *chunk_cb_arg; /* * Callback added for forked-daapd so they can collect ICY |