receive_responses: avoid potential hangup

* socketutils.c (receive_responses): Pass MSG_DONTWAIT to recvmsg after
the first recvmsg call to avoid potential hangup.
This commit is contained in:
Дмитрий Левин 2016-01-27 21:35:50 +00:00
parent 9d15ec7b57
commit 2215c3e352

View File

@ -150,6 +150,7 @@ receive_responses(const int fd, const unsigned long inode,
.iov_base = buf,
.iov_len = sizeof(buf)
};
int flags = 0;
for (;;) {
ssize_t ret;
@ -161,7 +162,7 @@ receive_responses(const int fd, const unsigned long inode,
.msg_iovlen = 1
};
ret = recvmsg(fd, &msg, 0);
ret = recvmsg(fd, &msg, flags);
if (ret < 0) {
if (errno == EINTR)
continue;
@ -180,6 +181,7 @@ receive_responses(const int fd, const unsigned long inode,
if (parser(proto_name, NLMSG_DATA(h), h->nlmsg_len, inode))
return true;
}
flags = MSG_DONTWAIT;
}
}