Refine query interface

This commit is contained in:
Max Lv
2017-12-27 22:18:55 -08:00
parent 10ce3ed5d3
commit be795e1985
5 changed files with 6 additions and 19 deletions
+1 -3
View File
@@ -188,7 +188,7 @@ resolv_shutdown(struct ev_loop *loop)
ares_library_cleanup();
}
struct resolv_query *
void
resolv_start(const char *hostname, uint16_t port,
void (*client_cb)(struct sockaddr *, void *),
void (*free_cb)(void *), void *data)
@@ -214,8 +214,6 @@ resolv_start(const char *hostname, uint16_t port,
ares_gethostbyname(default_ctx.channel, hostname, AF_INET6, dns_query_v6_cb, query);
reset_timer();
return query;
}
/*
+3 -3
View File
@@ -36,9 +36,9 @@
struct resolv_query;
int resolv_init(struct ev_loop *, char *, int);
struct resolv_query *resolv_start(const char *hostname, uint16_t port,
void (*client_cb)(struct sockaddr *, void *),
void (*free_cb)(void *), void *data);
void resolv_start(const char *hostname, uint16_t port,
void (*client_cb)(struct sockaddr *, void *),
void (*free_cb)(void *), void *data);
void resolv_shutdown(struct ev_loop *);
#endif
+1 -2
View File
@@ -912,8 +912,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
snprintf(query->hostname, 256, "%s", host);
server->stage = STAGE_RESOLVE;
struct resolv_query *q = resolv_start(host, port,
resolv_cb, resolv_free_cb, query);
resolv_start(host, port, resolv_cb, resolv_free_cb, query);
}
return;
+1 -10
View File
@@ -1293,16 +1293,7 @@ server_recv_cb(EV_P_ ev_io *w, int revents)
query_ctx->remote_ctx = remote_ctx;
}
struct resolv_query *query = resolv_start(host, htons(atoi(port)),
resolv_cb, resolv_free_cb, query_ctx);
if (query == NULL) {
ERROR("[udp] unable to create DNS query");
close_and_free_query(EV_A_ query_ctx);
goto CLEAN_UP;
}
query_ctx->query = query;
resolv_start(host, htons(atoi(port)), resolv_cb, resolv_free_cb, query_ctx);
}
#endif
-1
View File
@@ -67,7 +67,6 @@ typedef struct server_ctx {
#ifdef MODULE_REMOTE
typedef struct query_ctx {
struct resolv_query *query;
struct sockaddr_storage src_addr;
buffer_t *buf;
int addr_header_len;