[Cluster-devel] cluster/group/gfs_controld main.c

teigland at sourceware.org teigland at sourceware.org
Fri Oct 6 14:43:59 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2006-10-06 14:43:59

Modified files:
	group/gfs_controld: main.c 

Log message:
	make the number of clients a global variable so it will be easier
	to add clients later

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.14&r2=1.15

--- cluster/group/gfs_controld/main.c	2006/09/08 22:44:33	1.14
+++ cluster/group/gfs_controld/main.c	2006/10/06 14:43:58	1.15
@@ -20,6 +20,7 @@
 	char type[32];
 };
 
+static int client_maxi;
 static int client_size = 0;
 static struct client *client = NULL;
 static struct pollfd *pollfd = NULL;
@@ -107,7 +108,7 @@
 	return rp;
 }
 
-static int client_add(int fd, int *maxi)
+static int client_add(int fd)
 {
 	int i;
 
@@ -118,8 +119,8 @@
 				client[i].fd = fd;
 				pollfd[i].fd = fd;
 				pollfd[i].events = POLLIN;
-				if (i > *maxi)
-					*maxi = i;
+				if (i > client_maxi)
+					client_maxi = i;
 				return i;
 			}
 		}
@@ -380,42 +381,42 @@
 
 int loop(void)
 {
-	int rv, i, f, maxi = 0;
+	int rv, i, f;
 
 	rv = listen_fd = setup_listen();
 	if (rv < 0)
 		goto out;
-	client_add(listen_fd, &maxi);
+	client_add(listen_fd);
 
 	rv = cman_fd = setup_cman();
 	if (rv < 0)
 		goto out;
-	client_add(cman_fd, &maxi);
+	client_add(cman_fd);
 
 	rv = cpg_fd = setup_cpg();
 	if (rv < 0)
 		goto out;
-	client_add(cpg_fd, &maxi);
+	client_add(cpg_fd);
 
 	rv = groupd_fd = setup_groupd();
 	if (rv < 0)
 		goto out;
-	client_add(groupd_fd, &maxi);
+	client_add(groupd_fd);
 
 	rv = uevent_fd = setup_uevent();
 	if (rv < 0)
 		goto out;
-	client_add(uevent_fd, &maxi);
+	client_add(uevent_fd);
 
 	rv = plocks_fd = setup_plocks();
 	if (rv < 0)
 		goto out;
-	client_add(plocks_fd, &maxi);
+	client_add(plocks_fd);
 
 	log_debug("setup done");
 
 	for (;;) {
-		rv = poll(pollfd, maxi + 1, -1);
+		rv = poll(pollfd, client_maxi + 1, -1);
 		if (rv < 0)
 			log_error("poll error %d errno %d", rv, errno);
 
@@ -426,10 +427,10 @@
 			if (f < 0)
 				log_debug("accept error %d %d", f, errno);
 			else
-				client_add(f, &maxi);
+				client_add(f);
 		}
 
-		for (i = 1; i <= maxi; i++) {
+		for (i = 1; i <= client_maxi; i++) {
 			if (client[i].fd < 0)
 				continue;
 




More information about the Cluster-devel mailing list