X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=networking%2Fisrv.c;h=3673db715e45b58a8f78f7f0192fa33fff61f2f7;hb=c6725b0af68238a456690146adec763c04f66c82;hp=1a41dd4fbcf2db5d81c94794d77b954d6a5bcd99;hpb=d37f22225b4d10b84bbc4f6cee2e26d9f9b80fac;p=oweals%2Fbusybox.git diff --git a/networking/isrv.c b/networking/isrv.c index 1a41dd4fb..3673db715 100644 --- a/networking/isrv.c +++ b/networking/isrv.c @@ -3,9 +3,9 @@ * Generic non-forking server infrastructure. * Intended to make writing telnetd-type servers easier. * - * Copyright (C) 2007 Denis Vlasenko + * Copyright (C) 2007 Denys Vlasenko * - * Licensed under GPL version 2, see file LICENSE in this tarball for details. + * Licensed under GPLv2, see file LICENSE in this source tree. */ #include "libbb.h" @@ -21,20 +21,6 @@ /* Helpers */ -/* Even if _POSIX_MONOTONIC_CLOCK is defined, this - * may require librt */ -#if 0 /*def _POSIX_MONOTONIC_CLOCK*/ -static time_t monotonic_time(void) -{ - struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) - time(&ts.tv_sec); - return ts.tv_sec; -} -#else -#define monotonic_time() (time(NULL)) -#endif - /* Opaque structure */ struct isrv_state_t { @@ -208,7 +194,6 @@ static void handle_accept(isrv_state_t *state, int fd) remove_peer(state, n); /* unsuccesful peer start */ } -void BUG_sizeof_fd_set_is_strange(void); static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void **)) { enum { LONG_CNT = sizeof(fd_set) / sizeof(long) }; @@ -217,8 +202,7 @@ static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void * /* need to know value at _the beginning_ of this routine */ int fd_cnt = FD_COUNT; - if (LONG_CNT * sizeof(long) != sizeof(fd_set)) - BUG_sizeof_fd_set_is_strange(); + BUILD_BUG_ON(LONG_CNT * sizeof(long) != sizeof(fd_set)); fds_pos = 0; while (1) { @@ -258,7 +242,7 @@ static void handle_fd_set(isrv_state_t *state, fd_set *fds, int (*h)(int, void * /* this peer is gone */ remove_peer(state, peer); } else if (TIMEOUT) { - TIMEO_TBL[peer] = monotonic_time(); + TIMEO_TBL[peer] = monotonic_sec(); } } } @@ -335,7 +319,7 @@ void isrv_run( break; if (timeout) { - time_t t = monotonic_time(); + time_t t = monotonic_sec(); if (t != CURTIME) { CURTIME = t; handle_timeout(state, do_timeout);