diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100755 index 00000000..68483ef1 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1 @@ +@Library('CCtestLib${BUILDTYPE}) _ diff --git a/lib/ipc_setup.c b/lib/ipc_setup.c index 0ef9bb6b..0de71150 100644 --- a/lib/ipc_setup.c +++ b/lib/ipc_setup.c @@ -473,11 +473,15 @@ qb_ipcc_us_setup_connect(struct qb_ipcc_connection *c, return 0; } +#define AUTH_RECV_MAX_RETRIES 10 +#define AUTH_RECV_SLEEP_TIME_US 100 + /* Called from ipcc_connect_continue() when async connect socket is active */ int qb_ipcc_setup_connect_continue(struct qb_ipcc_connection *c, struct qb_ipc_connection_response *r) { struct ipc_auth_data *data; int32_t res; + int retry_count = 0; #ifdef QB_LINUX int off = 0; #endif @@ -486,8 +490,14 @@ int qb_ipcc_setup_connect_continue(struct qb_ipcc_connection *c, struct qb_ipc_c qb_ipcc_us_sock_close(c->setup.u.us.sock); return -ENOMEM; } - +retry: res = qb_ipc_us_recv_msghdr(data); + if (res == -EAGAIN && ++retry_count < AUTH_RECV_MAX_RETRIES) { + struct timespec ts = {0, AUTH_RECV_SLEEP_TIME_US*QB_TIME_NS_IN_USEC}; + struct timespec ts_left = {0, 0}; + nanosleep(&ts, &ts_left); + goto retry; + } #ifdef QB_LINUX setsockopt(c->setup.u.us.sock, SOL_SOCKET, SO_PASSCRED, &off, diff --git a/lib/loop_timerlist.c b/lib/loop_timerlist.c index 9aef348a..0396b951 100644 --- a/lib/loop_timerlist.c +++ b/lib/loop_timerlist.c @@ -326,10 +326,11 @@ qb_loop_timer_expire_time_remaining(struct qb_loop * lp, qb_loop_timer_handle th if (res != 0) { return 0; } + if (t->state != QB_POLL_ENTRY_ACTIVE) { + return 0; + } struct timerlist_timer *timer = (struct timerlist_timer *)t->timerlist_handle; - - if (timer->is_absolute_timer) { current_ns = qb_util_nano_from_epoch_get(); } @@ -337,12 +338,6 @@ qb_loop_timer_expire_time_remaining(struct qb_loop * lp, qb_loop_timer_handle th current_ns = qb_util_nano_current_get(); } uint64_t timer_ns = timerlist_expire_time(&s->timerlist, t->timerlist_handle); - /* since time estimation is racy by nature, I'll try to check the state late, - * and try to understand that no matter what, the timer might have expired in the mean time - */ - if (t->state != QB_POLL_ENTRY_ACTIVE) { - return 0; - } if (timer_ns < current_ns) { return 0; // respect the "expired" contract } diff --git a/tests/check_loop.c b/tests/check_loop.c index 4f9fe27d..b20cd85f 100644 --- a/tests/check_loop.c +++ b/tests/check_loop.c @@ -361,7 +361,7 @@ static void check_time_left(void *data) ck_assert(abs_time > 0ULL); ck_assert(rel_time > 0ULL); ck_assert(abs_time > rel_time); - ck_assert(rel_time <= 60*QB_TIME_NS_IN_MSEC); + ck_assert(rel_time <= 500*QB_TIME_NS_IN_MSEC); } @@ -425,10 +425,10 @@ START_TEST(test_loop_timer_basic) res = qb_loop_timer_add(l, QB_LOOP_LOW, 7*QB_TIME_NS_IN_MSEC, l, reset_one_shot_tmo, &reset_th); ck_assert_int_eq(res, 0); - res = qb_loop_timer_add(l, QB_LOOP_HIGH, 20*QB_TIME_NS_IN_MSEC, l, check_time_left, &test_th2); + res = qb_loop_timer_add(l, QB_LOOP_LOW, 500*QB_TIME_NS_IN_MSEC, l, job_stop, &test_th); ck_assert_int_eq(res, 0); - res = qb_loop_timer_add(l, QB_LOOP_LOW, 60*QB_TIME_NS_IN_MSEC, l, job_stop, &test_th); + res = qb_loop_timer_add(l, QB_LOOP_HIGH, 5*QB_TIME_NS_IN_MSEC, l, check_time_left, &test_th2); ck_assert_int_eq(res, 0); qb_loop_run(l); @@ -471,10 +471,10 @@ START_TEST(test_loop_timer_threads) res = qb_loop_timer_add(l, QB_LOOP_LOW, 7*QB_TIME_NS_IN_MSEC, l, reset_one_shot_tmo, &reset_th); ck_assert_int_eq(res, 0); - res = qb_loop_timer_add(l, QB_LOOP_HIGH, 20*QB_TIME_NS_IN_MSEC, l, check_time_left, &test_th2); + res = qb_loop_timer_add(l, QB_LOOP_LOW, 500*QB_TIME_NS_IN_MSEC, l, job_stop, &test_th); ck_assert_int_eq(res, 0); - res = qb_loop_timer_add(l, QB_LOOP_LOW, 60*QB_TIME_NS_IN_MSEC, l, job_stop, &test_th); + res = qb_loop_timer_add(l, QB_LOOP_HIGH, 5*QB_TIME_NS_IN_MSEC, l, check_time_left, &test_th2); ck_assert_int_eq(res, 0); qb_loop_run(l);