]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
fix crash when multiple links are sharing the same listener
authorFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 20 Dec 2012 19:16:59 +0000 (20:16 +0100)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 20 Dec 2012 19:16:59 +0000 (20:16 +0100)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libknet/link.c
libknet/listener.c
libknet/ping_test.c

index 90887ceea96607b2f931b63bd8a8ce08fc8baddf..c158e15447ddf1bd3ce640ffff5312fd6cbf59df 100644 (file)
@@ -95,7 +95,7 @@ int knet_link_enable(knet_handle_t knet_h, uint16_t node_id, uint8_t link_id, in
 
        err = _listener_remove(knet_h, lnk);
 
-       if ((err) && (err != -EBUSY)) {
+       if ((err) && (err != EBUSY)) {
                log_err(knet_h, KNET_SUB_LINK, "Unable to remove listener for this link");
                if (_link_updown(knet_h, node_id, lnk, 1, lnk->status.connected))
                        lnk->status.configured = 1;
index a4351ea4fad24398013896eaf667ddf67a4dec81..9a8242377ad7357b969c1cc6594a192254eca13c 100644 (file)
@@ -149,7 +149,8 @@ int _listener_remove(knet_handle_t knet_h, struct knet_link *lnk)
                }
        }
 
-       if (listener_cnt > 1) {
+       if (listener_cnt) {
+               lnk->listener_sock = 0;
                log_debug(knet_h, KNET_SUB_LISTENER, "listener_remove: listener still in use");
                ret = EBUSY;
                goto exit_unlock;
index 11f2824dda2508b15706ec8242933419ec03eddf..95910b87695006d747f3149b1991cdff47a8a95c 100644 (file)
@@ -17,6 +17,7 @@
 #include <signal.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
+#include <errno.h>
 
 #include "libknet.h"
 
@@ -190,22 +191,27 @@ static void sigint_handler(int signum)
        size_t host_ids_entries = 0;
        struct knet_link_status status;
 
-       printf("Cleaning up...\n");
+       printf("Cleaning up... got signal: %d\n", signum);
 
        if (knet_h != NULL) {
-               knet_host_get_host_list(knet_h, host_ids, &host_ids_entries);
+               if (knet_host_get_host_list(knet_h, host_ids, &host_ids_entries))
+                       printf("Unable to get host list: %s\n",strerror(errno));
+
                for (i = 0; i < host_ids_entries; i++) {
                        for (j = 0; j < KNET_MAX_LINK; j++) {
-                               knet_link_get_status(knet_h, host_ids[i], j, &status);
+                               if (knet_link_get_status(knet_h, host_ids[i], j, &status))
+                                       printf("Unable to get link data: %s\n",strerror(errno));
                                if (status.configured != 1) continue;
 
-                               knet_link_enable(knet_h, host_ids[i], j, 0);
+                               if (knet_link_enable(knet_h, host_ids[i], j, 0))
+                                       printf("Unable to remove link: %s\n",strerror(errno));
                        }
-                       knet_host_remove(knet_h, host_ids[i]);
+                       if (knet_host_remove(knet_h, host_ids[i]))
+                               printf("Unable to remove host: %s\n",strerror(errno));
                }
 
                if (knet_handle_free(knet_h)) {
-                       printf("Unable to cleanup before exit\n");
+                       printf("Unable to cleanup before exit: %s\n",strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }