Browse Source

Allow select to modify the timeout instead of it being reset on each pass through the read loop

master
Con Kolivas 11 years ago
parent
commit
a9c4c1690d
  1. 6
      src/ckpool.c

6
src/ckpool.c

@ -129,8 +129,8 @@ bool ping_main(ckpool_t *ckp)
* of the buffer for use on the next receive. */ * of the buffer for use on the next receive. */
int read_socket_line(connsock_t *cs, int timeout) int read_socket_line(connsock_t *cs, int timeout)
{ {
tv_t tv_timeout = {timeout, 0};
char *eom = NULL; char *eom = NULL;
tv_t tv_timeout;
size_t buflen; size_t buflen;
int ret = -1; int ret = -1;
fd_set rd; fd_set rd;
@ -153,8 +153,8 @@ int read_socket_line(connsock_t *cs, int timeout)
FD_ZERO(&rd); FD_ZERO(&rd);
FD_SET(cs->fd, &rd); FD_SET(cs->fd, &rd);
tv_timeout.tv_sec = eom ? 0 : timeout; if (eom)
tv_timeout.tv_usec = 0; tv_timeout.tv_sec = tv_timeout.tv_usec = 0;
ret = select(cs->fd + 1, &rd, NULL, NULL, &tv_timeout); ret = select(cs->fd + 1, &rd, NULL, NULL, &tv_timeout);
if (eom && !ret) if (eom && !ret)
break; break;

Loading…
Cancel
Save