author | Florian Forster <octo@verplant.org> | |
Wed, 24 Sep 2014 23:55:36 +0000 (16:55 -0700) | ||
committer | Florian Forster <octo@verplant.org> | |
Wed, 24 Sep 2014 23:55:36 +0000 (16:55 -0700) |
.gitignore | patch | blob | history | |
autogen.sh | [new file with mode: 0755] | patch | blob |
src/liboping.c | patch | blob | history | |
src/oping.c | patch | blob | history |
diff --git a/.gitignore b/.gitignore
index 8588514f81bd5b112c6bc6e25573fca8709b839c..e39f4fb7a399e15c738d7e87cb7e80205f194686 100644 (file)
--- a/.gitignore
+++ b/.gitignore
*.o
*.tar.gz
*.tar.bz2
+bindings/perl/MYMETA.yml
diff --git a/autogen.sh b/autogen.sh
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+libtoolize
+aclocal -I m4
+autoheader
+automake --add-missing
+autoconf
+echo "autoconfiguration done, to build: ./configure ; make"
diff --git a/src/liboping.c b/src/liboping.c
index 74122a80f63706c4c9166f30bba50f6c6e3a3073..40a0ba21b570bab19fea04fc71d8c69231125173 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
return (0);
}
+/* Blocks until a packet was received from all hosts or the timeout is reached.
+ * When interrupted, (-EINTR) is returned. On error, -1 is returned. On
+ * success, returns zero. */
static int ping_receive_all (pingobj_t *obj)
{
fd_set read_fds;
if ((status == -1) && (errno == EINTR))
{
dprintf ("select was interrupted by signal..\n");
- continue;
+ ping_set_errno (obj, EINTR);
+ return (-EINTR);
}
else if (status < 0)
{
} /* while (1) */
return (ret);
-}
+} /* int ping_receive_all */
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Sending functions: *
int ping_send (pingobj_t *obj)
{
- int ret;
-
if (obj == NULL)
return (-1);
if (ping_send_all (obj) < 0)
return (-1);
- if ((ret = ping_receive_all (obj)) < 0)
- return (-2);
-
- return (ret);
+ return (ping_receive_all (obj));
}
static pinghost_t *ping_host_search (pinghost_t *ph, const char *host)
diff --git a/src/oping.c b/src/oping.c
index 5c0ead5ee2608f4b69a3da6b59041e278321d7ff..b3beeb09d52b363fca4727d88bbb29dc76d4d3d7 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
# define _POSIX_SAVED_IDS 0
#endif
+#ifndef IPTOS_MINCOST
+# define IPTOS_MINCOST 0x02
+#endif
+
/* Remove GNU specific __attribute__ settings when using another compiler */
#if !__GNUC__
# define __attribute__(x) /**/
return (1);
}
- if (ping_send (ping) < 0)
+ status = ping_send (ping);
+ if (status == -EINTR)
+ {
+ continue;
+ }
+ else if (status < 0)
{
fprintf (stderr, "ping_send failed: %s\n",
ping_get_error (ping));
/* printf ("Sleeping for %i.%09li seconds\n", (int) ts_wait.tv_sec, ts_wait.tv_nsec); */
while ((status = nanosleep (&ts_wait, &ts_wait)) != 0)
{
- if (errno != EINTR)
+ if (errno == EINTR)
{
- perror ("nanosleep");
- break;
+ continue;
}
- else if (opt_count == 0)
+ else
{
- /* sigint */
+ perror ("nanosleep");
break;
}
}