Replace usleep() with nanosleep().
This commit is contained in:
parent
491839a81a
commit
b5b04910b9
4 changed files with 9 additions and 10 deletions
|
@ -199,7 +199,7 @@ AC_CHECK_TYPES([socklen_t, struct ether_header, struct arphdr, struct ether_arp,
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_TYPE_SIGNAL
|
AC_TYPE_SIGNAL
|
||||||
AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random recvmmsg select strdup strsignal usleep unsetenv vsyslog devname fdevname],
|
AC_CHECK_FUNCS([asprintf daemon fchmod flock ftime fork get_current_dir_name gettimeofday mlockall putenv random recvmmsg select strdup strsignal nanosleep unsetenv vsyslog devname fdevname],
|
||||||
[], [], [#include "$srcdir/src/have.h"]
|
[], [], [#include "$srcdir/src/have.h"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
11
src/dropin.c
11
src/dropin.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
dropin.c -- a set of drop-in replacements for libc functions
|
dropin.c -- a set of drop-in replacements for libc functions
|
||||||
Copyright (C) 2000-2005 Ivo Timmermans,
|
Copyright (C) 2000-2005 Ivo Timmermans,
|
||||||
2000-2013 Guus Sliepen <guus@tinc-vpn.org>
|
2000-2016 Guus Sliepen <guus@tinc-vpn.org>
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
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
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -174,10 +174,9 @@ int gettimeofday(struct timeval *tv, void *tz) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_USLEEP
|
#ifndef HAVE_NANOSLEEP
|
||||||
int usleep(long long usec) {
|
int nanosleep(const struct timespec *req, struct timespec *rem) {
|
||||||
struct timeval tv = {usec / 1000000, (usec / 1000) % 1000};
|
struct timeval tv = {req->tv_sec, req->tv_nsec / 1000};
|
||||||
select(0, NULL, NULL, NULL, &tv);
|
return select(0, NULL, NULL, NULL, &tv);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -41,8 +41,8 @@ extern int vasprintf(char **, const char *, va_list ap);
|
||||||
extern int gettimeofday(struct timeval *, void *);
|
extern int gettimeofday(struct timeval *, void *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_USLEEP
|
#ifndef HAVE_NANOSLEEP
|
||||||
extern int usleep(long long usec);
|
extern int nanosleep(const struct timespec *req, struct timespec *rem);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef timeradd
|
#ifndef timeradd
|
||||||
|
|
|
@ -181,7 +181,7 @@ static void periodic_handler(void *data) {
|
||||||
|
|
||||||
if(contradicting_del_edge > 100 && contradicting_add_edge > 100) {
|
if(contradicting_del_edge > 100 && contradicting_add_edge > 100) {
|
||||||
logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime);
|
logger(DEBUG_ALWAYS, LOG_WARNING, "Possible node with same Name as us! Sleeping %d seconds.", sleeptime);
|
||||||
usleep(sleeptime * 1000000LL);
|
nanosleep(&(struct timespec){sleeptime, 0}, NULL);
|
||||||
sleeptime *= 2;
|
sleeptime *= 2;
|
||||||
if(sleeptime < 0)
|
if(sleeptime < 0)
|
||||||
sleeptime = 3600;
|
sleeptime = 3600;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue