diff options
author | Stef Walter <stef@memberwebs.com> | 2004-09-18 23:43:06 +0000 |
---|---|---|
committer | Stef Walter <stef@memberwebs.com> | 2004-09-18 23:43:06 +0000 |
commit | fdd81151209a04a5ab2535a3c500774f2c70b3cc (patch) | |
tree | c3505f7d809a2d90bd1b3fda5fd1abaf163f5766 /common/spio.c | |
parent | 4d46583b744a3501a31400c4f8109e4500360f75 (diff) |
Debugging fixes for features recently added.
Diffstat (limited to 'common/spio.c')
-rw-r--r-- | common/spio.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/common/spio.c b/common/spio.c index 2d42eac..8cd315b 100644 --- a/common/spio.c +++ b/common/spio.c @@ -164,6 +164,7 @@ unsigned int spio_select(spctx_t* ctx, ...) fd_set mask; spio_t* io; int ret = 0; + int have = 0; int i = 0; va_list ap; @@ -174,16 +175,20 @@ unsigned int spio_select(spctx_t* ctx, ...) while((io = va_arg(ap, spio_t*)) != NULL) { - /* We can't handle more than 31 args */ - if(i > (sizeof(int) * 8) - 2) - break; + if(spio_valid(io)) + { + /* We can't handle more than 31 args */ + if(i > (sizeof(int) * 8) - 2) + break; - /* Check if the buffer has something in it */ - if(HAS_EXTRA(io)) - ret |= (1 << i); + /* Check if the buffer has something in it */ + if(HAS_EXTRA(io)) + ret |= (1 << i); - /* Mark for select */ - FD_SET(io->fd, &mask); + /* Mark for select */ + FD_SET(io->fd, &mask); + have = 1; + } i++; } @@ -194,17 +199,35 @@ unsigned int spio_select(spctx_t* ctx, ...) if(ret != 0) return ret; - /* Otherwise wait on more data */ - switch(select(FD_SETSIZE, &mask, NULL, NULL, - (struct timeval*)&(g_state.timeout))) - { - case 0: - sp_messagex(ctx, LOG_ERR, "network operation timed out"); - return ~0; - case -1: - sp_message(ctx, LOG_ERR, "couldn't select on sockets"); + /* No valid file descriptors */ + if(!have) return ~0; - }; + + for(;;) + { + /* Otherwise wait on more data */ + switch(select(FD_SETSIZE, &mask, NULL, NULL, + (struct timeval*)&(g_state.timeout))) + { + case 0: + sp_messagex(ctx, LOG_ERR, "network operation timed out"); + return ~0; + + case -1: + if(errno == EINTR) + { + if(!sp_is_quit()) + continue; + } + + else + sp_message(ctx, LOG_ERR, "couldn't select on sockets"); + + return ~0; + }; + + break; + } /* See what came in */ i = 0; |