[asterisk-commits] russell: branch bbryant/sip-tcptls r73126 - /team/bbryant/sip-tcptls/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 3 11:54:53 CDT 2007


Author: russell
Date: Tue Jul  3 11:54:52 2007
New Revision: 73126

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73126
Log:
Fix a problem I introduced in my last commit so that it doesn't crash when
accepting connections :)

Modified:
    team/bbryant/sip-tcptls/channels/chan_sip.c

Modified: team/bbryant/sip-tcptls/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/bbryant/sip-tcptls/channels/chan_sip.c?view=diff&rev=73126&r1=73125&r2=73126
==============================================================================
--- team/bbryant/sip-tcptls/channels/chan_sip.c (original)
+++ team/bbryant/sip-tcptls/channels/chan_sip.c Tue Jul  3 11:54:52 2007
@@ -1683,7 +1683,7 @@
 	.send_text = sip_sendtext,
 };
 
-static void *sip_tcp_helper_thread(void *);
+static void *sip_tcp_worker_fn(void *);
 
 static struct tls_config sip_tls_cfg;
 
@@ -1694,7 +1694,7 @@
 	.poll_timeout = -1,
 	.name = "sip tcp server",
 	.accept_fn = server_root,
-	.worker_fn = sip_tcp_helper_thread,
+	.worker_fn = sip_tcp_worker_fn,
 };
 
 static struct server_args sip_tls_desc = {
@@ -1704,7 +1704,7 @@
 	.poll_timeout = -1,
 	.name = "sip tls server",
 	.accept_fn = server_root,
-	.worker_fn = sip_tcp_helper_thread,
+	.worker_fn = sip_tcp_worker_fn,
 };
 
 /**--- some list management macros. **/
@@ -1728,11 +1728,26 @@
 
 static void sip_pvt_unlock(struct sip_pvt *);
 
-/*! \brief SIP TCP helper function */
-static void *sip_tcp_helper_thread(void *data) 
+static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct server_instance *ser);
+
+static void *sip_tcp_helper_thread(void *data)
 {
 	struct sip_pvt *pvt = data;
 	struct server_instance *ser = pvt->socket.ser;
+
+	return _sip_tcp_helper_thread(pvt, ser);
+}
+
+static void *sip_tcp_worker_fn(void *data)
+{
+	struct server_instance *ser = data;
+
+	return _sip_tcp_helper_thread(NULL, ser);
+}
+
+/*! \brief SIP TCP helper function */
+static void *_sip_tcp_helper_thread(struct sip_pvt *pvt, struct server_instance *ser) 
+{
 	int cl;
 	char buf[1024];
 	struct sip_request req = { 0, }, reqcpy = { 0, };
@@ -1743,7 +1758,8 @@
 
 		while (req.len < 4 || strncmp((char *)&req.data + req.len - 4, "\r\n\r\n", 4)) {
 			if (!fgets(buf, sizeof(buf), ser->f)) {
-				pvt->socket.ser = NULL;
+				if (pvt)
+					pvt->socket.ser = NULL;
 				return NULL;
 			}
 
@@ -1758,7 +1774,8 @@
 		if (sscanf(get_header(&reqcpy, "Content-Length"), "%d", &cl)) {
 			while (cl > 0) {
 				if (!fread(buf, (cl < sizeof(buf)) ? cl : sizeof(buf), 1, ser->f)) {
-					pvt->socket.ser = NULL;
+					if (pvt)
+						pvt->socket.ser = NULL;
 					return NULL;
 				}
 




More information about the asterisk-commits mailing list