From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group daemon/gd_internal.h daemon/main ...
Date: 13 Jul 2006 21:28:47 -0000 [thread overview]
Message-ID: <20060713212847.24677.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-07-13 21:28:45
Modified files:
group/daemon : gd_internal.h main.c
group/dlm_controld: dlm_daemon.h main.c
group/gfs_controld: lock_dlm.h main.c
Log message:
- memset to 0 arrays of arg pointers
- tighten up the splitting of strings into arg arrays
- reduce the size of the arg pointer arrays since we now know the max
number of args we're splitting out
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/gd_internal.h.diff?cvsroot=cluster&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/main.c.diff?cvsroot=cluster&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/dlm_daemon.h.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/main.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/lock_dlm.h.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/gfs_controld/main.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
--- cluster/group/daemon/gd_internal.h 2006/06/30 15:29:17 1.37
+++ cluster/group/daemon/gd_internal.h 2006/07/13 21:28:45 1.38
@@ -43,7 +43,7 @@
#define MAX_NAMELEN (32) /* should match libgroup.h */
#define MAX_LEVELS (4)
#define MAX_NODES (256)
-#define MAXARGS (32)
+#define MAXARGS (16)
#define MAXCON (16)
#define NALLOC (16)
#define DUMP_SIZE (1024 * 1024)
--- cluster/group/daemon/main.c 2006/07/13 18:21:35 1.39
+++ cluster/group/daemon/main.c 2006/07/13 21:28:45 1.40
@@ -538,6 +538,7 @@
int argc = 0, rv, act;
memset(buf, 0, sizeof(buf));
+ memset(argv, 0, sizeof(char *) * MAXARGS);
rv = read(client[ci].fd, buf, GROUPD_MSGLEN);
if (!rv) {
--- cluster/group/dlm_controld/dlm_daemon.h 2006/06/09 20:59:57 1.1
+++ cluster/group/dlm_controld/dlm_daemon.h 2006/07/13 21:28:45 1.2
@@ -44,7 +44,7 @@
#include "list.h"
#include "libgroup.h"
-#define MAXARGS 64
+#define MAXARGS 8
#define MAXLINE 256
#define MAXCON 4
#define MAXNAME 255
--- cluster/group/dlm_controld/main.c 2006/07/13 19:49:02 1.2
+++ cluster/group/dlm_controld/main.c 2006/07/13 21:28:45 1.3
@@ -48,6 +48,7 @@
return NULL;
}
+#if 0
void make_args(char *buf, int *argc, char **argv, char sep)
{
char *p = buf;
@@ -65,6 +66,38 @@
}
*argc = i;
}
+#endif
+
+static char *get_args(char *buf, int *argc, char **argv, char sep, int want)
+{
+ char *p = buf, *rp = NULL;
+ int i;
+
+ argv[0] = p;
+
+ for (i = 1; i < MAXARGS; i++) {
+ p = strchr(buf, sep);
+ if (!p)
+ break;
+ *p = '\0';
+
+ if (want == i) {
+ rp = p + 1;
+ break;
+ }
+
+ argv[i] = p + 1;
+ buf = p + 1;
+ }
+ *argc = i;
+
+ /* we ended by hitting \0, return the point following that */
+ if (!rp)
+ rp = strchr(buf, '\0') + 1;
+
+ return rp;
+}
+
/* recv "online" (join) and "offline" (leave)
messages from dlm via uevents and pass them on to groupd */
@@ -77,6 +110,7 @@
int rv, argc = 0;
memset(buf, 0, sizeof(buf));
+ memset(argv, 0, sizeof(char *) * MAXARGS);
rv = recv(uevent_fd, &buf, sizeof(buf), 0);
if (rv < 0) {
@@ -89,7 +123,9 @@
log_debug("uevent: %s", buf);
- make_args(buf, &argc, argv, '/');
+ get_args(buf, &argc, argv, '/', 4);
+ if (argc != 4)
+ log_error("uevent message has %d args", argc);
act = argv[0];
sys = argv[2];
@@ -291,9 +327,9 @@
printf("\n");
printf("Options:\n");
printf("\n");
- printf(" -D Enable debugging code and don't fork\n");
- printf(" -h Print this help, then exit\n");
- printf(" -V Print program version information, then exit\n");
+ printf(" -D Enable debugging code and don't fork\n");
+ printf(" -h Print this help, then exit\n");
+ printf(" -V Print program version information, then exit\n");
}
static void decode_arguments(int argc, char **argv)
--- cluster/group/gfs_controld/lock_dlm.h 2006/06/15 20:41:46 1.3
+++ cluster/group/gfs_controld/lock_dlm.h 2006/07/13 21:28:45 1.4
@@ -37,7 +37,7 @@
#include "linux_endian.h"
#include "libgroup.h"
-#define MAXARGS 64
+#define MAXARGS 16
#define MAXLINE 256
#define MAXNAME 255
#define MAX_CLIENTS 8
--- cluster/group/gfs_controld/main.c 2006/06/15 20:41:46 1.3
+++ cluster/group/gfs_controld/main.c 2006/07/13 21:28:45 1.4
@@ -35,6 +35,7 @@
extern struct list_head withdrawn_mounts;
int no_withdraw;
+#if 0
static void make_args(char *buf, int *argc, char **argv, char sep)
{
char *p = buf;
@@ -52,6 +53,37 @@
}
*argc = i;
}
+#endif
+
+static char *get_args(char *buf, int *argc, char **argv, char sep, int want)
+{
+ char *p = buf, *rp = NULL;
+ int i;
+
+ argv[0] = p;
+
+ for (i = 1; i < MAXARGS; i++) {
+ p = strchr(buf, sep);
+ if (!p)
+ break;
+ *p = '\0';
+
+ if (want == i) {
+ rp = p + 1;
+ break;
+ }
+
+ argv[i] = p + 1;
+ buf = p + 1;
+ }
+ *argc = i;
+
+ /* we ended by hitting \0, return the point following that */
+ if (!rp)
+ rp = strchr(buf, '\0') + 1;
+
+ return rp;
+}
static int client_add(int fd, int *maxi)
{
@@ -102,6 +134,7 @@
cmd = dir = type = proto = table = extra = NULL;
memset(buf, 0, MAXLINE);
memset(out, 0, MAXLINE);
+ memset(argv, 0, sizeof(char *) * MAXARGS);
rv = read(client[ci].fd, buf, MAXLINE);
if (!rv) {
@@ -116,7 +149,7 @@
log_debug("client %d: %s", ci, buf);
- make_args(buf, &argc, argv, ' ');
+ get_args(buf, &argc, argv, ' ', 6);
cmd = argv[0];
dir = argv[1];
type = argv[2];
@@ -184,6 +217,7 @@
int rv, argc = 0;
memset(buf, 0, sizeof(buf));
+ memset(argv, 0, sizeof(char *) * MAXARGS);
rv = recv(uevent_fd, &buf, sizeof(buf), 0);
if (rv < 0) {
@@ -194,7 +228,9 @@
if (!strstr(buf, "gfs") || !strstr(buf, "lock_module"))
return 0;
- make_args(buf, &argc, argv, '/');
+ get_args(buf, &argc, argv, '/', 4);
+ if (argc != 4)
+ log_error("uevent message has %d args", argc);
act = argv[0];
log_debug("kernel: %s %s", act, argv[3]);
@@ -286,7 +322,7 @@
log_debug("accept error %d %d", f, errno);
else
client_add(f, &maxi);
- }
+ }
for (i = 1; i <= maxi; i++) {
if (client[i].fd < 0)
@@ -389,9 +425,9 @@
printf("\n");
printf("Options:\n");
printf("\n");
- printf(" -D Enable debugging code and don't fork\n");
- printf(" -h Print this help, then exit\n");
- printf(" -V Print program version information, then exit\n");
+ printf(" -D Enable debugging code and don't fork\n");
+ printf(" -h Print this help, then exit\n");
+ printf(" -V Print program version information, then exit\n");
}
static void decode_arguments(int argc, char **argv)
reply other threads:[~2006-07-13 21:28 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=20060713212847.24677.qmail@sourceware.org \
--to=teigland@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.