On Wed, 2010-12-01 at 17:08 +0100, Domenico Chierico wrote: > I'm trying to solve the issue inverting the branches order into "if > else" struct using (fds[1].revents & (POLLERR | POLLHUP)) != 0) as first > test. > > I'll run the test tomorrow (this trouble occurs just into production > environment, so i need some time to be sure), I hope to get some > feedback from you. > I just test the patch and seems to work right.
The patch is really dumb, as I've told yesterday it just inverts the order into the tests , giving precedence to the error check. I hope it help. Let me know if something more is required. thanks Domenico Chierico.
>From 6037287aa1ebe290c32562454521215733be4218 Mon Sep 17 00:00:00 2001 From: Domenico Chierico <[email protected]> Date: Thu, 2 Dec 2010 15:25:27 +0100 Subject: [PATCH] give precedence to error management --- sipXtackLib/src/net/SipClient.cpp | 81 +++++++++++++++++++------------------ 1 files changed, 41 insertions(+), 40 deletions(-) diff --git a/sipXtackLib/src/net/SipClient.cpp b/sipXtackLib/src/net/SipClient.cpp index b38655b..6a96694 100644 --- a/sipXtackLib/src/net/SipClient.cpp +++ b/sipXtackLib/src/net/SipClient.cpp @@ -627,6 +627,47 @@ int SipClient::run(void* runArg) } } // end reading msg-available-for-output-queue pipe + else if ((fds[1].revents & (POLLERR | POLLHUP)) != 0) + { + OsSysLog::add(FAC_SIP, PRI_DEBUG, + "SipClient[%s]::run " + "SipMessage::poll error(%d) ", + mName.data(), errno); + + if (OsSocket::isFramed(mClientSocket->getIpProtocol())) + { + OsSysLog::add(FAC_SIP, PRI_ERR, + "SipClient[%s]::run " + "SipMessage::poll error(%d) got POLLERR | POLLHUP on UDP socket", + mName.data(), errno); + + } + else // eg. tcp socket + // This client's socket is a connection-oriented protocol and the + // connection has been terminated (probably by the remote end). + // We must terminate the SipClient. + // We drop the queued messages, but we do not report them to + // SipUserAgent as failed sends. This will cause SipUserAgent to + // retry the send using the same transport (rather than continuing + // to the next transport), which should cause a new connection to + // be made to the remote end. + { + // On non-blocking connect failures, we need to get the first send message + // in order to successfully trigger the protocol fallback mechanism + if (!tcpOnErrWaitForSend) + { + // Return all buffered messages with a transport error indication. + emptyBuffer(TRUE); + clientStopSelf(); + } + else + { + fds[1].revents &= ~(POLLERR | POLLHUP); // clear error bit if waiting + waitingToReportErr = TRUE; + } + } + } + else if ((fds[1].revents & POLLOUT) != 0) { // Poll finished because socket is ready to write. @@ -817,46 +858,6 @@ int SipClient::run(void* runArg) readBuffer.remove(0); } } // end POLLIN reading socket - else if ((fds[1].revents & (POLLERR | POLLHUP)) != 0) - { - OsSysLog::add(FAC_SIP, PRI_DEBUG, - "SipClient[%s]::run " - "SipMessage::poll error(%d) ", - mName.data(), errno); - - if (OsSocket::isFramed(mClientSocket->getIpProtocol())) - { - OsSysLog::add(FAC_SIP, PRI_ERR, - "SipClient[%s]::run " - "SipMessage::poll error(%d) got POLLERR | POLLHUP on UDP socket", - mName.data(), errno); - - } - else // eg. tcp socket - // This client's socket is a connection-oriented protocol and the - // connection has been terminated (probably by the remote end). - // We must terminate the SipClient. - // We drop the queued messages, but we do not report them to - // SipUserAgent as failed sends. This will cause SipUserAgent to - // retry the send using the same transport (rather than continuing - // to the next transport), which should cause a new connection to - // be made to the remote end. - { - // On non-blocking connect failures, we need to get the first send message - // in order to successfully trigger the protocol fallback mechanism - if (!tcpOnErrWaitForSend) - { - // Return all buffered messages with a transport error indication. - emptyBuffer(TRUE); - clientStopSelf(); - } - else - { - fds[1].revents &= ~(POLLERR | POLLHUP); // clear error bit if waiting - waitingToReportErr = TRUE; - } - } - } } while (isStarted()); -- 1.7.2.3
_______________________________________________ sipx-dev mailing list [email protected] List Archive: http://list.sipfoundry.org/archive/sipx-dev/
