]> git.meshlink.io Git - meshlink/blobdiff - src/net.c
Never call timeout_set() outside callbacks if no callback is set.
[meshlink] / src / net.c
index 8bec6b67f52af5e52c671d94cc26ffad425244aa..22f8287ff70a232acc2ab8c7f7091308c47f0304 100644 (file)
--- a/src/net.c
+++ b/src/net.c
@@ -700,7 +700,7 @@ void retry(meshlink_handle_t *mesh) {
 
                int sock = socket(sa.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
 
-               if(sock != -1) {
+               if(sock == -1) {
                        continue;
                }
 
@@ -713,9 +713,11 @@ void retry(meshlink_handle_t *mesh) {
        }
 
        /* Kick the ping timeout handler */
-       timeout_set(&mesh->loop, &mesh->pingtimer, &(struct timespec) {
-               0, 0
-       });
+       if(mesh->pingtimer.cb) {
+               timeout_set(&mesh->loop, &mesh->pingtimer, &(struct timespec) {
+                       0, 0
+               });
+       }
 }
 
 /*