[Asterisk-code-review] chan_sip: in case of tcp/tls, be less annoying about tx errors. (asterisk[13])

Joshua C. Colp asteriskteam at digium.com
Thu Dec 19 18:39:08 CST 2019


Joshua C. Colp has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/13366 )

Change subject: chan_sip:  in case of tcp/tls, be less annoying about tx errors.
......................................................................

chan_sip:  in case of tcp/tls, be less annoying about tx errors.

chan_sip.c:3782 __sip_xmit: sip_xmit of 0x7f1478069230 (len 600) to
213.150.203.60:1492 returned -2: Interrupted system call

returned -2 implies this wasn't actually an OS error, so errno makes no
sense either.  Internal error was already logged higher up, and -2
generally means that either there isn't a valid connection available, or
the pipe notification failed, and that is already correctly logged.

ASTERISK-28651 #close

Change-Id: I46eb82924beeff9dfd86fa6c7eb87d2651b950f2
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M channels/chan_sip.c
1 file changed, 12 insertions(+), 2 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Joshua C. Colp: Looks good to me, approved; Approved for Submit



diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index ea78d23..064e6ef 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2568,13 +2568,17 @@
 
 	ao2_lock(tcptls_session);
 
-	if ((tcptls_session->fd == -1) ||
-		!(th = ao2_t_find(threadt, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread")) ||
+	if (tcptls_session->fd == -1 ||
 		!(packet = ao2_alloc(sizeof(*packet), tcptls_packet_destructor)) ||
 		!(packet->data = ast_str_create(len))) {
 		goto tcptls_write_setup_error;
 	}
 
+	if (!(th = ao2_t_find(threadt, &tmp, OBJ_POINTER, "ao2_find, getting sip_threadinfo in tcp helper thread"))) {
+		ast_log(LOG_ERROR, "Unable to locate tcptls_session helper thread.\n");
+		goto tcptls_write_setup_error;
+	}
+
 	/* goto tcptls_write_error should _NOT_ be used beyond this point */
 	ast_str_set(&packet->data, 0, "%s", (char *) buf);
 	packet->len = len;
@@ -3758,6 +3762,9 @@
 		res = ast_sendto(p->socket.fd, ast_str_buffer(data), ast_str_strlen(data), 0, dst);
 	} else if (p->socket.tcptls_session) {
 		res = sip_tcptls_write(p->socket.tcptls_session, ast_str_buffer(data), ast_str_strlen(data));
+		if (res < -1) {
+			return res;
+		}
 	} else if (p->socket.ws_session) {
 		if (!(res = ast_websocket_write_string(p->socket.ws_session, ast_str_buffer(data)))) {
 			/* The WebSocket API just returns 0 on success and -1 on failure, while this code expects the payload length to be returned */
@@ -30160,6 +30167,9 @@
 		   (peer->socket.tcptls_session) &&
 		   (peer->socket.tcptls_session->fd != -1)) {
 		res = sip_tcptls_write(peer->socket.tcptls_session, keepalive, count);
+		if (res < -1) {
+			return 0;
+		}
 	} else if (peer->socket.type == AST_TRANSPORT_UDP) {
 		res = ast_sendto(sipsock, keepalive, count, 0, &peer->addr);
 	}

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/13366
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: I46eb82924beeff9dfd86fa6c7eb87d2651b950f2
Gerrit-Change-Number: 13366
Gerrit-PatchSet: 4
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua C. Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: Richard Mudgett <rmudgett at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20191219/23223b3a/attachment.html>


More information about the asterisk-code-review mailing list