* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-11-20 22:54 rpeterso
0 siblings, 0 replies; 8+ messages in thread
From: rpeterso @ 2006-11-20 22:54 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL50
Changes by: rpeterso at sourceware.org 2006-11-20 22:54:23
Modified files:
group/lib : libgroup.c
Log message:
if read() returns a non-EINTR error then abort
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.24&r2=1.24.4.1
--- cluster/group/lib/libgroup.c 2006/10/24 15:11:20 1.24
+++ cluster/group/lib/libgroup.c 2006/11/20 22:54:23 1.24.4.1
@@ -176,6 +176,8 @@
return -1;
if (rv == -1 && errno == EINTR)
continue;
+ if (rv == -1)
+ return -1;
off += rv;
}
return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cluster-devel] cluster/group/lib libgroup.c
@ 2007-10-26 20:41 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2007-10-26 20:41 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2007-10-26 20:41:58
Modified files:
group/lib : libgroup.c
Log message:
include ctype.h to sync with HEAD
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24.2.2&r2=1.24.2.3
--- cluster/group/lib/libgroup.c 2007/10/26 20:34:41 1.24.2.2
+++ cluster/group/lib/libgroup.c 2007/10/26 20:41:58 1.24.2.3
@@ -30,6 +30,7 @@
#include <netinet/in.h>
#include <string.h>
#include <errno.h>
+#include <ctype.h>
#include "groupd.h"
#include "libgroup.h"
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cluster-devel] cluster/group/lib libgroup.c
@ 2007-04-30 16:56 fabbione
0 siblings, 0 replies; 8+ messages in thread
From: fabbione @ 2007-04-30 16:56 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: fabbione at sourceware.org 2007-04-30 17:56:22
Modified files:
group/lib : libgroup.c
Log message:
Remove unused vars
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&r1=1.26&r2=1.27
--- cluster/group/lib/libgroup.c 2007/04/30 11:22:20 1.26
+++ cluster/group/lib/libgroup.c 2007/04/30 16:56:22 1.27
@@ -379,7 +379,7 @@
{
char buf[GROUPD_MSGLEN], *argv[MAXARGS];
char *p;
- int act, argc, rv, i, count, *nodeids;
+ int act, argc, rv, count, *nodeids;
struct group_handle *h = (struct group_handle *) handle;
VALIDATE_HANDLE(h);
@@ -495,7 +495,7 @@
{
char buf[GROUPD_MSGLEN];
char data_buf[sizeof(group_data_t)];
- int fd, rv, len;
+ int fd, rv;
fd = connect_groupd();
if (fd < 0)
^ permalink raw reply [flat|nested] 8+ messages in thread* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-11-17 16:30 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2006-11-17 16:30 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: teigland at sourceware.org 2006-11-17 16:30:45
Modified files:
group/lib : libgroup.c
Log message:
if read() returns a non-EINTR error then abort
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.24&r2=1.24.2.1
--- cluster/group/lib/libgroup.c 2006/10/24 15:11:20 1.24
+++ cluster/group/lib/libgroup.c 2006/11/17 16:30:45 1.24.2.1
@@ -176,6 +176,8 @@
return -1;
if (rv == -1 && errno == EINTR)
continue;
+ if (rv == -1)
+ return -1;
off += rv;
}
return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-11-17 16:30 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2006-11-17 16:30 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-11-17 16:30:20
Modified files:
group/lib : libgroup.c
Log message:
if read() returns a non-EINTR error then abort
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&r1=1.24&r2=1.25
--- cluster/group/lib/libgroup.c 2006/10/24 15:11:20 1.24
+++ cluster/group/lib/libgroup.c 2006/11/17 16:30:19 1.25
@@ -176,6 +176,8 @@
return -1;
if (rv == -1 && errno == EINTR)
continue;
+ if (rv == -1)
+ return -1;
off += rv;
}
return 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-10-24 15:11 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2006-10-24 15:11 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-10-24 15:11:20
Modified files:
group/lib : libgroup.c
Log message:
clean up gross code
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&r1=1.23&r2=1.24
--- cluster/group/lib/libgroup.c 2006/10/21 17:15:12 1.23
+++ cluster/group/lib/libgroup.c 2006/10/24 15:11:20 1.24
@@ -297,23 +297,24 @@
for (i = 0; !timeout || i < timeout * 2; i++) {
h->fd = connect_groupd();
- if (h->fd > 0 || !timeout) /* if successful or only once allowed */
+ if (h->fd > 0 || !timeout)
break;
usleep(500000);
}
- if (h->fd > 0) {
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "setup %s %d", prog_name, level);
-
- for (; !timeout || i < timeout * 2; i++) {
- rv = do_write(h->fd, &buf, GROUPD_MSGLEN);
- if (rv >= 0)
- return (group_handle_t) h;
- if (!timeout)
- break;
- usleep(500000);
- }
- }
+
+ if (h->fd <= 0)
+ goto fail;
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "setup %s %d", prog_name, level);
+
+ rv = do_write(h->fd, &buf, GROUPD_MSGLEN);
+ if (rv < 0)
+ goto fail;
+
+ return (group_handle_t) h;
+
+ fail:
saved_errno = errno;
close(h->fd);
free(h);
@@ -446,35 +447,43 @@
return rv;
}
-int group_get_groups(int max, int *count, group_data_t *data)
+int group_get_groups(int max, int *count, group_data_t *data)
{
char buf[GROUPD_MSGLEN];
- group_data_t empty;
+ group_data_t dbuf, empty;
int fd, rv;
+ *count = 0;
+
fd = connect_groupd();
if (fd < 0)
return fd;
- memset(&empty, 0, sizeof(empty));
memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf), "get_groups %d", max);
rv = do_write(fd, &buf, GROUPD_MSGLEN);
- *count = 0;
- if (!rv) {
- while (1) {
- rv = read(fd, &data[*count], sizeof(group_data_t));
- /* a blank data struct is returned when there are none */
- if (rv <= 0 || (rv == sizeof(group_data_t) &&
- !memcmp(&data[*count], &empty, rv))) {
- rv = 0;
- break;
- }
- else
- (*count)++;
+ if (rv < 0)
+ goto out;
+
+ memset(&empty, 0, sizeof(empty));
+
+ while (1) {
+ memset(&dbuf, 0, sizeof(dbuf));
+
+ rv = do_read(fd, &dbuf, sizeof(group_data_t));
+ if (rv < 0)
+ break;
+
+ if (!memcmp(&dbuf, &empty, sizeof(group_data_t))) {
+ rv = 0;
+ break;
+ } else {
+ memcpy(&data[*count], &dbuf, sizeof(group_data_t));
+ (*count)++;
}
}
+ out:
close(fd);
return rv;
}
@@ -506,3 +515,4 @@
close(fd);
return rv;
}
+
^ permalink raw reply [flat|nested] 8+ messages in thread* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-10-13 17:15 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2006-10-13 17:15 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-10-13 17:15:26
Modified files:
group/lib : libgroup.c
Log message:
replace spaces with tabs
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&r1=1.21&r2=1.22
--- cluster/group/lib/libgroup.c 2006/10/13 16:03:48 1.21
+++ cluster/group/lib/libgroup.c 2006/10/13 17:15:26 1.22
@@ -482,28 +482,28 @@
int group_get_group(int level, const char *name, group_data_t *data)
{
- char buf[GROUPD_MSGLEN];
- char data_buf[sizeof(group_data_t)];
- int fd, rv, len;
-
- fd = connect_groupd();
- if (fd < 0)
- return fd;
-
- memset(buf, 0, sizeof(buf));
- snprintf(buf, sizeof(buf), "get_group %d %s", level, name);
-
- rv = do_write(fd, &buf, GROUPD_MSGLEN);
- if (rv < 0)
- goto out;
-
- rv = do_read(fd, &data_buf, sizeof(data_buf));
- if (rv < 0)
- goto out;
+ char buf[GROUPD_MSGLEN];
+ char data_buf[sizeof(group_data_t)];
+ int fd, rv, len;
+
+ fd = connect_groupd();
+ if (fd < 0)
+ return fd;
+
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf), "get_group %d %s", level, name);
+
+ rv = do_write(fd, &buf, GROUPD_MSGLEN);
+ if (rv < 0)
+ goto out;
+
+ rv = do_read(fd, &data_buf, sizeof(data_buf));
+ if (rv < 0)
+ goto out;
- memcpy(data, data_buf, sizeof(group_data_t));
- rv = 0;
+ memcpy(data, data_buf, sizeof(group_data_t));
+ rv = 0;
out:
- close(fd);
- return rv;
+ close(fd);
+ return rv;
}
^ permalink raw reply [flat|nested] 8+ messages in thread* [Cluster-devel] cluster/group/lib libgroup.c
@ 2006-09-07 19:24 teigland
0 siblings, 0 replies; 8+ messages in thread
From: teigland @ 2006-09-07 19:24 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-09-07 19:24:08
Modified files:
group/lib : libgroup.c
Log message:
handle short or interrupted reads/writes, an snprintf instead of sprintf,
strtoul instead of atoi, handle an ENOMEM
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/lib/libgroup.c.diff?cvsroot=cluster&r1=1.19&r2=1.20
--- cluster/group/lib/libgroup.c 2006/02/28 20:31:27 1.19
+++ cluster/group/lib/libgroup.c 2006/09/07 19:24:08 1.20
@@ -88,7 +88,7 @@
return rp;
}
-void get_nodeids(char *buf, int memb_count, int *nodeids)
+static void get_nodeids(char *buf, int memb_count, int *nodeids)
{
char *p;
int i, count = 0;
@@ -112,7 +112,7 @@
}
}
-int get_action(char *buf)
+static int get_action(char *buf)
{
char act[16];
int i;
@@ -151,15 +151,32 @@
{
int rv, off = 0;
- again:
+ retry:
rv = write(fd, buf + off, count);
+ if (rv == -1 && errno == EINTR)
+ goto retry;
if (rv < 0)
return rv;
if (rv != count) {
count -= rv;
off += rv;
- goto again;
+ goto retry;
+ }
+ return 0;
+}
+
+static int do_read(int fd, void *buf, size_t count)
+{
+ int rv, off = 0;
+
+ while (off < count) {
+ rv = read(fd, buf + off, count - off);
+ if (rv == 0)
+ return -1;
+ if (rv == -1 && errno == EINTR)
+ continue;
+ off += rv;
}
return 0;
}
@@ -231,7 +248,7 @@
return -EINVAL;
memset(buf, 0, sizeof(buf));
- rv = sprintf(buf, "send %s %d", name, len);
+ rv = snprintf(buf, sizeof(buf), "send %s %d", name, len);
memcpy(buf + rv + 1, data, len);
return do_write(h->fd, buf, GROUPD_MSGLEN);
@@ -359,8 +376,8 @@
memset(buf, 0, sizeof(buf));
- rv = read(h->fd, &buf, GROUPD_MSGLEN);
- if (rv != GROUPD_MSGLEN)
+ rv = do_read(h->fd, &buf, GROUPD_MSGLEN);
+ if (rv < 0)
goto out;
act = get_action(buf);
@@ -378,6 +395,10 @@
count = atoi(argv[4]);
nodeids = malloc(count * sizeof(int));
+ if (!nodeids) {
+ rv = -ENOMEM;
+ goto out;
+ }
get_nodeids(p, count, nodeids);
h->cbs.start(h, h->private, argv[1], atoi(argv[2]),
@@ -403,9 +424,8 @@
case DO_SET_ID:
get_args(buf, &argc, argv, ' ', 3);
- /* FIXME: id is unsigned, use strtoul() here */
-
- h->cbs.set_id(h, h->private, argv[1], atoi(argv[2]));
+ h->cbs.set_id(h, h->private, argv[1],
+ (unsigned int) strtoul(argv[2], NULL, 10));
break;
case DO_DELIVER:
@@ -472,9 +492,9 @@
if (rv < 0)
goto out;
- rv = read(fd, &data_buf, sizeof(data_buf));
-
- /* FIXME: check rv */
+ rv = do_read(fd, &data_buf, sizeof(data_buf));
+ if (rv < 0)
+ goto out;
memcpy(data, data_buf, sizeof(group_data_t));
rv = 0;
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2007-10-26 20:41 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-20 22:54 [Cluster-devel] cluster/group/lib libgroup.c rpeterso
-- strict thread matches above, loose matches on Subject: below --
2007-10-26 20:41 teigland
2007-04-30 16:56 fabbione
2006-11-17 16:30 teigland
2006-11-17 16:30 teigland
2006-10-24 15:11 teigland
2006-10-13 17:15 teigland
2006-09-07 19:24 teigland
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).