Commit de56aef0 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Protect against sendmsg returning EAGAIN indefinitely.

parent e262a686
......@@ -141,7 +141,7 @@ babel_send(int s,
{
struct iovec iovec[2];
struct msghdr msg;
int rc;
int rc, count = 0;
iovec[0].iov_base = (void*)buf1;
iovec[0].iov_len = buflen1;
......@@ -153,16 +153,23 @@ babel_send(int s,
msg.msg_iov = iovec;
msg.msg_iovlen = 2;
/* The Linux kernel can apparently keep returning EAGAIN indefinitely. */
again:
rc = sendmsg(s, &msg, 0);
if(rc < 0) {
if(errno == EINTR)
if(errno == EINTR) {
count++;
if(count < 100)
goto again;
else if(errno == EAGAIN) {
} else if(errno == EAGAIN) {
int rc2;
rc2 = wait_for_fd(1, s, 5);
if(rc2 > 0)
if(rc2 > 0) {
count++;
if(count < 100)
goto again;
}
errno = EAGAIN;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment