]> git.meshlink.io Git - meshlink/blobdiff - src/protocol_misc.c
Fix memory leaks from timers.
[meshlink] / src / protocol_misc.c
index 727881bd1080476d2c5d9303b76d315f702cc2a0..dde4bbb4db377445cda34c3b6e028ebb8268237f 100644 (file)
@@ -72,7 +72,7 @@ bool send_ping(meshlink_handle_t *mesh, connection_t *c) {
        c->status.pinged = true;
        c->last_ping_time = mesh->loop.now.tv_sec;
 
-       return send_request(mesh, c, "%d", PING);
+       return send_request(mesh, c, NULL, "%d", PING);
 }
 
 bool ping_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
@@ -81,7 +81,7 @@ bool ping_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
 }
 
 bool send_pong(meshlink_handle_t *mesh, connection_t *c) {
-       return send_request(mesh, c, "%d", PONG);
+       return send_request(mesh, c, NULL, "%d", PONG);
 }
 
 bool pong_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
@@ -89,11 +89,12 @@ bool pong_h(meshlink_handle_t *mesh, connection_t *c, const char *request) {
        (void)request;
        c->status.pinged = false;
 
-       /* Succesful connection, reset timeout if this is an outgoing connection. */
+       /* Successful connection, reset timeout if this is an outgoing connection. */
 
+       // TODO: completely remove this outgoing, let the autoconnect algorithm handle it
        if(c->outgoing) {
                c->outgoing->timeout = 0;
-               c->outgoing->cfg = NULL;
+               c->outgoing->state = OUTGOING_START;
 
                if(c->outgoing->ai) {
                        freeaddrinfo(c->outgoing->ai);