summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 012f00b)
raw | patch | inline | side by side (parent: 012f00b)
author | Florian Forster <octo@verplant.org> | |
Fri, 2 Jun 2006 17:29:15 +0000 (19:29 +0200) | ||
committer | Florian Forster <octo@verplant.org> | |
Fri, 2 Jun 2006 17:29:15 +0000 (19:29 +0200) |
If no hosts could be added (e.g. because resolving the hostnames failed) the
oping application didn't exit but seemed to hang. Actually it was calling
`poll' (or select?) without any file descriptors, and not outputting anything
at all.
This patch makes oping exit if no hosts could be added to the oping library.
oping application didn't exit but seemed to hang. Actually it was calling
`poll' (or select?) without any file descriptors, and not outputting anything
at all.
This patch makes oping exit if no hosts could be added to the oping library.
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index 18724f4c2d289bf34e1795b076a7c63a284a8d6b..50c051b6d8c9beb7b3b544c9a24cb8897ca6c8f8 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
for (i = optind; i < argc; i++)
{
- if (ping_host_add (ping, argv[i]) > 0)
+ if (ping_host_add (ping, argv[i]) < 0)
{
fprintf (stderr, "ping_host_add (%s) failed\n", argv[i]);
continue;
}
}
+ i = 0;
for (iter = ping_iterator_get (ping);
iter != NULL;
iter = ping_iterator_next (iter))
context->host, context->addr, (unsigned int) buffer_size);
ping_iterator_set_context (iter, (void *) context);
+
+ i++;
+ }
+
+ if (i == 0)
+ {
+ fprintf (stderr, "No valid hosts left.\n");
+ exit (1);
}
memset (&sigint_action, '\0', sizeof (sigint_action));