cvs commit: ALFS/nALFS/src comm.c

kpfleming at linuxfromscratch.org kpfleming at linuxfromscratch.org
Fri Feb 27 20:44:06 PST 2004


kpfleming    04/02/27 21:44:06

  Modified:    nALFS/src comm.c
  Log:
  simplify control message sending code and eliminate extra copy of message content
  
  Revision  Changes    Path
  1.12      +5 -5      ALFS/nALFS/src/comm.c
  
  Index: comm.c
  ===================================================================
  RCS file: /home/cvsroot/ALFS/nALFS/src/comm.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- comm.c	24 Feb 2004 04:21:14 -0000	1.11
  +++ comm.c	28 Feb 2004 04:44:06 -0000	1.12
  @@ -374,7 +374,7 @@
   {
   	ssize_t ret;
   	va_list ap;
  -	char *full_message;
  +	char header[15];
   	int result;
   	char *buf;
   	int buf_size = 1024;
  @@ -404,13 +404,13 @@
   		}
   	}
   
  -	full_message = xmalloc(result + 15);
  +	/* header contains size of message (buf) plus type number and separators */
   	/* message size does _NOT_ include trailing null, as it is not sent by write() */
   	/* message size does _NOT_ include size prefix, or '|' separator */
  -	sprintf(full_message, "%08d|%04d|%s", result + 5, t, buf);
  +	sprintf(header, "%08d|%04d|", result + 5, t);
  +	ret = write(comm_get_socket(s), header, 14);
  +	ret = write(comm_get_socket(s), buf, result);
   	xfree(buf);
  -	ret = write(comm_get_socket(s), full_message, strlen(full_message));
  -	xfree(full_message);
   	if (ret == -1) {
   		Nprint_err("write() failed: %s", strerror(errno));
   		return -1;
  
  
  



More information about the alfs-log mailing list