c->last_key_renewal = -3600;
}
}
+
+void devtool_set_meta_status_cb(meshlink_handle_t *mesh, meshlink_node_status_cb_t cb) {
+ if(!mesh) {
+ meshlink_errno = MESHLINK_EINVAL;
+ return;
+ }
+
+ if(pthread_mutex_lock(&mesh->mutex) != 0) {
+ abort();
+ }
+
+ mesh->meta_status_cb = cb;
+ pthread_mutex_unlock(&mesh->mutex);
+}
*/
extern void (*devtool_set_inviter_commits_first)(bool inviter_commited_first);
+/// Set the meta-connection status callback.
+/** This functions sets the callback that is called whenever a meta-connection is made or closed.
+ * The callback is run in MeshLink's own thread.
+ * It is therefore important that the callback uses apprioriate methods (queues, pipes, locking, etc.)
+ * to hand the data over to the application's thread.
+ * The callback should also not block itself and return as quickly as possible.
+ *
+ * \memberof meshlink_handle
+ * @param mesh A handle which represents an instance of MeshLink.
+ * @param cb A pointer to the function which will be called when a node's meta-connection status changes.
+ * If a NULL pointer is given, the callback will be disabled.
+ */
+void devtool_set_meta_status_cb(struct meshlink_handle *mesh, meshlink_node_status_cb_t cb);
+
#endif
devtool_get_node_status
devtool_keyrotate_probe
devtool_open_in_netns
+devtool_set_meta_status_cb
devtool_set_inviter_commits_first
devtool_trybind_probe
meshlink_add_address
// Infrequently used callbacks
meshlink_node_status_cb_t node_status_cb;
+ meshlink_node_status_cb_t meta_status_cb;
meshlink_node_pmtu_cb_t node_pmtu_cb;
meshlink_channel_accept_cb_t channel_accept_cb;
meshlink_node_duplicate_cb_t node_duplicate_cb;
void terminate_connection(meshlink_handle_t *mesh, connection_t *c, bool report) {
logger(mesh, MESHLINK_INFO, "Closing connection with %s", c->name);
- c->status.active = false;
-
if(c->node && c->node->connection == c) {
+ if(c->status.active && mesh->meta_status_cb) {
+ mesh->meta_status_cb(mesh, (meshlink_node_t *)c->node, false);
+ }
+
c->node->connection = NULL;
}
+ c->status.active = false;
+
if(c->edge) {
if(report) {
send_del_edge(mesh, mesh->everyone, c->edge, 0);
logger(mesh, MESHLINK_INFO, "Connection with %s activated", c->name);
+ if(mesh->meta_status_cb) {
+ mesh->meta_status_cb(mesh, (meshlink_node_t *)n, true);
+ }
+
/* Send him everything we know */
send_everything(mesh, c);