Browse Source

EINTR requires special handling

git.mgm/mediaproxy-ng/2.1
Richard Fuchs 14 years ago
parent
commit
e033d1da1c
3 changed files with 16 additions and 6 deletions
  1. +4
    -2
      daemon/call.c
  2. +3
    -1
      daemon/control_udp.c
  3. +9
    -3
      daemon/streambuf.c

+ 4
- 2
daemon/call.c View File

@ -294,7 +294,7 @@ forward:
ret = sendmsg(p->fd, &mh, 0);
if (ret == -1 && errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) {
if (ret == -1) {
r->stats.errors++;
m->statsps.errors++;
return -1;
@ -332,7 +332,9 @@ static void stream_readable(int fd, void *p, uintptr_t u) {
ret = recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *) &ss, &sinlen);
if (ret < 0) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
if (errno == EINTR)
continue;
if (errno == EAGAIN || errno == EWOULDBLOCK)
break;
stream_closed(fd, r, 0);
break;


+ 3
- 1
daemon/control_udp.c View File

@ -40,7 +40,9 @@ next:
sin_len = sizeof(sin);
len = recvfrom(fd, buf, sizeof(buf) - 1, 0, (struct sockaddr *) &sin, &sin_len);
if (len < 0) {
if (errno != EWOULDBLOCK && errno != EAGAIN && errno != EINTR)
if (errno == EINTR)
goto next;
if (errno != EWOULDBLOCK && errno != EAGAIN)
mylog(LOG_WARNING, "Error reading from UDP socket");
return;
}


+ 9
- 3
daemon/streambuf.c View File

@ -45,7 +45,9 @@ int streambuf_writeable(struct streambuf *b) {
ret = write(b->fd, b->buf->str, out);
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK)
if (errno == EINTR)
continue;
if (errno != EAGAIN && errno != EWOULDBLOCK)
return -1;
ret = 0;
}
@ -74,7 +76,9 @@ int streambuf_readable(struct streambuf *b) {
if (ret == 0)
return -1;
if (ret < 0) {
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK)
if (errno == EINTR)
continue;
if (errno == EAGAIN || errno == EWOULDBLOCK)
break;
return -1;
}
@ -155,7 +159,9 @@ void streambuf_write(struct streambuf *b, const char *s, unsigned int len) {
ret = write(b->fd, s, out);
if (ret < 0) {
if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) {
if (errno == EINTR)
continue;
if (errno != EAGAIN && errno != EWOULDBLOCK) {
poller_error(b->poller, b->fd);
break;
}


Loading…
Cancel
Save