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)
|
list_t *wait_event(list_t *cn_list, time_t *msec, int *nc)
|
||||||
{
|
{
|
||||||
fd_set fds_read, fds_write, fds_except;
|
fd_set fds_read, fds_write, fds_except;
|
||||||
int maxfd = -1, err, errtime;
|
int maxfd = -1, err;
|
||||||
list_t *cn_newdata;
|
list_t *cn_newdata;
|
||||||
list_iterator_t it;
|
list_iterator_t it;
|
||||||
struct timeval tv;
|
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,
|
mylog(LOG_DEBUGTOOMUCH, "msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
|
||||||
tv.tv_usec);
|
tv.tv_usec);
|
||||||
|
|
||||||
errtime = clock_gettime(CLOCK_MONOTONIC, &btv);
|
bip_clock_gettime(CLOCK_MONOTONIC, &btv);
|
||||||
if (errtime != 0) {
|
|
||||||
fatal("clock_gettime: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
|
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
|
||||||
|
|
||||||
if (err == 0) {
|
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);
|
tv.tv_sec, tv.tv_usec);
|
||||||
}
|
}
|
||||||
|
|
||||||
errtime = clock_gettime(CLOCK_MONOTONIC, &etv);
|
bip_clock_gettime(CLOCK_MONOTONIC, &etv);
|
||||||
if (errtime != 0) {
|
|
||||||
fatal("clock_gettime: %s", strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (etv.tv_sec < btv.tv_sec)
|
if (etv.tv_sec < btv.tv_sec)
|
||||||
mylog(LOG_ERROR, "Time rewinded ! not touching interval");
|
mylog(LOG_ERROR, "Time rewinded ! not touching interval");
|
||||||
else {
|
else {
|
||||||
|
11
src/util.c
11
src/util.c
@ -158,6 +158,17 @@ end:
|
|||||||
return res;
|
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> }
|
* <nick> ::= <letter> { <letter> | <number> | <special> }
|
||||||
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
|
||||||
|
@ -178,6 +178,7 @@ void *bip_realloc(void *ptr, size_t size);
|
|||||||
char *bip_strdup(const char *str);
|
char *bip_strdup(const char *str);
|
||||||
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2);
|
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2);
|
||||||
char *bip_strcatf_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; \
|
#define array_each(a, idx, ptr) for ((idx) = 0; \
|
||||||
(idx) < (a)->elemc && (((ptr) = array_get((a), (idx))) || 1); \
|
(idx) < (a)->elemc && (((ptr) = array_get((a), (idx))) || 1); \
|
||||||
(idx)++)
|
(idx)++)
|
||||||
|
Loading…
Reference in New Issue
Block a user