mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
c698b77d19
commit
5032e52680
16
http.c
16
http.c
@ -1739,11 +1739,11 @@ evhttp_read_header(struct evhttp_connection *evcon,
|
|||||||
struct evhttp_connection *
|
struct evhttp_connection *
|
||||||
evhttp_connection_new(const char *address, unsigned short port)
|
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 *
|
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)
|
const char *address, unsigned short port)
|
||||||
{
|
{
|
||||||
struct evhttp_connection *evcon = NULL;
|
struct evhttp_connection *evcon = NULL;
|
||||||
@ -1785,6 +1785,8 @@ evhttp_connection_base_new(struct event_base *base,
|
|||||||
bufferevent_base_set(base, evcon->bufev);
|
bufferevent_base_set(base, evcon->bufev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
evcon->dns_base = dnsbase;
|
||||||
|
|
||||||
return (evcon);
|
return (evcon);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -1793,14 +1795,6 @@ evhttp_connection_base_new(struct event_base *base,
|
|||||||
return (NULL);
|
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
|
void
|
||||||
evhttp_connection_set_base(struct evhttp_connection *evcon,
|
evhttp_connection_set_base(struct evhttp_connection *evcon,
|
||||||
struct event_base *base)
|
struct event_base *base)
|
||||||
@ -2925,7 +2919,7 @@ evhttp_get_request_connection(
|
|||||||
|
|
||||||
/* we need a connection object to put the http request on */
|
/* we need a connection object to put the http request on */
|
||||||
evcon = evhttp_connection_base_new(
|
evcon = evhttp_connection_base_new(
|
||||||
http->base, hostname, atoi(portname));
|
http->base, NULL, hostname, atoi(portname));
|
||||||
mm_free(hostname);
|
mm_free(hostname);
|
||||||
mm_free(portname);
|
mm_free(portname);
|
||||||
if (evcon == NULL)
|
if (evcon == NULL)
|
||||||
|
@ -353,21 +353,23 @@ void evhttp_request_set_chunked_cb(struct evhttp_request *,
|
|||||||
/** Frees the request object and removes associated events. */
|
/** Frees the request object and removes associated events. */
|
||||||
void evhttp_request_free(struct evhttp_request *req);
|
void evhttp_request_free(struct evhttp_request *req);
|
||||||
|
|
||||||
|
struct evdns_base;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A connection object that can be used to for making HTTP requests. The
|
* A connection object that can be used to for making HTTP requests. The
|
||||||
* connection object tries to resolve address and establish the connection
|
* connection object tries to resolve address and establish the connection
|
||||||
* when it is given an http request object.
|
* 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 evhttp_connection *evhttp_connection_base_new(
|
||||||
struct event_base *base, const char *address, unsigned short port);
|
struct event_base *base, struct evdns_base *dnsbase,
|
||||||
|
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);
|
|
||||||
|
|
||||||
/** Takes ownership of the request object
|
/** Takes ownership of the request object
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user