From fbef5fdbc041d865daff316f51d8bf8d1e414116 Mon Sep 17 00:00:00 2001 From: chris <> Date: Thu, 6 Nov 2003 21:43:31 +0000 Subject: [PATCH] "" --- Makefile.am | 2 +- configure.in | 6 +++--- resolver.c | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 47a34bb..9c130c4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -22,7 +22,7 @@ noinst_HEADERS = addr_hash.h ether.h ethertype.h extract.h hash.h iftop.h \ integers.h ip.h llc.h ns_hash.h options.h resolver.h \ screenfilter.h serv_hash.h sll.h sorted_list.h tcp.h \ threadprof.h token.h ui.h dlcommon.h stringmap.h \ - vector.h cfgfile.h + vector.h cfgfile.h util.h man_MANS = iftop.8 diff --git a/configure.in b/configure.in index 04efb58..f581697 100644 --- a/configure.in +++ b/configure.in @@ -37,9 +37,9 @@ AC_ARG_WITH(resolver, [ --with-resolver=TYPE Technique iftop should use for name resolution. Valid options are netdb, netdb_1thread (for systems without working gethostbyaddr_r), ares for the MIT ARES - asynchronous resolver library, forking for the REALLY SUCKY - forking resolver, or none if you don't need any name - resolution. + asynchronous resolver library, forking for the REALLY + SUCKY forking resolver, or none if you don't need any + name resolution. [default=netdb]], [resolver=$withval], [resolver=netdb]) diff --git a/resolver.c b/resolver.c index 1cec32d..43539dc 100644 --- a/resolver.c +++ b/resolver.c @@ -320,7 +320,7 @@ char *do_resolve(struct in_addr *addr) { workerinfo = xmalloc(sizeof *workerinfo); pthread_setspecific(worker_key, workerinfo); workerinfo->fd = p[0]; - + switch (workerinfo->child = fork()) { case 0: close(p[0]); @@ -332,6 +332,7 @@ char *do_resolve(struct in_addr *addr) { return NULL; default: +fprintf(stderr, "New child is %d, we have fd %d, he has fd %d\n", workerinfo->child, p[0], p[1]); close(p[1]); } } @@ -340,11 +341,13 @@ char *do_resolve(struct in_addr *addr) { if (write(workerinfo->fd, addr, sizeof *addr) != sizeof *addr || read(workerinfo->fd, name, NAMESIZE) != NAMESIZE) { /* Something went wrong. Just kill the child and get on with it. */ +fprintf(stderr, "Protocol error (%s) talking to child %d\n", strerror(errno), workerinfo->child); kill(workerinfo->child, SIGKILL); wait(); close(workerinfo->fd); xfree(workerinfo); pthread_setspecific(worker_key, NULL); + *name = 0; } if (!*name) return NULL;