summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-06-11 00:27:06 +0200
committerMikael Magnusson <mikma@users.sourceforge.net>2021-06-11 00:27:06 +0200
commit8f94fe5e547bb56d9f90b247eff1cf2c77d14a14 (patch)
tree9526812fabcaad0554fddc960e0a8725da272aa4
parente20f5cc3a49035f7b422f62fdbaad12dc123094a (diff)
WIP: caresbuild
-rw-r--r--src/sock.c11
-rw-r--r--src/sock.h2
2 files changed, 8 insertions, 5 deletions
diff --git a/src/sock.c b/src/sock.c
index cefafd9..eefd75c 100644
--- a/src/sock.c
+++ b/src/sock.c
@@ -162,9 +162,11 @@ bind_socket_list (int sockfd, sblist *addresses, int family)
int opensock (const char *host, int port, const char *bind_to, const char *bind_to_alt)
{
int sockfd, n;
- struct ares_addrinfo hints, *res, *ressave;
+ struct ares_addrinfo *ressave;
+ struct ares_addrinfo_node *res;
+ struct ares_addrinfo_hints hints;
char portstr[6];
- ares_channel *resolver = NULL;
+ ares_channel resolver = NULL;
assert (host != NULL);
assert (port > 0);
@@ -190,7 +192,7 @@ int opensock (const char *host, int port, const char *bind_to, const char *bind_
snprintf (portstr, sizeof (portstr), "%d", port);
- n = ares_getaddrinfo (host, portstr, &hints, &res);
+ n = ares_getaddrinfo (resolver, host, portstr, &hints, &ressave);
if (n != 0) {
log_message (LOG_ERR,
"opensock: Could not retrieve address info for %s:%d: %s", host, port, get_gai_error (n));
@@ -200,7 +202,8 @@ int opensock (const char *host, int port, const char *bind_to, const char *bind_
log_message(LOG_INFO,
"opensock: getaddrinfo returned for %s:%d", host, port);
- ressave = res;
+ res = ressave->nodes;
+
do {
sockfd =
socket (res->ai_family, res->ai_socktype, res->ai_protocol);
diff --git a/src/sock.h b/src/sock.h
index b85142c..0755e15 100644
--- a/src/sock.h
+++ b/src/sock.h
@@ -51,7 +51,7 @@ union sockaddr_union {
};
extern int init_sock(void);
-extern void destroy_dock(void);
+extern void cleanup_dock(void);
extern int opensock (const char *host, int port, const char *bind_to, const char *bind_to_alt);
extern int listen_sock (const char *addr, uint16_t port, sblist* listen_fds);