[asterisk-commits] russell: branch russell/sla_updates r57024 - /team/russell/sla_updates/apps/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Feb 27 16:08:27 MST 2007


Author: russell
Date: Tue Feb 27 17:08:26 2007
New Revision: 57024

URL: http://svn.digium.com/view/asterisk?view=rev&rev=57024
Log:
Note to self:  Do not create a mutex and not call mutex_init() on it.

Modified:
    team/russell/sla_updates/apps/app_meetme.c

Modified: team/russell/sla_updates/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/russell/sla_updates/apps/app_meetme.c?view=diff&rev=57024&r1=57023&r2=57024
==============================================================================
--- team/russell/sla_updates/apps/app_meetme.c (original)
+++ team/russell/sla_updates/apps/app_meetme.c Tue Feb 27 17:08:26 2007
@@ -3241,13 +3241,12 @@
  * \param station the station
  * \param remove remove the ringing trunk once selected
  * \return a pointer to the selected ringing trunk, or NULL if none found
+ * \note Assumes that sla.lock is locked
  */
 static struct sla_ringing_trunk *sla_choose_ringing_trunk(struct sla_station *station, int remove)
 {
 	struct sla_trunk_ref *s_trunk_ref;
 	struct sla_ringing_trunk *ringing_trunk;
-
-	ast_mutex_lock(&sla.lock);
 
 	AST_LIST_TRAVERSE(&station->trunks, s_trunk_ref, entry) {
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&sla.ringing_trunks, ringing_trunk, entry) {
@@ -3270,8 +3269,6 @@
 		if (ringing_trunk)
 			break;
 	}
-
-	ast_mutex_unlock(&sla.lock);
 
 	return ringing_trunk;
 }
@@ -3302,7 +3299,9 @@
 		case AST_DIAL_RESULT_ANSWERED:
 			AST_LIST_REMOVE_CURRENT(&sla.ringing_stations, entry);
 			/* Find the appropriate trunk to answer. */
+			ast_mutex_lock(&sla.lock);
 			ringing_trunk = sla_choose_ringing_trunk(ringing_station->station, 1);
+			ast_mutex_unlock(&sla.lock);
 			if (!ringing_trunk) {
 				ast_log(LOG_DEBUG, "Found no ringing trunk for station '%s' to answer!\n",
 					ringing_station->station->name);
@@ -4505,6 +4504,9 @@
 	const char *cat = NULL;
 	int res = 0;
 
+	ast_mutex_init(&sla.lock);
+	ast_cond_init(&sla.cond, NULL);
+
 	if (!(cfg = ast_config_load(SLA_CONFIG_FILE)))
 		return 0; /* Treat no config as normal */
 
@@ -4572,6 +4574,8 @@
 static int load_module(void)
 {
 	int res;
+
+	res |= load_config(0);
 
 	ast_cli_register_multiple(cli_meetme, ARRAY_LEN(cli_meetme));
 	res = ast_manager_register("MeetmeMute", EVENT_FLAG_CALL, 
@@ -4589,8 +4593,6 @@
 	res |= ast_devstate_prov_add("Meetme", meetmestate);
 	res |= ast_devstate_prov_add("SLA", sla_state);
 
-	res |= load_config(0);
-
 	return res;
 }
 



More information about the asterisk-commits mailing list