sanitize: add bip_clock_gettime util function
This commit is contained in:
parent
368149575d
commit
ce4cf8b6a0
@ -874,7 +874,7 @@ static int cn_want_write(connection_t *cn)
|
||||
list_t *wait_event(list_t *cn_list, time_t *msec, int *nc)
|
||||
{
|
||||
fd_set fds_read, fds_write, fds_except;
|
||||
int maxfd = -1, err, errtime;
|
||||
int maxfd = -1, err;
|
||||
list_t *cn_newdata;
|
||||
list_iterator_t it;
|
||||
struct timeval tv;
|
||||
@ -945,11 +945,7 @@ list_t *wait_event(list_t *cn_list, time_t *msec, int *nc)
|
||||
mylog(LOG_DEBUGTOOMUCH, "msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
||||
tv.tv_usec);
|
||||
|
||||
errtime = clock_gettime(CLOCK_MONOTONIC, &btv);
|
||||
if (errtime != 0) {
|
||||
fatal("clock_gettime: %s", strerror(errno));
|
||||
}
|
||||
|
||||
bip_clock_gettime(CLOCK_MONOTONIC, &btv);
|
||||
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
|
||||
|
||||
if (err == 0) {
|
||||
@ -962,11 +958,7 @@ list_t *wait_event(list_t *cn_list, time_t *msec, int *nc)
|
||||
tv.tv_sec, tv.tv_usec);
|
||||
}
|
||||
|
||||
errtime = clock_gettime(CLOCK_MONOTONIC, &etv);
|
||||
if (errtime != 0) {
|
||||
fatal("clock_gettime: %s", strerror(errno));
|
||||
}
|
||||
|
||||
bip_clock_gettime(CLOCK_MONOTONIC, &etv);
|
||||
if (etv.tv_sec < btv.tv_sec)
|
||||
mylog(LOG_ERROR, "Time rewinded ! not touching interval");
|
||||
else {
|
||||
|
11
src/util.c
11
src/util.c
@ -158,6 +158,17 @@ end:
|
||||
return res;
|
||||
}
|
||||
|
||||
void bip_clock_gettime(clockid_t clockid, struct timespec *tp)
|
||||
{
|
||||
int err = clock_gettime(clockid, tp);
|
||||
|
||||
if (err != 0)
|
||||
fatal("clock_gettime: %s", strerror(errno));
|
||||
|
||||
if (tp->tv_sec < 0 || tp->tv_nsec < 0)
|
||||
fatal("clock_gettime returned negative time");
|
||||
}
|
||||
|
||||
/*
|
||||
* <nick> ::= <letter> { <letter> | <number> | <special> }
|
||||
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
||||
|
@ -178,6 +178,7 @@ void *bip_realloc(void *ptr, size_t size);
|
||||
char *bip_strdup(const char *str);
|
||||
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2);
|
||||
char *bip_strcatf_fit(size_t *remaining, char *str, const char *str2, ...);
|
||||
void bip_clock_gettime(clockid_t clockid, struct timespec *tp);
|
||||
#define array_each(a, idx, ptr) for ((idx) = 0; \
|
||||
(idx) < (a)->elemc && (((ptr) = array_get((a), (idx))) || 1); \
|
||||
(idx)++)
|
||||
|
Loading…
Reference in New Issue
Block a user