fix bad return vals on sending messages when under stress

This commit is contained in:
Anthony Minessale 2012-11-13 17:56:09 -06:00
parent 5fffdc2936
commit 18f20e24bf
3 changed files with 13 additions and 4 deletions

View File

@ -1 +1 @@
Thu Nov 8 09:48:11 CST 2012
Tue Nov 13 15:22:19 CST 2012

View File

@ -9211,7 +9211,7 @@ int outgoing_recv(nta_outgoing_t *_orq,
if (orq->orq_destroyed && 200 <= status && status < 300) {
if (orq->orq_uas && su_strcasecmp(sip->sip_to->a_tag, orq->orq_tag) != 0) {
/* Orphan 200 Ok to INVITE. ACK and BYE it */
SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE\n" VA_NONE));
SU_DEBUG_5(("nta: Orphan 200 Ok send ACK&BYE %p\n", (void *)orq));
return nta_msg_ackbye(sa, msg);
}
return -1; /* Proxy statelessly (RFC3261 section 16.11) */

View File

@ -510,13 +510,20 @@ issize_t su_vsend(su_socket_t s,
su_sockaddr_t const *su, socklen_t sulen)
{
struct msghdr hdr[1] = {{0}};
int rv;
hdr->msg_name = (void *)su;
hdr->msg_namelen = sulen;
hdr->msg_iov = (struct iovec *)iov;
hdr->msg_iovlen = iovlen;
return sendmsg(s, hdr, flags);
do {
if ((rv = sendmsg(s, hdr, flags)) == -1) {
if (errno == EAGAIN) usleep(1000);
}
} while (rv == -1 && (errno == EAGAIN || errno == EINTR));
return rv;
}
issize_t su_vrecv(su_socket_t s, su_iovec_t iov[], isize_t iovlen, int flags,
@ -531,7 +538,9 @@ issize_t su_vrecv(su_socket_t s, su_iovec_t iov[], isize_t iovlen, int flags,
hdr->msg_iov = (struct iovec *)iov;
hdr->msg_iovlen = iovlen;
retval = recvmsg(s, hdr, flags);
do {
retval = recvmsg(s, hdr, flags);
} while (retval == -1 && errno == EINTR);
if (su && sulen)
*sulen = hdr->msg_namelen;