diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/or/dnsserv.c | 2 | ||||
-rw-r--r-- | src/or/main.c | 19 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c index ee3cd473cf..659d264a7b 100644 --- a/src/or/dnsserv.c +++ b/src/or/dnsserv.c @@ -122,6 +122,8 @@ evdns_server_callback(struct evdns_server_request *req, void *_data) conn->dns_server_request = req; + connection_add(TO_CONN(conn)); + /* Now, throw the connection over to get rewritten (which will answer it * immediately if it's in the cache, or completely bogus, or automapped), * and then attached to a circuit. */ diff --git a/src/or/main.c b/src/or/main.c index 73a0401178..5c7fcb5476 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -162,18 +162,23 @@ int connection_add(connection_t *conn) { tor_assert(conn); - tor_assert(conn->s >= 0 || conn->linked); + tor_assert(conn->s >= 0 || + conn->linked || + (conn->type == CONN_TYPE_AP && + TO_EDGE_CONN(conn)->dns_server_request)); tor_assert(conn->conn_array_index == -1); /* can only connection_add once */ conn->conn_array_index = smartlist_len(connection_array); smartlist_add(connection_array, conn); - conn->read_event = tor_malloc_zero(sizeof(struct event)); - conn->write_event = tor_malloc_zero(sizeof(struct event)); - event_set(conn->read_event, conn->s, EV_READ|EV_PERSIST, - conn_read_callback, conn); - event_set(conn->write_event, conn->s, EV_WRITE|EV_PERSIST, - conn_write_callback, conn); + if (conn->s >= 0) { + conn->read_event = tor_malloc_zero(sizeof(struct event)); + conn->write_event = tor_malloc_zero(sizeof(struct event)); + event_set(conn->read_event, conn->s, EV_READ|EV_PERSIST, + conn_read_callback, conn); + event_set(conn->write_event, conn->s, EV_WRITE|EV_PERSIST, + conn_write_callback, conn); + } log_debug(LD_NET,"new conn type %s, socket %d, n_conns %d.", conn_type_to_string(conn->type), conn->s, |