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

This commit is contained in:
Niels Provos 2010-01-14 15:42:07 -08:00
parent c698b77d19
commit 5032e52680
2 changed files with 16 additions and 20 deletions

16
http.c
View File

@ -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)

View File

@ -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
*