always recreate FD_SETs for select after EINTR; do not rely on select changing timeout because it is not portable

pull/10/head
Boian Bonev 13 years ago
parent 293a632056
commit 3ab1db8554

@ -2584,11 +2584,12 @@ char * sprint_tm( int t )
void u_sleep( int u_sec )
{
int nfound;
struct timeval to;
struct timeval to, tokeep;
fd_set readset, writeset;
to.tv_sec = u_sec / 1000000;
to.tv_usec = u_sec - ( to.tv_sec * 1000000 );
tokeep = to;
FD_ZERO( &readset );
FD_ZERO( &writeset );
@ -2598,6 +2599,10 @@ select_again:
if(nfound < 0) {
if(errno == EINTR) {
/* interrupted system call: redo the select */
to = tokeep;
FD_ZERO( &readset );
FD_ZERO( &writeset );
goto select_again;
}
else {
@ -2632,7 +2637,7 @@ int recvfrom_wto( int s, char *buf, int len, FPING_SOCKADDR *saddr, long timo )
{
unsigned int slen;
int nfound, n;
struct timeval to;
struct timeval to, tokeep;
fd_set readset, writeset;
to.tv_sec = 0;
@ -2641,6 +2646,7 @@ int recvfrom_wto( int s, char *buf, int len, FPING_SOCKADDR *saddr, long timo )
to.tv_sec++;
to.tv_usec -= 1000000;
}
tokeep = to;
FD_ZERO( &readset );
FD_ZERO( &writeset );
@ -2651,6 +2657,11 @@ select_again:
if(nfound < 0) {
if(errno == EINTR) {
/* interrupted system call: redo the select */
to = tokeep;
FD_ZERO( &readset );
FD_ZERO( &writeset );
FD_SET( s, &readset );
goto select_again;
}
else {

Loading…
Cancel
Save