]> git.meshlink.io Git - meshlink/blobdiff - src/devtools.c
Don't use assert() to check the results of pthread_*() calls.
[meshlink] / src / devtools.c
index fab0c72019325ad4e893207305c2fc71abf81e94..22a0818b559b3e6f291a3e27e36531e4a305071e 100644 (file)
@@ -30,7 +30,7 @@
 
 #include "devtools.h"
 
-static void trybind_nop_probe(void) {
+static void nop_probe(void) {
        return;
 }
 
@@ -39,8 +39,21 @@ static void keyrotate_nop_probe(int stage) {
        return;
 }
 
-void (*devtool_trybind_probe)(void) = trybind_nop_probe;
+static void inviter_commits_first_nop_probe(bool stage) {
+       (void)stage;
+       return;
+}
+
+static void sptps_renewal_nop_probe(meshlink_node_t *node) {
+       (void)node;
+       return;
+}
+
+void (*devtool_trybind_probe)(void) = nop_probe;
 void (*devtool_keyrotate_probe)(int stage) = keyrotate_nop_probe;
+void (*devtool_set_inviter_commits_first)(bool inviter_commited_first) = inviter_commits_first_nop_probe;
+void (*devtool_adns_resolve_probe)(void) = nop_probe;
+void (*devtool_sptps_renewal_probe)(meshlink_node_t *node) = sptps_renewal_nop_probe;
 
 /* Return an array of edges in the current network graph.
  * Data captures the current state and will not be updated.
@@ -52,7 +65,9 @@ devtool_edge_t *devtool_get_all_edges(meshlink_handle_t *mesh, devtool_edge_t *e
                return NULL;
        }
 
-       pthread_mutex_lock(&mesh->mutex);
+       if(pthread_mutex_lock(&mesh->mutex) != 0) {
+               abort();
+       }
 
        devtool_edge_t *result = NULL;
        unsigned int result_size = 0;
@@ -72,7 +87,7 @@ devtool_edge_t *devtool_get_all_edges(meshlink_handle_t *mesh, devtool_edge_t *e
 
                for splay_each(edge_t, e, mesh->edges) {
                        // skip edges that do not represent a two-directional connection
-                       if((!e->reverse) || (e->reverse->to != e->from)) {
+                       if(!e->reverse || e->reverse->to != e->from) {
                                continue;
                        }
 
@@ -122,7 +137,9 @@ bool devtool_export_json_all_edges_state(meshlink_handle_t *mesh, FILE *stream)
 
        bool result = true;
 
-       pthread_mutex_lock(&mesh->mutex);
+       if(pthread_mutex_lock(&mesh->mutex) != 0) {
+               abort();
+       }
 
        // export edges and nodes
        size_t node_count = 0;
@@ -250,7 +267,9 @@ void devtool_get_node_status(meshlink_handle_t *mesh, meshlink_node_t *node, dev
 
        node_t *internal = (node_t *)node;
 
-       pthread_mutex_lock(&mesh->mutex);
+       if(pthread_mutex_lock(&mesh->mutex) != 0) {
+               abort();
+       }
 
        memcpy(&status->status, &internal->status, sizeof status->status);
        memcpy(&status->address, &internal->address, sizeof status->address);
@@ -292,7 +311,9 @@ meshlink_submesh_t **devtool_get_all_submeshes(meshlink_handle_t *mesh, meshlink
        meshlink_submesh_t **result;
 
        //lock mesh->nodes
-       pthread_mutex_lock(&mesh->mutex);
+       if(pthread_mutex_lock(&mesh->mutex) != 0) {
+               abort();
+       }
 
        *nmemb = mesh->submeshes->count;
        result = realloc(submeshes, *nmemb * sizeof(*submeshes));
@@ -330,3 +351,19 @@ meshlink_handle_t *devtool_open_in_netns(const char *confbase, const char *name,
 
        return handle;
 }
+
+void devtool_force_sptps_renewal(meshlink_handle_t *mesh, meshlink_node_t *node) {
+       if(!mesh || !node) {
+               meshlink_errno = MESHLINK_EINVAL;
+               return;
+       }
+
+       node_t *n = (node_t *)node;
+       connection_t *c = n->connection;
+
+       n->last_req_key = -3600;
+
+       if(c) {
+               c->last_key_renewal = -3600;
+       }
+}