[asterisk-commits] pcadach: branch pcadach/chan_h323-live r42923 - /team/pcadach/chan_h323-live/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Sep 13 21:12:24 MST 2006


Author: pcadach
Date: Wed Sep 13 23:12:24 2006
New Revision: 42923

URL: http://svn.digium.com/view/asterisk?rev=42923&view=rev
Log:
Hold technology's lock when destroying private data

Modified:
    team/pcadach/chan_h323-live/channels/chan_h323.c

Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=42923&r1=42922&r2=42923&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Wed Sep 13 23:12:24 2006
@@ -461,6 +461,7 @@
 	if (!cur) {
 		ast_log(LOG_WARNING, "%p is not in list?!?! \n", cur);
 	} else {
+		ast_mutex_unlock(&pvt->lock);
 		ast_mutex_destroy(&pvt->lock);
 		free(pvt);
 	}
@@ -472,6 +473,7 @@
 		ast_log(LOG_DEBUG, "Destroying channel %s\n", (pvt->owner ? pvt->owner->name : "<unknown>"));
 	}
 	ast_mutex_lock(&iflock);
+	ast_mutex_lock(&pvt->lock);
 	__oh323_destroy(pvt);
 	ast_mutex_unlock(&iflock);
 }
@@ -686,10 +688,11 @@
 		}
 	}
 	pvt->needdestroy = 1;
+	ast_mutex_unlock(&pvt->lock);
 
 	/* Update usage counter */
-	ast_mutex_unlock(&pvt->lock);
 	ast_module_unref(ast_module_info->self);
+
 	return 0;
 }
 
@@ -2330,9 +2333,12 @@
 #if 1
 		do {
 			for (oh323 = iflist; oh323; oh323 = oh323->next) {
-				if (oh323->needdestroy) {
-					__oh323_destroy(oh323);
-					break;
+				if (!ast_mutex_trylock(&oh323->lock)) {
+					if (oh323->needdestroy) {
+						__oh323_destroy(oh323);
+						break;
+					}
+					ast_mutex_unlock(&oh323->lock);
 				}
 			}
 		} while (/*oh323*/ 0);
@@ -2340,11 +2346,14 @@
 restartsearch:		
 		oh323 = iflist;
 		while(oh323) {
-			if (oh323->needdestroy) {
-				__oh323_destroy(oh323);
-				goto restartsearch;
-			}
-			oh323 = oh323->next;
+			if (!ast_mutex_trylock(&oh323->lock)) {
+				if (oh323->needdestroy) {
+					__oh323_destroy(oh323);
+					goto restartsearch;
+				}
+				ast_mutex_unlock(&oh323->lock);
+				oh323 = oh323->next;
+			}
 		}
 #endif
 		ast_mutex_unlock(&iflock);



More information about the asterisk-commits mailing list