X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet.c;h=76f884758ceb7408ce82b566de6c11784b210810;hb=4216a7e7a1897c0e34ce82e7c2c4cc82070c7b10;hp=1e2e00cdef5eaecfc84c1cddd63e61601fc9110e;hpb=771c923ba3d6e2122d822cd1ebd38373020dc422;p=meshlink diff --git a/src/net.c b/src/net.c index 1e2e00cd..76f88475 100644 --- a/src/net.c +++ b/src/net.c @@ -109,6 +109,8 @@ void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report) and close the connection. */ static void timeout_handler(event_loop_t *loop, void *data) { + assert(data); + meshlink_handle_t *mesh = loop->data; logger(mesh, MESHLINK_DEBUG, "timeout_handler()"); @@ -146,7 +148,7 @@ static void timeout_handler(event_loop_t *loop, void *data) { } timeout_set(&mesh->loop, data, &(struct timeval) { - default_timeout, rand() % 100000 + default_timeout, prng(mesh, TIMER_FUDGE) }); } @@ -608,7 +610,7 @@ static void periodic_handler(event_loop_t *loop, void *data) { } timeout_set(&mesh->loop, data, &(struct timeval) { - timeout, rand() % 100000 + timeout, prng(mesh, TIMER_FUDGE) }); } @@ -696,7 +698,7 @@ void retry(meshlink_handle_t *mesh) { */ int main_loop(meshlink_handle_t *mesh) { timeout_add(&mesh->loop, &mesh->pingtimer, timeout_handler, &mesh->pingtimer, &(struct timeval) { - default_timeout, rand() % 100000 + default_timeout, prng(mesh, TIMER_FUDGE) }); timeout_add(&mesh->loop, &mesh->periodictimer, periodic_handler, &mesh->periodictimer, &(struct timeval) { 0, 0