Update of /cvsroot/libsnet/libsnet
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29000
Modified Files:
snet.c
Log Message:
correctly restore blocking state on read & write errors
Index: snet.c
===================================================================
RCS file: /cvsroot/libsnet/libsnet/snet.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** snet.c 20 Mar 2006 14:46:12 -0000 1.51
--- snet.c 2 May 2006 15:08:06 -0000 1.52
***************
*** 565,573 ****
if ( snet_select( snet_fd( sn ) + 1, NULL, &fds, NULL, tv ) < 0 ) {
! return( -1 );
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! return( -1 );
}
--- 565,573 ----
if ( snet_select( snet_fd( sn ) + 1, NULL, &fds, NULL, tv ) < 0 ) {
! goto restoreblocking;
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! goto restoreblocking;
}
***************
*** 588,596 ****
if ( snet_select( snet_fd( sn ) + 1,
&fds, NULL, NULL, tv ) < 0 ) {
! return( -1 );
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! return( -1 );
}
--- 588,596 ----
if ( snet_select( snet_fd( sn ) + 1,
&fds, NULL, NULL, tv ) < 0 ) {
! goto restoreblocking;
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! goto restoreblocking;
}
***************
*** 599,607 ****
default :
! return( -1 );
}
}
#else
! return( -1 );
#endif /* HAVE_LIBSSL */
} else {
--- 599,607 ----
default :
! goto restoreblocking;
}
}
#else
! goto restoreblocking;
#endif /* HAVE_LIBSSL */
} else {
***************
*** 610,614 ****
continue;
}
! return( rc );
}
}
--- 610,614 ----
continue;
}
! goto restoreblocking;
}
}
***************
*** 625,628 ****
--- 625,636 ----
}
return( rlen );
+
+ restoreblocking:
+ if (( oflags & O_NONBLOCK ) == 0 ) {
+ if ( fcntl( snet_fd( sn ), F_SETFL, oflags ) < 0 ) {
+ return( -1 );
+ }
+ }
+ return( -1 );
}
***************
*** 816,824 ****
/* time out case? */
if ( select( snet_fd( sn ) + 1, &fds, NULL, NULL, tv ) < 0 ) {
! return( -1 );
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! return( -1 );
}
}
--- 824,832 ----
/* time out case? */
if ( select( snet_fd( sn ) + 1, &fds, NULL, NULL, tv ) < 0 ) {
! goto restoreblocking;
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! goto restoreblocking;
}
}
***************
*** 834,842 ****
if ( snet_select( snet_fd( sn ) + 1,
NULL, &fds, NULL, tv ) < 0 ) {
! return( -1 );
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! return( -1 );
}
--- 842,850 ----
if ( snet_select( snet_fd( sn ) + 1,
NULL, &fds, NULL, tv ) < 0 ) {
! goto restoreblocking;
}
if ( FD_ISSET( snet_fd( sn ), &fds ) == 0 ) {
errno = ETIMEDOUT;
! goto restoreblocking;
}
***************
*** 845,849 ****
default :
! return( -1 );
}
}
--- 853,857 ----
default :
! goto restoreblocking;
}
}
***************
*** 883,886 ****
--- 891,902 ----
return( rc );
+
+ restoreblocking:
+ if ( dontblock && (( oflags & O_NONBLOCK ) == 0 )) {
+ if (( fcntl( snet_fd( sn ), F_SETFL, oflags )) < 0 ) {
+ return( -1 );
+ }
+ }
+ return( -1 );
}
|