diff options
author | Volker Lendecke <vl@samba.org> | 2017-01-08 17:54:06 +0000 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2017-03-20 16:11:15 +0100 |
commit | a181609f94a71ea7e9fba2f1d9a5220a6bff9683 (patch) | |
tree | d032ee06d8bbe38f8cdd539a496ac02428b2b457 /lib/util/util.c | |
parent | 8f0ecb660e23ed51451aca96b9bb1f8776fa1ad0 (diff) | |
download | samba-a181609f94a71ea7e9fba2f1d9a5220a6bff9683.tar.gz |
lib: Simplify smb_nanosleep
We have the recalculation logic also in sys_poll_intr, don't duplicate it.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Mon Mar 20 16:11:16 CET 2017 on sn-devel-144
Diffstat (limited to 'lib/util/util.c')
-rw-r--r-- | lib/util/util.c | 44 |
1 files changed, 2 insertions, 42 deletions
diff --git a/lib/util/util.c b/lib/util/util.c index 49f15847be6..ef148e98d29 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -33,6 +33,7 @@ #include "system/wait.h" #include "debug.h" #include "samba_util.h" +#include "lib/util/select.h" #undef malloc #undef strcasecmp @@ -292,48 +293,7 @@ _PUBLIC_ bool directory_create_or_exist_strict(const char *dname, _PUBLIC_ void smb_msleep(unsigned int t) { -#if defined(HAVE_NANOSLEEP) - struct timespec ts; - int ret; - - ts.tv_sec = t/1000; - ts.tv_nsec = 1000000*(t%1000); - - do { - errno = 0; - ret = nanosleep(&ts, &ts); - } while (ret < 0 && errno == EINTR && (ts.tv_sec > 0 || ts.tv_nsec > 0)); -#else - unsigned int tdiff=0; - struct timeval tval,t1,t2; - fd_set fds; - - GetTimeOfDay(&t1); - t2 = t1; - - while (tdiff < t) { - tval.tv_sec = (t-tdiff)/1000; - tval.tv_usec = 1000*((t-tdiff)%1000); - - /* Never wait for more than 1 sec. */ - if (tval.tv_sec > 1) { - tval.tv_sec = 1; - tval.tv_usec = 0; - } - - FD_ZERO(&fds); - errno = 0; - select(0,&fds,NULL,NULL,&tval); - - GetTimeOfDay(&t2); - if (t2.tv_sec < t1.tv_sec) { - /* Someone adjusted time... */ - t1 = t2; - } - - tdiff = usec_time_diff(&t2,&t1)/1000; - } -#endif + sys_poll_intr(NULL, 0, t); } /** |