Index: ossp-pkg/sa/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/sa/ChangeLog,v rcsdiff -q -kk '-r1.43' '-r1.44' -u '/v/ossp/cvs/ossp-pkg/sa/ChangeLog,v' 2>/dev/null --- ChangeLog 2005/01/24 15:10:09 1.43 +++ ChangeLog 2005/01/29 08:17:32 1.44 @@ -11,6 +11,14 @@ This is a list of all changes to OSSP sa. For a more brief summary please have a look at the NEWS file. + Changes between 1.2.3 and 1.2.4 (24-Jan-2005 to 29-Jan-2005) + + o Fix timeout handling in various functions by fixing the internal + select(2) usage: the timeout structure is (standard compliantly) + modified in place on some platforms (like Linux), so its values + have to be preserved before calls to select(2)). + [Robert Wood ] + Changes between 1.2.2 and 1.2.3 (26-Jun-2004 to 24-Jan-2005) o Adjusted all copyright messages for new year 2005. Index: ossp-pkg/sa/THANKS RCS File: /v/ossp/cvs/ossp-pkg/sa/THANKS,v rcsdiff -q -kk '-r1.6' '-r1.7' -u '/v/ossp/cvs/ossp-pkg/sa/THANKS,v' 2>/dev/null --- THANKS 2004/06/26 11:16:02 1.6 +++ THANKS 2005/01/29 08:17:32 1.7 @@ -24,4 +24,5 @@ o Amos Gouaux o Thomas Lotterer o Alvaro Lopez Ortega + o Robert Wood Index: ossp-pkg/sa/sa.c RCS File: /v/ossp/cvs/ossp-pkg/sa/sa.c,v rcsdiff -q -kk '-r1.88' '-r1.89' -u '/v/ossp/cvs/ossp-pkg/sa/sa.c,v' 2>/dev/null --- sa.c 2005/01/24 15:10:09 1.88 +++ sa.c 2005/01/29 08:17:32 1.89 @@ -1456,6 +1456,7 @@ socklen_t len; sa_rc_t rv; struct timeval *tv; + struct timeval tv_buf; /* argument sanity check(s) */ if (sa == NULL || raddr == NULL) @@ -1512,8 +1513,10 @@ FD_ZERO(&wset); FD_SET(sa->fdSocket, &rset); FD_SET(sa->fdSocket, &wset); - if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_CONNECT])) - tv = &sa->tvTimeout[SA_TIMEOUT_CONNECT]; + if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_CONNECT])) { + memcpy(&tv_buf, &sa->tvTimeout[SA_TIMEOUT_CONNECT], sizeof(struct timeval)); + tv = &tv_buf; + } else tv = NULL; do { @@ -1591,6 +1594,7 @@ #endif } sa_buf; socklen_t sa_size; + struct timeval tv; int s; int i; @@ -1610,9 +1614,9 @@ if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_ACCEPT])) { FD_ZERO(&fds); FD_SET(sa->fdSocket, &fds); + memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_ACCEPT], sizeof(struct timeval)); do { - n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, - &sa->tvTimeout[SA_TIMEOUT_ACCEPT]); + n = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv); } while (n == -1 && errno == EINTR); if (n == 0) return SA_RC(SA_ERR_TMT); @@ -1763,6 +1767,7 @@ int rv; #if !(defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO)) fd_set fds; + struct timeval tv; #endif /* if timeout is enabled, perform explicit/smart blocking instead @@ -1771,9 +1776,9 @@ if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) { FD_ZERO(&fds); FD_SET(sa->fdSocket, &fds); + memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_READ], sizeof(struct timeval)); do { - rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, - &sa->tvTimeout[SA_TIMEOUT_READ]); + rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv); } while (rv == -1 && errno == EINTR); if (rv == 0) { errno = ETIMEDOUT; @@ -1942,6 +1947,7 @@ int rv; #if !(defined(SO_RCVTIMEO) && defined(USE_SO_RCVTIMEO) && defined(SO_SNDTIMEO) && defined(USE_SO_SNDTIMEO)) fd_set fds; + struct timeval tv; #endif /* if timeout is enabled, perform explicit/smart blocking instead @@ -1950,9 +1956,9 @@ if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) { FD_ZERO(&fds); FD_SET(sa->fdSocket, &fds); + memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_WRITE], sizeof(struct timeval)); do { - rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, - &sa->tvTimeout[SA_TIMEOUT_WRITE]); + rv = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, &tv); } while (rv == -1 && errno == EINTR); if (rv == 0) { errno = ETIMEDOUT; @@ -2177,6 +2183,7 @@ ssize_t n; int k; fd_set fds; + struct timeval tv; /* argument sanity check(s) */ if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL) @@ -2195,9 +2202,9 @@ if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_READ])) { FD_ZERO(&fds); FD_SET(sa->fdSocket, &fds); + memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_READ], sizeof(struct timeval)); do { - k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, - &sa->tvTimeout[SA_TIMEOUT_READ]); + k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, &fds, (fd_set *)NULL, (fd_set *)NULL, &tv); } while (k == -1 && errno == EINTR); if (k == 0) errno = ETIMEDOUT; @@ -2233,6 +2240,7 @@ int k; fd_set fds; sa_rc_t rv; + struct timeval tv; /* argument sanity check(s) */ if (sa == NULL || buf == NULL || buflen == 0 || raddr == NULL) @@ -2252,9 +2260,9 @@ if (!SA_TVISZERO(sa->tvTimeout[SA_TIMEOUT_WRITE])) { FD_ZERO(&fds); FD_SET(sa->fdSocket, &fds); + memcpy(&tv, &sa->tvTimeout[SA_TIMEOUT_WRITE], sizeof(struct timeval)); do { - k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, - &sa->tvTimeout[SA_TIMEOUT_WRITE]); + k = SA_SC_CALL_5(sa, select, sa->fdSocket+1, (fd_set *)NULL, &fds, (fd_set *)NULL, &tv); } while (k == -1 && errno == EINTR); if (k == 0) errno = ETIMEDOUT;