[Spread-cvs] cvs commit: spread/daemon Changelog sp.c

jonathan at spread.org jonathan at spread.org
Fri Apr 1 08:21:35 EST 2005


jonathan    05/04/01 08:21:34

  Modified:    daemon   Tag: branch_3_17 Changelog sp.c
  Log:
  Check for short writes on network socket sends in libsp and loop to finish full write.
  Bug reported by Tudor Dumitras.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.3   +6 -0      spread/daemon/Changelog
  
  Index: Changelog
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/Changelog,v
  retrieving revision 1.4.2.2
  retrieving revision 1.4.2.3
  diff -u -r1.4.2.2 -r1.4.2.3
  --- Changelog	29 Oct 2004 17:35:56 -0000	1.4.2.2
  +++ Changelog	1 Apr 2005 13:21:34 -0000	1.4.2.3
  @@ -1,3 +1,9 @@
  +Thu Mar 31 23:44:04 2005  Jonathan Stanton  <jonathan at cnds.jhu.edu>
  + 
  +       * sp.c (SP_internal_multicast): Check for short writes on network 
  +       socket sends and loop to finish full write. Bug reported by Tudor 
  +       Dumitras.
  +
   Fri Oct 29 13:24:53 2004  Jonathan Stanton  <jonathan at cnds.jhu.edu>
   
   	* monitor.c (main): Move WSAStartup before Conf_init. Reported
  
  
  
  1.14.2.1  +14 -7     spread/daemon/sp.c
  
  Index: sp.c
  ===================================================================
  RCS file: /storage/cvsroot/spread/daemon/sp.c,v
  retrieving revision 1.14
  retrieving revision 1.14.2.1
  diff -u -r1.14 -r1.14.2.1
  --- sp.c	5 Oct 2004 14:08:10 -0000	1.14
  +++ sp.c	1 Apr 2005 13:21:34 -0000	1.14.2.1
  @@ -975,6 +975,7 @@
   	int		mess_len, len;
   	int		ses;
   	int		i;
  +        int             buf_len;
   	int		ret;
   
           /* zero head_buf to avoid information leakage */
  @@ -1019,19 +1020,24 @@
   	memcpy( group_ptr, groups, MAX_GROUP_NAME * num_groups );
   
   	Mutex_lock( &Mbox_mutex[mbox&MAX_MUTEX_MASK][0] );
  -	while(((ret=send( mbox, head_buf, sizeof(message_header)+MAX_GROUP_NAME*num_groups, 0 )) == -1) 
  -              && ((sock_errno == EINTR) || (sock_errno == EAGAIN) || (sock_errno == EWOULDBLOCK)) )
  +        for ( buf_len = 0; buf_len < sizeof(message_header)+MAX_GROUP_NAME*num_groups; buf_len += ret) 
  +        {
  +            while(((ret=send( mbox, &head_buf[buf_len], sizeof(message_header)+MAX_GROUP_NAME*num_groups - buf_len, 0 )) == -1) 
  +                  && ((sock_errno == EINTR) || (sock_errno == EAGAIN) || (sock_errno == EWOULDBLOCK)) )
                   ;
  -	if( ret <=0 )
  -	{
  +            if( ret <=0 )
  +            {
   		Alarm( SESSION, "SP_internal_multicast: error %d sending header and groups on mailbox %d: %s \n", ret, mbox, sock_strerror(sock_errno));
   		Mutex_unlock( &Mbox_mutex[mbox&MAX_MUTEX_MASK][0] );
   		SP_kill( mbox );
   		return( CONNECTION_CLOSED );
  -	}
  -	for( len=0, i=0; i < scat_mess->num_elements; len+=ret, i++ )
  +            }
  +        }
  +	for( len=0, i=0; i < scat_mess->num_elements; len+=buf_len, i++ )
   	{
  -		while(((ret=send( mbox, scat_mess->elements[i].buf, scat_mess->elements[i].len, 0 )) == -1)
  +            for ( buf_len = 0; buf_len < scat_mess->elements[i].len; buf_len += ret) 
  +            {
  +		while(((ret=send( mbox, &scat_mess->elements[i].buf[buf_len], scat_mess->elements[i].len - buf_len, 0 )) == -1)
                         && ((sock_errno == EINTR) || (sock_errno == EAGAIN) || (sock_errno == EWOULDBLOCK)) )
                           ;
   		if( ret < 0 )
  @@ -1041,6 +1047,7 @@
   			SP_kill( mbox );
   			return( CONNECTION_CLOSED );
   		}
  +            }
   	}
   	Mutex_unlock( &Mbox_mutex[mbox&MAX_MUTEX_MASK][0] );
   	return( len );
  
  
  



More information about the Spread-cvs mailing list