version 1.33, 2012/04/07 21:52:03 |
version 1.34, 2012/04/13 19:23:32 |
|
|
ssize_t n; |
ssize_t n; |
struct statctx *sc = v_sc; |
struct statctx *sc = v_sc; |
|
|
again: |
|
n = read(fd, ptb->dummybuf, ptb->dummybuf_len); |
n = read(fd, ptb->dummybuf, ptb->dummybuf_len); |
if (n == 0) |
if (n == 0) |
return; |
return; |
else if (n == -1) { |
else if (n == -1) { |
if (errno == EINTR) |
if (errno != EINTR && errno != EWOULDBLOCK) |
goto again; |
warn("fd %d read error", fd); |
else if (errno == EWOULDBLOCK) |
|
return; |
|
warn("fd %d read error", fd); |
|
return; |
return; |
} |
} |
|
|
|
|
struct statctx *sc = v_sc; |
struct statctx *sc = v_sc; |
ssize_t n; |
ssize_t n; |
|
|
again: |
|
n = read(sc->fd, sc->buf, sc->buflen); |
n = read(sc->fd, sc->buf, sc->buflen); |
if (n == -1) { |
if (n == -1) { |
if (errno == EINTR) |
if (errno != EINTR && errno != EWOULDBLOCK) |
goto again; |
warn("fd %d read error", sc->fd); |
else if (errno == EWOULDBLOCK) |
|
return; |
|
warn("fd %d read error", sc->fd); |
|
return; |
return; |
} else if (n == 0) { |
} else if (n == 0) { |
if (ptb->vflag) |
if (ptb->vflag) |
|
|
event_add(&ts->ev, NULL); |
event_add(&ts->ev, NULL); |
if (event & EV_TIMEOUT) |
if (event & EV_TIMEOUT) |
return; |
return; |
again: |
|
if ((sock = accept(fd, (struct sockaddr *)&ss, &sslen)) == -1) { |
if ((sock = accept(fd, (struct sockaddr *)&ss, &sslen)) == -1) { |
if (errno == EINTR) |
|
goto again; |
|
/* |
/* |
* Pause accept if we are out of file descriptors, or |
* Pause accept if we are out of file descriptors, or |
* libevent will haunt us here too. |
* libevent will haunt us here too. |
|
|
|
|
event_del(&ts->ev); |
event_del(&ts->ev); |
evtimer_add(&ts->evt, &evtpause); |
evtimer_add(&ts->evt, &evtpause); |
} else |
} else if (errno != EWOULDBLOCK && errno != EINTR) |
warn("accept"); |
warn("accept"); |
return; |
return; |
} |
} |
|
|
struct statctx *sc = v_sc; |
struct statctx *sc = v_sc; |
ssize_t n; |
ssize_t n; |
|
|
again: |
|
if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { |
if ((n = write(sc->fd, sc->buf, sc->buflen)) == -1) { |
if (errno == EINTR || errno == EAGAIN || |
if (errno == EINTR || errno == EWOULDBLOCK || |
(UDP_MODE && errno == ENOBUFS)) |
(UDP_MODE && errno == ENOBUFS)) |
goto again; |
return; |
err(1, "write"); |
err(1, "write"); |
} |
} |
if (TCP_MODE && n == 0) { |
if (TCP_MODE && n == 0) { |