[asterisk-commits] rmudgett: trunk r357317 - in /trunk: channels/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Feb 28 12:46:39 CST 2012


Author: rmudgett
Date: Tue Feb 28 12:46:34 2012
New Revision: 357317

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=357317
Log:
Convert struct ast_tcptls_session_instance to finally use the ao2 object lock.

Modified:
    trunk/channels/chan_sip.c
    trunk/include/asterisk/tcptls.h
    trunk/main/tcptls.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=357317&r1=357316&r2=357317
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Feb 28 12:46:34 2012
@@ -2440,7 +2440,7 @@
 		return XMIT_ERROR;
 	}
 
-	ast_mutex_lock(&tcptls_session->lock);
+	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")) ||
@@ -2467,7 +2467,7 @@
 	}
 	ao2_unlock(th);
 
-	ast_mutex_unlock(&tcptls_session->lock);
+	ao2_unlock(tcptls_session);
 	ao2_t_ref(th, -1, "In sip_tcptls_write, unref threadinfo object after finding it");
 	return res;
 
@@ -2478,7 +2478,7 @@
 	if (packet) {
 		ao2_t_ref(packet, -1, "could not allocate packet's data");
 	}
-	ast_mutex_unlock(&tcptls_session->lock);
+	ao2_unlock(tcptls_session);
 
 	return XMIT_ERROR;
 }
@@ -2692,9 +2692,9 @@
 					}
 				}
 
-				ast_mutex_lock(&tcptls_session->lock);
+				ao2_lock(tcptls_session);
 				if (!fgets(buf, sizeof(buf), tcptls_session->f)) {
-					ast_mutex_unlock(&tcptls_session->lock);
+					ao2_unlock(tcptls_session);
 					if (after_poll) {
 						goto cleanup;
 					} else {
@@ -2702,7 +2702,7 @@
 						continue;
 					}
 				}
-				ast_mutex_unlock(&tcptls_session->lock);
+				ao2_unlock(tcptls_session);
 				after_poll = 0;
 				if (me->stop) {
 					 goto cleanup;
@@ -2742,9 +2742,9 @@
 						}
 					}
 
-					ast_mutex_lock(&tcptls_session->lock);
+					ao2_lock(tcptls_session);
 					if (!(bytes_read = fread(buf, 1, MIN(sizeof(buf) - 1, cl), tcptls_session->f))) {
-						ast_mutex_unlock(&tcptls_session->lock);
+						ao2_unlock(tcptls_session);
 						if (after_poll) {
 							goto cleanup;
 						} else {
@@ -2753,7 +2753,7 @@
 						}
 					}
 					buf[bytes_read] = '\0';
-					ast_mutex_unlock(&tcptls_session->lock);
+					ao2_unlock(tcptls_session);
 					after_poll = 0;
 					if (me->stop) {
 						goto cleanup;
@@ -2823,10 +2823,10 @@
 	}
 
 	if (tcptls_session) {
-		ast_mutex_lock(&tcptls_session->lock);
+		ao2_lock(tcptls_session);
 		ast_tcptls_close_session_file(tcptls_session);
 		tcptls_session->parent = NULL;
-		ast_mutex_unlock(&tcptls_session->lock);
+		ao2_unlock(tcptls_session);
 
 		ao2_ref(tcptls_session, -1);
 		tcptls_session = NULL;

Modified: trunk/include/asterisk/tcptls.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/tcptls.h?view=diff&rev=357317&r1=357316&r2=357317
==============================================================================
--- trunk/include/asterisk/tcptls.h (original)
+++ trunk/include/asterisk/tcptls.h Tue Feb 28 12:46:34 2012
@@ -155,8 +155,6 @@
 	int client;
 	struct ast_sockaddr remote_address;
 	struct ast_tcptls_session_args *parent;
-	/*! \todo XXX Why do we still use this lock when this struct is allocated as an ao2 object which has its own lock? */
-	ast_mutex_t lock;
 };
 
 #if defined(HAVE_FUNOPEN)

Modified: trunk/main/tcptls.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/tcptls.c?view=diff&rev=357317&r1=357316&r2=357317
==============================================================================
--- trunk/main/tcptls.c (original)
+++ trunk/main/tcptls.c Tue Feb 28 12:46:34 2012
@@ -129,12 +129,6 @@
 	}
 #endif
 	return write(tcptls_session->fd, buf, count);
-}
-
-static void session_instance_destructor(void *obj)
-{
-	struct ast_tcptls_session_instance *i = obj;
-	ast_mutex_destroy(&i->lock);
 }
 
 /*! \brief
@@ -285,7 +279,7 @@
 			}
 			continue;
 		}
-		tcptls_session = ao2_alloc(sizeof(*tcptls_session), session_instance_destructor);
+		tcptls_session = ao2_alloc(sizeof(*tcptls_session), NULL);
 		if (!tcptls_session) {
 			ast_log(LOG_WARNING, "No memory for new session: %s\n", strerror(errno));
 			if (close(fd)) {
@@ -293,8 +287,6 @@
 			}
 			continue;
 		}
-
-		ast_mutex_init(&tcptls_session->lock);
 
 		flags = fcntl(fd, F_GETFL);
 		fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
@@ -477,11 +469,10 @@
 		}
 	}
 
-	if (!(tcptls_session = ao2_alloc(sizeof(*tcptls_session), session_instance_destructor))) {
+	if (!(tcptls_session = ao2_alloc(sizeof(*tcptls_session), NULL))) {
 		goto error;
 	}
 
-	ast_mutex_init(&tcptls_session->lock);
 	tcptls_session->client = 1;
 	tcptls_session->fd = desc->accept_fd;
 	tcptls_session->parent = desc;




More information about the asterisk-commits mailing list