[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/ccs/daemon cluster_mgr.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	fabbione sourceware org	2007-05-02 12:42:20

Modified files:
	ccs/daemon     : cluster_mgr.c 

Log message:
	When the project switched away from magma, we forgot to enable IPv6 for
	cluster_base_port.
	The patch fix that and add some checks that were marked as TODO in the code.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/daemon/cluster_mgr.c.diff?cvsroot=cluster&r1=1.24&r2=1.25

--- cluster/ccs/daemon/cluster_mgr.c	2006/12/14 21:00:10	1.24
+++ cluster/ccs/daemon/cluster_mgr.c	2007/05/02 12:42:19	1.25
@@ -375,35 +375,62 @@
   fd_set rset;
   cman_handle_t handle = NULL;
 
-  struct sockaddr_in sin;
+  struct sockaddr_storage addr;
+  struct sockaddr_in *addr4 = (struct sockaddr_in *)&addr;
+  struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *)&addr;
+  int addr_size=0;
 
   ENTER("cluster_communicator");
 
-  if ((ccsd_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
-    log_err("Unable to create socket.\n");
-    exit(EXIT_FAILURE);
+  memset(&addr, 0, sizeof(struct sockaddr_storage));
+
+  if (IPv6) {
+    if ((ccsd_fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0) {
+      if(IPv6 == -1) {
+	log_dbg("Unable to create IPv6 socket:: %s\n", strerror(errno));
+	IPv6=0;
+     }
+    }
   }
 
-  sin.sin_family = AF_INET;
-  sin.sin_port = htons(cluster_base_port);
-  sin.sin_addr.s_addr = htonl(INADDR_ANY);
+  if (!IPv6) {
+    if ((ccsd_fd = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
+      log_err("Unable to create IPv4 socket.\n");
+      exit(EXIT_FAILURE);
+    }
+  }
 
   if (setsockopt(ccsd_fd, SOL_SOCKET, SO_REUSEADDR, (void *)&opt, sizeof(opt)) < 0) {
-    /* Check the errno and exit ? */
+    log_sys_err("Unable to set socket option");
+    exit(EXIT_FAILURE);
+  }
+
+  if(IPv6){
+    addr_size = sizeof(struct sockaddr_in6);
+    addr6->sin6_family = AF_INET6;
+    addr6->sin6_addr = in6addr_any;
+    addr6->sin6_port = htons(cluster_base_port);
+  } else {
+    addr_size = sizeof(struct sockaddr_in);
+    addr4->sin_family = AF_INET;
+    addr4->sin_addr.s_addr = INADDR_ANY;
+    addr4->sin_port = htons(cluster_base_port);
   }
 
   flags = fcntl(ccsd_fd, F_GETFD, 0);
   flags |= FD_CLOEXEC;
   fcntl(ccsd_fd, F_SETFD, flags);
 
-  if (bind(ccsd_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+  if (bind(ccsd_fd, (struct sockaddr *)&addr, addr_size) < 0) {
     log_err("Unable to bind to socket.\n");
     close(ccsd_fd);
     exit(EXIT_FAILURE);
   }
 
   if (listen(ccsd_fd, 15) < 0) {
-    /* Check the errno and exit ? */
+    log_err("Unable to listen to socket.\n");
+    close(ccsd_fd);
+    exit(EXIT_FAILURE);
   }
 
 restart:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]