diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libmdsserver/macros.h | 12 | ||||
-rw-r--r-- | src/mds.c | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/libmdsserver/macros.h b/src/libmdsserver/macros.h index bb4e1c3..b464732 100644 --- a/src/libmdsserver/macros.h +++ b/src/libmdsserver/macros.h @@ -24,6 +24,7 @@ #include <unistd.h> #include <pthread.h> #include <string.h> +#include <time.h> */ @@ -215,5 +216,16 @@ (geteuid() == getuid() ? 0 : seteuid(getuid()))) +/** + * Wrapper for `clock_gettime` that gets some kind of + * monotonic time, the exact clock ID is not specified + * + * @param time_slot:struct timespec* Pointer to the variable in which to store the time + * @return :int Zero on sucess, -1 on error + */ +#define monotone(time_slot) \ + clock_gettime(CLOCK_MONOTONIC, time_slot) + + #endif @@ -297,7 +297,7 @@ int spawn_and_respawn_server(int fd) if (pid) { /* Get the current time. (Start of child process.) */ - time_error = (clock_gettime(CLOCK_MONOTONIC, &time_start) < 0); + time_error = (monotone(&time_start) < 0); if (time_error) perror(*argv); @@ -313,7 +313,7 @@ int spawn_and_respawn_server(int fd) break; /* Get the current time. (End of child process.) */ - time_error |= (clock_gettime(CLOCK_MONOTONIC, &time_end) < 0); + time_error |= (monotone(&time_end) < 0); /* Do not respawn if we could not read the time. */ if (time_error) |