From: Guus Sliepen Date: Fri, 10 Jul 2020 20:13:23 +0000 (+0200) Subject: Add meshlink_reset_timers(). X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=fcd0a7b8c0a823aaa4f9b885a408969b7dc16e00;p=meshlink Add meshlink_reset_timers(). This resets the outgoing connections timers and ping timers, exactly what is done when the network intterface status changes. --- diff --git a/src/meshlink.c b/src/meshlink.c index a8f8c928..0fe7343c 100644 --- a/src/meshlink.c +++ b/src/meshlink.c @@ -4420,7 +4420,20 @@ void meshlink_set_dev_class_maxtimeout(struct meshlink_handle *mesh, dev_class_t pthread_mutex_unlock(&mesh->mutex); } -extern void meshlink_set_inviter_commits_first(struct meshlink_handle *mesh, bool inviter_commits_first) { +void meshlink_reset_timers(struct meshlink_handle *mesh) { + if(!mesh) { + return; + } + + if(pthread_mutex_lock(&mesh->mutex) != 0) { + abort(); + } + + handle_network_change(mesh, true); + pthread_mutex_unlock(&mesh->mutex); +} + +void meshlink_set_inviter_commits_first(struct meshlink_handle *mesh, bool inviter_commits_first) { if(!mesh) { meshlink_errno = EINVAL; return; diff --git a/src/meshlink.h b/src/meshlink.h index e0164b7f..8293da0f 100644 --- a/src/meshlink.h +++ b/src/meshlink.h @@ -1599,6 +1599,15 @@ void meshlink_set_dev_class_fast_retry_period(struct meshlink_handle *mesh, dev_ */ void meshlink_set_dev_class_maxtimeout(struct meshlink_handle *mesh, dev_class_t devclass, int maxtimeout); +/// Reset all connection timers +/** This resets all timers related to connections, causing pending outgoing connections to be retried immediately. + * It also sends keepalive packets on all active connections immediately. + * + * \memberof meshlink_handle + * @param mesh A handle which represents an instance of MeshLink. + */ +void meshlink_reset_timers(struct meshlink_handle *mesh); + /// Set which order invitations are committed /** This determines in which order configuration files are written to disk during an invitation. * By default, the invitee saves the configuration to disk first, then the inviter. diff --git a/src/meshlink.sym b/src/meshlink.sym index 7b0c9159..991daa87 100644 --- a/src/meshlink.sym +++ b/src/meshlink.sym @@ -61,6 +61,7 @@ meshlink_open_ephemeral meshlink_open_ex meshlink_open_params_free meshlink_open_params_init +meshlink_reset_timers meshlink_send meshlink_set_canonical_address meshlink_set_channel_accept_cb