[Pvfs2-cvs] commit by slang in pvfs2/src/io/bmi/bmi_tcp: bmi-tcp.c
sockio.c
CVS commit program
cvs at parl.clemson.edu
Tue Oct 16 16:54:42 EDT 2007
Update of /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp
In directory parlweb1:/tmp/cvs-serv25077/src/io/bmi/bmi_tcp
Modified Files:
bmi-tcp.c sockio.c
Log Message:
switching from the blocking receive (where we had just done a peek) to the non-blocking receive didn't work perfectly since new connections weren't getting set to nonblocking after accept (it looks like this is why blocking receive was used in the first place). The fix here sets the new socket to nonblocking and adds some asserts to make sure that sockets passed to nbpeek and nbrecv are nonblocking already. Thanks to Kevin for helping debug this one.
Index: bmi-tcp.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/bmi-tcp.c,v
diff -p -u -r1.118 -r1.119
--- bmi-tcp.c 9 Oct 2007 21:58:31 -0000 1.118
+++ bmi-tcp.c 16 Oct 2007 20:54:41 -0000 1.119
@@ -3497,6 +3497,7 @@ static int tcp_accept_init(int *socket,
int ret = -1;
int tmp_errno = 0;
struct tcp_addr *tcp_addr_data = tcp_method_params.listen_addr->method_data;
+ int oldfl = 0;
struct sockaddr_in peer_sockaddr;
int peer_sockaddr_size = sizeof(struct sockaddr_in);
char* tmp_peer;
@@ -3562,6 +3563,13 @@ static int tcp_accept_init(int *socket,
gossip_lerr("Error: failed to set TCP_NODELAY option.\n");
close(*socket);
return (bmi_tcp_errno_to_pvfs(-tmp_errno));
+ }
+
+ /* set it to non-blocking operation */
+ oldfl = fcntl(*socket, F_GETFL, 0);
+ if (!(oldfl & O_NONBLOCK))
+ {
+ fcntl(*socket, F_SETFL, oldfl | O_NONBLOCK);
}
/* allocate ip address string */
Index: sockio.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/io/bmi/bmi_tcp/sockio.c,v
diff -p -u -r1.23 -r1.24
--- sockio.c 26 Mar 2007 18:26:35 -0000 1.23
+++ sockio.c 16 Oct 2007 20:54:42 -0000 1.24
@@ -226,6 +226,8 @@ int BMI_sockio_nbrecv(int s,
{
int ret, comp = len;
+ assert(fcntl(s, F_GETFL, 0) & O_NONBLOCK);
+
while (comp)
{
nbrecv_restart:
@@ -264,6 +266,8 @@ int BMI_sockio_nbrecv(int s,
int BMI_sockio_nbpeek(int s, void* buf, int len)
{
int ret, comp = len;
+
+ assert(fcntl(s, F_GETFL, 0) & O_NONBLOCK);
while (comp)
{
More information about the Pvfs2-cvs
mailing list