dect
/
libnl
Archived
13
0
Fork 0

nl_recv(): "else if" logick simplified and refined

This commit is contained in:
Коренберг Марк (ноутбук дома) 2012-09-10 02:25:07 +06:00 committed by Коренберг Марк (дома)
parent e7ec197da3
commit 9d6b104ec8
1 changed files with 16 additions and 8 deletions

View File

@ -459,25 +459,31 @@ retry:
n = recvmsg(sk->s_fd, &msg, flags);
if (!n)
goto abort;
else if (n < 0) {
if (n < 0) {
if (errno == EINTR) {
NL_DBG(3, "recvmsg() returned EINTR, retrying\n");
goto retry;
} else if (errno == EAGAIN) {
}
if (errno == EAGAIN) {
NL_DBG(3, "recvmsg() returned EAGAIN, aborting\n");
goto abort;
} else {
free(msg.msg_control);
free(*buf);
return -nl_syserr2nlerr(errno);
}
free(msg.msg_control);
free(*buf);
return -nl_syserr2nlerr(errno);
}
if (msg.msg_flags & MSG_CTRUNC) {
msg.msg_controllen *= 2;
msg.msg_control = realloc(msg.msg_control, msg.msg_controllen);
goto retry;
} else if (iov.iov_len < n || msg.msg_flags & MSG_TRUNC) {
}
if (iov.iov_len < n || msg.msg_flags & MSG_TRUNC) {
/* Provided buffer is not long enough, enlarge it
* to size of n (which should be total length of the message)
* and try again. */
@ -485,7 +491,9 @@ retry:
iov.iov_base = *buf = realloc(*buf, iov.iov_len);
flags = 0;
goto retry;
} else if (flags != 0) {
}
if (flags != 0) {
/* Buffer is big enough, do the actual reading */
flags = 0;
goto retry;