Commit fbef5fdb authored by chris's avatar chris
Browse files

""

parent 027a0242
......@@ -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
......
......@@ -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])
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment