All of lore.kernel.org
 help / color / mirror / Atom feed
From: rpeterso@sourceware.org <rpeterso@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group daemon/main.c gfs_controld/main.c
Date: 31 Aug 2006 18:17:32 -0000	[thread overview]
Message-ID: <20060831181732.25853.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	rpeterso at sourceware.org	2006-08-31 18:17:32

Modified files:
	group/daemon   : main.c 
	group/gfs_controld: main.c 

Log message:
	This is a fix for Bugzilla Bug 203916: groupd daemon segfault and
	mount hang when mounting five or more GFS file systems.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/main.c.diff?cvsroot=cluster&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.10&r2=1.11

--- cluster/group/daemon/main.c	2006/07/13 21:28:45	1.40
+++ cluster/group/daemon/main.c	2006/08/31 18:17:32	1.41
@@ -25,8 +25,8 @@
 int			cman_quorate;
 
 static int client_maxi;
-static int client_size;
-static struct client *client;
+static int client_size = 0;
+static struct client *client = NULL;
 static struct pollfd *pollfd;
 static char last_action[16];
 
@@ -334,17 +334,25 @@
 
 	if (!client)
 		client = malloc(NALLOC * sizeof(struct client));
-	else
+	else {
 		client = realloc(client, (client_size + NALLOC) *
 				         sizeof(struct client));
+		pollfd = realloc(pollfd, (client_size + NALLOC) *
+						 sizeof(struct pollfd));
+		if (!pollfd)
+			log_print("can't alloc for pollfd");
+	}
 	if (!client)
 		log_print("can't alloc for client array");
 
 	for (i = client_size; i < client_size + NALLOC; i++) {
 		client[i].workfn = NULL;
+		client[i].deadfn = NULL;
 		client[i].fd = -1;
 		client[i].level = -1;
 		memset(client[i].type, 0, sizeof(client[i].type));
+		pollfd[i].fd = -1;
+		pollfd[i].revents = 0;
 	}
 	client_size += NALLOC;
 }
@@ -844,7 +852,7 @@
 	if (!groupd_debug_opt)
 		daemonize();
 
-	pollfd = malloc(MAXCON * sizeof(struct pollfd));
+	pollfd = malloc(NALLOC * sizeof(struct pollfd));
 	if (!pollfd)
 		return -1;
 
--- cluster/group/gfs_controld/main.c	2006/08/15 17:17:47	1.10
+++ cluster/group/gfs_controld/main.c	2006/08/31 18:17:32	1.11
@@ -20,9 +20,9 @@
 	char type[32];
 };
 
-static int client_size = MAX_CLIENTS;
-static struct client client[MAX_CLIENTS];
-static struct pollfd pollfd[MAX_CLIENTS];
+static int client_size = 0;
+static struct client *client = NULL;
+static struct pollfd *pollfd = NULL;
 
 static int cman_fd;
 static int cpg_fd;
@@ -89,19 +89,36 @@
 {
 	int i;
 
-	for (i = 0; i < client_size; i++) {
-		if (client[i].fd == -1) {
-			client[i].fd = fd;
-			pollfd[i].fd = fd;
-			pollfd[i].events = POLLIN;
-			if (i > *maxi)
-				*maxi = i;
-			/* log_debug("client %d fd %d added", i, fd); */
-			return i;
+	while (1) { /* I hate gotos */
+		/* This is expected to fail the first time, with nothing allocated: */
+		for (i = 0; i < client_size; i++) {
+			if (client[i].fd == -1) {
+				client[i].fd = fd;
+				pollfd[i].fd = fd;
+				pollfd[i].events = POLLIN;
+				if (i > *maxi)
+					*maxi = i;
+				/* log_debug("client %d fd %d added", i, fd); */
+				return i;
+			}
+		}
+		/* We didn't find an empty slot, so allocate more. */
+		client_size += MAX_CLIENTS;
+		if (!client) {
+			client = malloc(client_size * sizeof(struct client));
+			pollfd = malloc(client_size * sizeof(struct pollfd));
+		}
+		else {
+			client = realloc(client, client_size * sizeof(struct client));
+			pollfd = realloc(pollfd, client_size * sizeof(struct pollfd));
+		}
+		if (!client || !pollfd)
+			log_error("Can't allocate client memory.");
+		for (i = client_size - MAX_CLIENTS; i < client_size; i++) {
+			client[i].fd = -1;
+			pollfd[i].fd = -1;
 		}
 	}
-	log_debug("client add failed");
-	return -1;
 }
 
 static void client_dead(int ci)



                 reply	other threads:[~2006-08-31 18:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060831181732.25853.qmail@sourceware.org \
    --to=rpeterso@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.