]> granicus.if.org Git - libevent/commitdiff
do not use a function to assign the evdns base; instead assign it via evhttp_connecti...
authorNiels Provos <provos@gmail.com>
Thu, 14 Jan 2010 23:42:07 +0000 (15:42 -0800)
committerNiels Provos <provos@gmail.com>
Thu, 14 Jan 2010 23:42:07 +0000 (15:42 -0800)
http.c
include/event2/http.h

diff --git a/http.c b/http.c
index 66cd0ad73d01e77683f15c2d58e91271fc27b891..ec47d13c1d8dd1b0a907a34e6bd8adccad950a7b 100644 (file)
--- 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)
index cdbafeb864a49db2e4f2b686d74d7f7a410bd973..0edaf7e7dfd2c1269c5db03f5068a038769a4c4e 100644 (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
  *