X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fnet.c;h=80490efadb785ab59db7cb6e8a43e850008b9131;hb=0f19bd98e1a95ab45d0ed46d79a07502b65a4c95;hp=1e2e00cdef5eaecfc84c1cddd63e61601fc9110e;hpb=771c923ba3d6e2122d822cd1ebd38373020dc422;p=meshlink diff --git a/src/net.c b/src/net.c index 1e2e00cd..80490efa 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 @@ -706,7 +708,7 @@ int main_loop(meshlink_handle_t *mesh) { mesh->datafromapp.signum = 0; signal_add(&mesh->loop, &mesh->datafromapp, meshlink_send_from_queue, mesh, mesh->datafromapp.signum); - if(!event_loop_run(&mesh->loop, &mesh->mesh_mutex)) { + if(!event_loop_run(&mesh->loop, &mesh->mutex)) { logger(mesh, MESHLINK_ERROR, "Error while waiting for input: %s", strerror(errno)); abort(); signal_del(&mesh->loop, &mesh->datafromapp);