X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=src%2Fprotocol.c;h=482808a7e71885c6cf37d24ce42444f9d18c8aac;hb=aab092bf87b3f113499ba40802ad21f855c607e5;hp=3886e357a83b91a7349d80d1314d4ea601282600;hpb=9cde0d32cf209388cc59b06b7dcb0c3432f97da5;p=meshlink diff --git a/src/protocol.c b/src/protocol.c index 3886e357..482808a7 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -129,7 +129,6 @@ void forward_request(meshlink_handle_t *mesh, connection_t *from, submesh_t *s, bool receive_request(meshlink_handle_t *mesh, connection_t *c, const char *request) { assert(request); - assert(*request); if(c->outgoing && mesh->proxytype == PROXY_HTTP && c->allow_request == ID) { if(!request[0] || request[0] == '\r') { @@ -208,8 +207,8 @@ static void age_past_requests(event_loop_t *loop, void *data) { } if(left) { - timeout_set(&mesh->loop, &mesh->past_request_timeout, &(struct timeval) { - 10, rand() % 100000 + timeout_set(&mesh->loop, &mesh->past_request_timeout, &(struct timespec) { + 10, prng(mesh, TIMER_FUDGE) }); } } @@ -229,8 +228,8 @@ bool seen_request(meshlink_handle_t *mesh, const char *request) { new->firstseen = mesh->loop.now.tv_sec; if(!mesh->past_request_tree->head) { - timeout_set(&mesh->loop, &mesh->past_request_timeout, &(struct timeval) { - 10, rand() % 100000 + timeout_set(&mesh->loop, &mesh->past_request_timeout, &(struct timespec) { + 10, prng(mesh, TIMER_FUDGE) }); } @@ -243,7 +242,7 @@ void init_requests(meshlink_handle_t *mesh) { assert(!mesh->past_request_tree); mesh->past_request_tree = splay_alloc_tree((splay_compare_t) past_request_compare, (splay_action_t) free_past_request); - timeout_add(&mesh->loop, &mesh->past_request_timeout, age_past_requests, NULL, &(struct timeval) { + timeout_add(&mesh->loop, &mesh->past_request_timeout, age_past_requests, NULL, &(struct timespec) { 0, 0 }); }