]> git.meshlink.io Git - meshlink/blobdiff - src/net.c
Correctly handle incoming retransmissions of SYN packets.
[meshlink] / src / net.c
index 1e2e00cdef5eaecfc84c1cddd63e61601fc9110e..76f884758ceb7408ce82b566de6c11784b210810 100644 (file)
--- 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