From 18f20e24bf2a2cd309bf41b6ed373342d4688e97 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 13 Nov 2012 17:56:09 -0600 Subject: [PATCH] fix bad return vals on sending messages when under stress --- libs/sofia-sip/.update | 2 +- libs/sofia-sip/libsofia-sip-ua/nta/nta.c | 2 +- libs/sofia-sip/libsofia-sip-ua/su/su.c | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index dbb9bc2ccd..b50d284902 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Thu Nov 8 09:48:11 CST 2012 +Tue Nov 13 15:22:19 CST 2012 diff --git a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c index 709e678d86..c9bbea2d6b 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nta/nta.c +++ b/libs/sofia-sip/libsofia-sip-ua/nta/nta.c @@ -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) */ diff --git a/libs/sofia-sip/libsofia-sip-ua/su/su.c b/libs/sofia-sip/libsofia-sip-ua/su/su.c index 8067fdec60..c99d32f24d 100644 --- a/libs/sofia-sip/libsofia-sip-ua/su/su.c +++ b/libs/sofia-sip/libsofia-sip-ua/su/su.c @@ -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;