diff --git a/src/liboping.c b/src/liboping.c
index 21855e1fc04f077dcd6ba149c89e78a475b85aa4..9b91b6d40f0214963c025aeb6af9e7f3f4246575 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * the Free Software Foundation; only version 2 of the License is
+ * applicable.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
(struct sockaddr *) ph->addr, ph->addrlen);
if (ret < 0)
+ {
+#if defined(EHOSTUNREACH)
+ if (errno == EHOSTUNREACH)
+ return (0);
+#endif
+#if defined(ENETUNREACH)
+ if (errno == ENETUNREACH)
+ return (0);
+#endif
ping_set_error (obj, "sendto", strerror (errno));
+ }
return (ret);
}
ph->addr = (struct sockaddr_storage *) (ph->timer + 1);
ph->addrlen = sizeof (struct sockaddr_storage);
+ ph->fd = -1;
ph->latency = -1.0;
ph->ident = ping_get_ident () & 0xFFFF;
static void ping_free (pinghost_t *ph)
{
+ if (ph->fd >= 0)
+ close (ph->fd);
+
if (ph->hostname != NULL)
free (ph->hostname);
if (ph->fd < 0)
{
- free (ph->hostname);
- free (ph);
+ ping_free (ph);
return (-1);
}
while (cur != NULL)
{
- if (strcasecmp (host, cur->hostname))
+ if (strcasecmp (host, cur->hostname) == 0)
break;
pre = cur;
else
pre->next = cur->next;
- if (cur->fd >= 0)
- close (cur->fd);
-
ping_free (cur);
return (0);