From: Niels Provos Date: Thu, 14 Jan 2010 23:42:07 +0000 (-0800) Subject: do not use a function to assign the evdns base; instead assign it via evhttp_connecti... X-Git-Tag: release-2.0.4-alpha~76^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5032e52680f751ce64b3bda4fa4439bebfd13bb0;p=libevent do not use a function to assign the evdns base; instead assign it via evhttp_connection_base_new() which is a new function introduced in 2.0 --- diff --git a/http.c b/http.c index 66cd0ad7..ec47d13c 100644 --- a/http.c +++ b/http.c @@ -1739,11 +1739,11 @@ evhttp_read_header(struct evhttp_connection *evcon, struct evhttp_connection * evhttp_connection_new(const char *address, unsigned short port) { - return (evhttp_connection_base_new(NULL, address, port)); + return (evhttp_connection_base_new(NULL, NULL, address, port)); } struct evhttp_connection * -evhttp_connection_base_new(struct event_base *base, +evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase, const char *address, unsigned short port) { struct evhttp_connection *evcon = NULL; @@ -1785,6 +1785,8 @@ evhttp_connection_base_new(struct event_base *base, bufferevent_base_set(base, evcon->bufev); } + evcon->dns_base = dnsbase; + return (evcon); error: @@ -1793,14 +1795,6 @@ evhttp_connection_base_new(struct event_base *base, return (NULL); } -void -evhttp_connection_set_evdns_base(struct evhttp_connection *evcon, - struct evdns_base *base) -{ - EVUTIL_ASSERT(evcon->dns_base == NULL); - evcon->dns_base = base; -} - void evhttp_connection_set_base(struct evhttp_connection *evcon, struct event_base *base) @@ -2925,7 +2919,7 @@ evhttp_get_request_connection( /* we need a connection object to put the http request on */ evcon = evhttp_connection_base_new( - http->base, hostname, atoi(portname)); + http->base, NULL, hostname, atoi(portname)); mm_free(hostname); mm_free(portname); if (evcon == NULL) diff --git a/include/event2/http.h b/include/event2/http.h index cdbafeb8..0edaf7e7 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -353,21 +353,23 @@ void evhttp_request_set_chunked_cb(struct evhttp_request *, /** Frees the request object and removes associated events. */ void evhttp_request_free(struct evhttp_request *req); +struct evdns_base; + /** * A connection object that can be used to for making HTTP requests. The * connection object tries to resolve address and establish the connection * when it is given an http request object. + * + * @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 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_new( - struct event_base *base, const char *address, unsigned short port); - -struct evdns_base; -/** - * Tell the connection object to use evdns_base when resolving hostnames. - * If no base is set, it will block when resolving hostnames. - */ -void evhttp_connection_set_evdns_base(struct evhttp_connection *evcon, - struct evdns_base *base); + struct event_base *base, struct evdns_base *dnsbase, + const char *address, unsigned short port); /** Takes ownership of the request object *