[Spread-cvs] cvs commit: spread/daemon Changelog sp.c
jonathan at spread.org
jonathan at spread.org
Thu Apr 7 00:00:57 EDT 2005
jonathan 05/04/07 00:00:57
Modified: daemon 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
1.8 +5 -0 spread/daemon/Changelog
Index: Changelog
===================================================================
RCS file: /storage/cvsroot/spread/daemon/Changelog,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Changelog 7 Apr 2005 03:59:13 -0000 1.7
+++ Changelog 7 Apr 2005 04:00:57 -0000 1.8
@@ -1,3 +1,8 @@
+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.
+
Thu Dec 02 23:50:27 2004 Ryan Caudy <rcaudy at gmail.com>
* groups.c (G_build_groups_buf): Fix groups-state-exchange
1.16 +14 -7 spread/daemon/sp.c
Index: sp.c
===================================================================
RCS file: /storage/cvsroot/spread/daemon/sp.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- sp.c 29 Oct 2004 21:13:07 -0000 1.15
+++ sp.c 7 Apr 2005 04:00:57 -0000 1.16
@@ -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