--- 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;
|