Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@Library('CCtestLib${BUILDTYPE}) _
12 changes: 11 additions & 1 deletion lib/ipc_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
11 changes: 3 additions & 8 deletions lib/loop_timerlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,18 @@ 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();
}
else {
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
}
Expand Down
10 changes: 5 additions & 5 deletions tests/check_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down