]> git.meshlink.io Git - meshlink/blobdiff - src/net_socket.c
Add a callback that notifies the application when it is blacklisted.
[meshlink] / src / net_socket.c
index 6af4f7386bcc37530057fc5251de2ff0103a1137..abf6a7cf0e0eb7fa878f347efa45a6910c646927 100644 (file)
@@ -87,14 +87,16 @@ static void retry_outgoing_handler(event_loop_t *loop, void *data) {
 }
 
 void retry_outgoing(meshlink_handle_t *mesh, outgoing_t *outgoing) {
-       if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[mesh->devclass].fast_retry_period) {
+       if(!mesh->reachable && mesh->loop.now.tv_sec < mesh->last_unreachable + mesh->dev_class_traits[outgoing->node->devclass].fast_retry_period) {
                outgoing->timeout = 1;
        } else {
                outgoing->timeout += 5;
        }
 
-       if(outgoing->timeout > mesh->dev_class_traits[mesh->devclass].maxtimeout) {
-               outgoing->timeout = mesh->dev_class_traits[mesh->devclass].maxtimeout;
+       int maxtimeout = mesh->dev_class_traits[outgoing->node->devclass].maxtimeout;
+
+       if(outgoing->timeout > maxtimeout) {
+               outgoing->timeout = maxtimeout;
        }
 
        timeout_add(&mesh->loop, &outgoing->ev, retry_outgoing_handler, outgoing, &(struct timespec) {
@@ -141,6 +143,10 @@ static void handle_meta_write(meshlink_handle_t *mesh, connection_t *c) {
        }
 }
 
+void flush_meta(meshlink_handle_t *mesh, connection_t *c) {
+       handle_meta_write(mesh, c);
+}
+
 static void handle_meta_io(event_loop_t *loop, void *data, int flags) {
        meshlink_handle_t *mesh = loop->data;
        connection_t *c = data;
@@ -318,7 +324,7 @@ static bool get_next_outgoing_address(meshlink_handle_t *mesh, outgoing_t *outgo
 
                outgoing->ai = NULL;
                outgoing->aip = NULL;
-               outgoing->state = OUTGOING_RECENT;
+               outgoing->state = OUTGOING_END;
        }
 
        if(outgoing->state == OUTGOING_RECENT) {