* [Cluster-devel] cluster/group daemon/main.c gfs_controld/main.c
@ 2006-08-31 18:17 rpeterso
0 siblings, 0 replies; only message in thread
From: rpeterso @ 2006-08-31 18:17 UTC (permalink / raw)
To: cluster-devel.redhat.com
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-31 18:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-31 18:17 [Cluster-devel] cluster/group daemon/main.c gfs_controld/main.c rpeterso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).