]> git.meshlink.io Git - meshlink/commitdiff
Check the return value of catta_simple_poll_get().
authorGuus Sliepen <guus@meshlink.io>
Mon, 25 Jan 2021 20:00:47 +0000 (21:00 +0100)
committerGuus Sliepen <guus@meshlink.io>
Mon, 25 Jan 2021 20:00:47 +0000 (21:00 +0100)
This ensures we gracefully handle the case of Catta not being able to bind
to the NETLINK_ROUTE socket.

catta
src/discovery.c

diff --git a/catta b/catta
index bb142eb202fda78982305d8aeffc4ae5c16ab1ae..070b95d769cbcbdf0113437a0db92777765474ea 160000 (submodule)
--- a/catta
+++ b/catta
@@ -1 +1 @@
-Subproject commit bb142eb202fda78982305d8aeffc4ae5c16ab1ae
+Subproject commit 070b95d769cbcbdf0113437a0db92777765474ea
index e144c286cbafcefac637b2bbeff50b5e3fa06be7..2ac69b36fd07580a8369fdbcda7b5cd60b63e3da 100644 (file)
@@ -418,7 +418,14 @@ static void *discovery_loop(void *userdata) {
 
        /* Allocate a new server */
        int error;
-       mesh->catta_server = catta_server_new(catta_simple_poll_get(mesh->catta_poll), &config, discovery_server_callback, mesh, &error);
+       const CattaPoll *poller = catta_simple_poll_get(mesh->catta_poll);
+
+       if(!poller) {
+               logger(mesh, MESHLINK_ERROR, "Failed to create discovery server: %s\n", catta_strerror(error));
+               goto fail;
+       }
+
+       mesh->catta_server = catta_server_new(poller, &config, discovery_server_callback, mesh, &error);
 
        /* Free the configuration data */
        catta_server_config_free(&config);