cluster/group/gfs_controld main.c
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2006-08-31 18:46:24
Modified files:
group/gfs_controld: main.c
Log message:
tidy up a couple style things
group/gfs_controld/main.c +10 -16
@@ -89,8 +89,8 @@ {int i; -while (1 ) {/* I hate gotos */ -/* This is expected to fail the first time, with nothing allocated: */ +while (1 ) { +/* This fails the first time with client_size of zero */ for (i =0 ; i < client_size; i++) {if (client[i].fd ==-1 ) { client[i].fd = fd;
@@ -98,22 +98,25 @@ 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 )); + }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 ;
@@ -129,14 +132,6 @@ pollfd[ci].fd =-1 ; } -static void client_init (void ) -{ -int i; - -for (i =0 ; i < client_size; i++) - client[i].fd =-1 ; -} -int client_send (int ci,char *buf,int len) {return write (client[ci].fd, buf, len);
@@ -586,7 +581,6 @@ prog_name = argv[0 ];INIT_LIST_HEAD (&mounts);INIT_LIST_HEAD (&withdrawn_mounts); -client_init ();decode_arguments (argc, argv);