[28803] in Source-Commits

home help back first fref pref prev next nref lref last post

larvnetd commit: build against modern ares library

daemon@ATHENA.MIT.EDU (Lizhou Sha)
Sat Nov 11 18:06:41 2017

Date: Sat, 11 Nov 2017 18:06:34 -0500
From: Lizhou Sha <slz@mit.edu>
Message-Id: <201711112306.vABN6Y0S008789@drugstore.mit.edu>
To: source-commits@mit.edu

https://github.com/mit-athena/larvnetd/commit/75bb9db50f26bc4dfe51f8f9935daebded59fe69
commit 75bb9db50f26bc4dfe51f8f9935daebded59fe69
Author: Jonathon Weiss <jweiss@mit.edu>
Date:   Wed Mar 8 17:37:47 2017 -0500

    build against modern ares library

 Makefile.in |    2 +-
 config.c    |    4 +---
 larvnetd.c  |    4 +---
 printer.c   |   23 +++++++++++------------
 ws.c        |   11 ++++++-----
 5 files changed, 20 insertions(+), 24 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index c47b79e..02d4a99 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -18,7 +18,7 @@ DEFS=@DEFS@
 CPPFLAGS=@CPPFLAGS@
 CFLAGS=@CFLAGS@ ${WARN_CFLAGS}
 LDFLAGS=@LDFLAGS@
-LIBS=@HESIOD_LIBS@ @LIBS@ -lares
+LIBS=@HESIOD_LIBS@ @LIBS@ -lcares
 ALL_CFLAGS=${CPPFLAGS} ${CFLAGS} ${DEFS}
 
 OBJS=config.o larvnetd.o printer.o report.o timer.o util.o ws.o
diff --git a/config.c b/config.c
index be78cea..c857d43 100644
--- a/config.c
+++ b/config.c
@@ -59,7 +59,6 @@ void reread_config(struct serverstate *state)
   struct machine *machine;
   struct printer *printer;
   int i, j, status;
-  char *errmem;
 
   syslog(LOG_DEBUG, "reread_config");
 
@@ -110,8 +109,7 @@ void reread_config(struct serverstate *state)
   if (status != ARES_SUCCESS)
     {
       syslog(LOG_ALERT, "reread_config: can't reinitialize resolver channel, "
-	     "aborting: %s", ares_strerror(status, &errmem));
-      ares_free_errmem(errmem);
+	     "aborting: %s", ares_strerror(status));
       exit(1);
     }
 
diff --git a/larvnetd.c b/larvnetd.c
index 6080d41..7f891e9 100644
--- a/larvnetd.c
+++ b/larvnetd.c
@@ -58,7 +58,6 @@ int main(int argc, char **argv)
   fd_set readers, writers;
   int c, nofork = 0, fd, i, nfds, count, status;
   const char *progname;
-  char *errmem;
   FILE *fp;
 
   progname = strrchr(argv[0], '/');
@@ -105,8 +104,7 @@ int main(int argc, char **argv)
   if (status != ARES_SUCCESS)
     {
       fprintf(stderr, "Can't initialize resolver: %s\n",
-	      ares_strerror(status, &errmem));
-      ares_free_errmem(errmem);
+	      ares_strerror(status));
       return 1;
     }
 
diff --git a/printer.c b/printer.c
index baf6ca9..118707c 100644
--- a/printer.c
+++ b/printer.c
@@ -45,9 +45,10 @@ struct printer_poll_args {
 };
 
 static void printer_poll(void *arg);
-static void printer_hes_callback(void *arg, int status, unsigned char *abuf,
-				 int alen);
-static void printer_host_callback(void *arg, int status, struct hostent *host);
+static void printer_hes_callback(void *arg, int status, int timeouts,
+				 unsigned char *abuf, int alen);
+static void printer_host_callback(void *arg, int status, int timeouts,
+				  struct hostent *host);
 static void *make_pargs(struct serverstate *state, struct printer *printer);
 
 void printer_start_polls(struct serverstate *state)
@@ -84,13 +85,13 @@ static void printer_poll(void *arg)
   hesiod_free_string(state->hescontext, hesname);
 }
 
-static void printer_hes_callback(void *arg, int status, unsigned char *abuf,
-				 int alen)
+static void printer_hes_callback(void *arg, int status, int timeouts,
+				 unsigned char *abuf, int alen)
 {
   struct printer_poll_args *pargs = (struct printer_poll_args *) arg;
   struct serverstate *state = pargs->state;
   struct printer *printer = pargs->printer;
-  char **vec = NULL, *p, *q, *errmem;
+  char **vec = NULL, *p, *q;
 
   if (status == ARES_EDESTRUCTION)
     {
@@ -104,8 +105,7 @@ static void printer_hes_callback(void *arg, int status, unsigned char *abuf,
     {
       syslog(LOG_ERR, "printer_hes_callback: could not resolve Hesiod pcap "
 	     "for printer %s: %s", printer->name,
-	     ares_strerror(status, &errmem));
-      ares_free_errmem(errmem);
+	     ares_strerror(status));
       goto failure;
     }
 
@@ -150,7 +150,8 @@ failure:
   printer->timer = timer_set_rel(60, printer_poll, pargs);
 }
 
-static void printer_host_callback(void *arg, int status, struct hostent *host)
+static void printer_host_callback(void *arg, int status, int timeouts,
+				  struct hostent *host)
 {
   struct printer_poll_args *pargs = (struct printer_poll_args *) arg;
   struct printer *printer = pargs->printer;
@@ -158,7 +159,6 @@ static void printer_host_callback(void *arg, int status, struct hostent *host)
   unsigned short port;
   struct servent *servent;
   struct sockaddr_in sin;
-  char *errmem;
 
   if (status == ARES_EDESTRUCTION)
     {
@@ -171,8 +171,7 @@ static void printer_host_callback(void *arg, int status, struct hostent *host)
   if (status != ARES_SUCCESS)
     {
       syslog(LOG_ERR, "printer_host_callback: printer %s can't resolve print "
-	     "server name: %s", printer->name, ares_strerror(status, &errmem));
-      ares_free_errmem(errmem);
+	     "server name: %s", printer->name, ares_strerror(status));
       goto failure;
     }
 
diff --git a/ws.c b/ws.c
index 4cddb20..c2a0eba 100644
--- a/ws.c
+++ b/ws.c
@@ -55,7 +55,8 @@ struct wsarg {
   struct machine *machine;
 };
 
-static void poll_callback(void *arg, int status, struct hostent *host);
+static void poll_callback(void *arg, int status, int timeouts,
+			  struct hostent *host);
 static int ws_searchcomp(const void *key, const void *elem);
 static int ws_sortcomp(const void *elem1, const void *elem2);
 
@@ -202,13 +203,14 @@ void ws_sort(struct config *config)
 	ws_sortcomp);
 }
 
-static void poll_callback(void *arg, int status, struct hostent *host)
+static void poll_callback(void *arg, int status, int timeouts,
+			  struct hostent *host)
 {
   struct wsarg *wsarg = (struct wsarg *) arg;
   struct serverstate *state = wsarg->state;
   struct machine *machine = wsarg->machine;
   struct sockaddr_in sin;
-  char dummy = 0, *errmem;
+  char dummy = 0;
 
   free(wsarg);
   if (status != ARES_SUCCESS)
@@ -221,8 +223,7 @@ static void poll_callback(void *arg, int status, struct hostent *host)
       else
 	{
 	  syslog(LOG_ERR, "poll_callback: could not resolve ws name %s: %s",
-		 machine->name, ares_strerror(status, &errmem));
-	  ares_free_errmem(errmem);
+		 machine->name, ares_strerror(status));
 	}
       return;
     }

home help back first fref pref prev next nref lref last post