[asterisk-commits] qwell: branch qwell/fun_with_transports r386567 - in /team/qwell/fun_with_tra...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Apr 25 14:51:33 CDT 2013


Author: qwell
Date: Thu Apr 25 14:51:16 2013
New Revision: 386567

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=386567
Log:
Multiple revisions 386022,386056,386163,386192,386213,386238,386304,386321,386338,386343,386345,386354,386378,386430,386465,386490,386532,386545

........
  r386022 | root | 2013-04-18 13:17:43 -0500 (Thu, 18 Apr 2013) | 39 lines
  
  Multiple revisions 386019-386020
  
  ........
    r386019 | dlee | 2013-04-18 12:26:29 -0500 (Thu, 18 Apr 2013) | 17 lines
    
    Fix lock errors on startup.
    
    In messages.c, there are several places in the code where we create a
    tmp_tech_holder and pass that into an ao2_find call. Unfortunately, we
    weren't initializing the rwlock on the tmp_tech_holder, which the hash
    function was locking. It's apparently harmless, but still not the best
    code.
    
    This patch extracts all that copy/pasted code into two functions,
    msg_find_by_tech and msg_find_by_tech_name, which properly initialize
    and destroy the rwlock on the tmp_tech_holder.
    
    Review: https://reviewboard.asterisk.org/r/2454/
    ........
    
    Merged revisions 386006 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r386020 | dlee | 2013-04-18 12:30:28 -0500 (Thu, 18 Apr 2013) | 12 lines
    
    Allow WebSocket connections on more URL's
    
    This patch adds the concept of ast_websocket_server to
    res_http_websocket, allowing WebSocket connections on URL's more more
    than /ws.
    
    The existing funcitons for managing the WebSocket subprotocols on /ws
    still work, so this patch should be completely backward compatible.
    
    (closes issue ASTERISK-21279)
    Review: https://reviewboard.asterisk.org/r/2453/
  ........
  
  Merged revisions 386019-386020 from file:///srv/subversion/repos/asterisk/trunk
........
  r386056 | root | 2013-04-19 01:17:38 -0500 (Fri, 19 Apr 2013) | 13 lines
  
  cli.c: Properly initialize debug_modules and verbose_modules.
  
  This avoids some lock errors on the core set {debug,verbose} commands.
  ........
  
  Merged revisions 386049 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 386051 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 386054 from file:///srv/subversion/repos/asterisk/trunk
........
  r386163 | root | 2013-04-19 18:17:44 -0500 (Fri, 19 Apr 2013) | 58 lines
  
  Prevent res_timing_pthread from blocking callers
  
  There were several reports of deadlock when using
  res_timing_pthread. Backtraces indicated that one thread was blocked
  waiting for the write to the pipe to complete and this thread held
  the container lock for the timers.  Therefore any thread that wanted
  to create a new timer or read an existing timer would block waiting
  for either the timer lock or the container lock and deadlock ensued.
  
  This patch changes the way the pipe is used to eliminate this source
  of deadlocks:
  
  1) The pipe is placed in non-blocking mode so that it would never
  block even if the following changes someone fail...
  
  2) Instead of writing bytes into the pipe for each "tick" that's
  fired the pipe now has two states--signaled and unsignaled. If
  signaled, the pipe is hot and any pollers of the read side
  filedescriptor will be woken up. If unsigned the pipe is idle. This
  eliminates even the chance of filling up the pipe and reduces the
  potential overhead of calling unnecessary writes.
  
  3) Since we're tracking the signaled / unsignaled state, we can
  eliminate the exta poll system call for every firing because we know
  that there is data to be read.
  
  (closes issue ASTERISK-21389)
  Reported by: Matt Jordan
  Tested by: Shaun Ruffell, Matt Jordan, Tony Lewis
  patches:
    0001-res_timing_pthread-Reduce-probability-of-deadlocking.patch uploaded by sruffell (License 5417)
  
  (closes issue ASTERISK-19754)
  Reported by: Nikola Ciprich
  
  (closes issue ASTERISK-20577)
  Reported by: Kien Kennedy
  
  (closes issue ASTERISK-17436)
  Reported by: Henry Fernandes
  
  (closes issue ASTERISK-17467)
  Reported by: isrl
  
  (closes issue ASTERISK-17458)
  Reported by: isrl
  
  Review: https://reviewboard.asterisk.org/r/2441/
  ........
  
  Merged revisions 386109 from http://svn.asterisk.org/svn/asterisk/branches/1.8
  ........
  
  Merged revisions 386159 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 386160 from file:///srv/subversion/repos/asterisk/trunk
........
  r386192 | root | 2013-04-21 20:18:32 -0500 (Sun, 21 Apr 2013) | 9 lines
  
  sla: remove redundant locking.
  
  sla.lock was already locked in the only place that sla_check_reload() was called.
  Remove the redundant locking of sla.lock done in this function.  Less recursive
  locking is A Good Thing.
  ........
  
  Merged revisions 386190 from file:///srv/subversion/repos/asterisk/trunk
........
  r386213 | root | 2013-04-22 08:18:13 -0500 (Mon, 22 Apr 2013) | 7 lines
  
  Fix mistake in Doxygen. 
  
  Doxygen is only *ONE* comment that applies to the NEXT piece of code.
  ........
  
  Merged revisions 386211 from file:///srv/subversion/repos/asterisk/trunk
........
  r386238 | root | 2013-04-22 10:17:48 -0500 (Mon, 22 Apr 2013) | 1 line
  
  automerge cancel
........
  r386304 | qwell | 2013-04-22 12:50:44 -0500 (Mon, 22 Apr 2013) | 9 lines
  
  Add support for DTMF via SIP INFO.
  
  For sending, set dtmfmode=info in res_sip.conf.
  For receiving, load res_sip_dtmf_info.so.
  
  (closes issue ASTERISK-21261)
  
  Review: https://reviewboard.asterisk.org/r/2455/
........
  r386321 | mmichelson | 2013-04-22 15:06:26 -0500 (Mon, 22 Apr 2013) | 3 lines
  
  Resolve conflict and reset automerge.
........
  r386338 | file | 2013-04-23 10:13:25 -0500 (Tue, 23 Apr 2013) | 2 lines
  
  Reduce long-term memory usage by using the provisional pool on the invite session.
........
  r386343 | file | 2013-04-23 10:24:34 -0500 (Tue, 23 Apr 2013) | 2 lines
  
  Don't assume a session will be present when has_supplement is called, it may have gone away.
........
  r386345 | file | 2013-04-23 10:37:06 -0500 (Tue, 23 Apr 2013) | 2 lines
  
  If incoming SDP can not be handled send a 488, not a 500.
........
  r386354 | root | 2013-04-23 14:17:40 -0500 (Tue, 23 Apr 2013) | 7 lines
  
  Fix some bad whitespace
  
  This crept in with the RESTful HTTP interface merge.
  ........
  
  Merged revisions 386352 from file:///srv/subversion/repos/asterisk/trunk
........
  r386378 | root | 2013-04-23 16:17:37 -0500 (Tue, 23 Apr 2013) | 12 lines
  
  confbridge: Make search the conference bridges container using OBJ_KEY.
  
  * Make confbridge config parsing user profile, bridge profile, and menu
  container hash/cmp functions correctly check the OBJ_POINTER, OBJ_KEY, and
  OBJ_PARTIAL_KEY flags.
  
  * Made confbridge load_module()/unload_module() free all resources on
  failure conditions.
  ........
  
  Merged revisions 386375 from file:///srv/subversion/repos/asterisk/trunk
........
  r386430 | kmoore | 2013-04-24 13:57:25 -0500 (Wed, 24 Apr 2013) | 4 lines
  
  Fix res_sip sample config
  
  Fix listing of possible values for timers endpoint configuration option.
........
  r386465 | root | 2013-04-24 17:17:44 -0500 (Wed, 24 Apr 2013) | 14 lines
  
  Multiple revisions 386461-386462
  
  ........
    r386461 | dlee | 2013-04-24 16:43:16 -0500 (Wed, 24 Apr 2013) | 1 line
    
    Oops. Mustache doesn't like dictionaries
  ........
    r386462 | dlee | 2013-04-24 16:47:03 -0500 (Wed, 24 Apr 2013) | 1 line
    
    Document JSON models in resource_*.h
  ........
  
  Merged revisions 386461-386462 from file:///srv/subversion/repos/asterisk/trunk
........
  r386490 | root | 2013-04-24 22:17:56 -0500 (Wed, 24 Apr 2013) | 28 lines
  
  Multiple revisions 386485,386487
  
  ........
    r386485 | elguero | 2013-04-24 21:48:44 -0500 (Wed, 24 Apr 2013) | 10 lines
    
    Change Case On Forcerport For Consistency
    
    * Change "ForcerPort" to "Forcerport" to match everywhere else it is displayed
    ........
    
    Merged revisions 386483 from http://svn.asterisk.org/svn/asterisk/branches/1.8
    ........
    
    Merged revisions 386484 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
    r386487 | elguero | 2013-04-24 22:04:21 -0500 (Wed, 24 Apr 2013) | 8 lines
    
    Fix Displaying Symmetric RTP Global Setting
    
    * Use comedia_string() to display correctly the symmetric rtp setting when
      running "sip show settings"
    ........
    
    Merged revisions 386486 from http://svn.asterisk.org/svn/asterisk/branches/11
  ........
  
  Merged revisions 386485,386487 from file:///srv/subversion/repos/asterisk/trunk
........
  r386532 | mmichelson | 2013-04-25 12:44:41 -0500 (Thu, 25 Apr 2013) | 8 lines
  
  Merge SUBSCRIBE/NOTIFY support and MWI support.
  
  (closes ASTERISK-21259)
  (closes ASTERISK-21260)
  
  Review: https://reviewboard.asterisk.org/r/2456
........
  r386545 | root | 2013-04-25 14:17:50 -0500 (Thu, 25 Apr 2013) | 1 line
  
  automerge cancel
........

Merged revisions 386022,386056,386163,386192,386213,386238,386304,386321,386338,386343,386345,386354,386378,386430,386465,386490,386532,386545 from http://svn.asterisk.org/svn/asterisk/team/group/pimp_my_sip

Added:
    team/qwell/fun_with_transports/configs/stasis_http.conf.sample
      - copied unchanged from r386545, team/group/pimp_my_sip/configs/stasis_http.conf.sample
    team/qwell/fun_with_transports/include/asterisk/res_sip_pubsub.h
      - copied unchanged from r386545, team/group/pimp_my_sip/include/asterisk/res_sip_pubsub.h
    team/qwell/fun_with_transports/include/asterisk/stasis_http.h
      - copied unchanged from r386545, team/group/pimp_my_sip/include/asterisk/stasis_http.h
    team/qwell/fun_with_transports/res/res_sip_dtmf_info.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_sip_dtmf_info.c
    team/qwell/fun_with_transports/res/res_sip_mwi.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_sip_mwi.c
    team/qwell/fun_with_transports/res/res_sip_pubsub.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_sip_pubsub.c
    team/qwell/fun_with_transports/res/res_sip_pubsub.exports.in
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_sip_pubsub.exports.in
    team/qwell/fun_with_transports/res/res_stasis_http.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http.c
    team/qwell/fun_with_transports/res/res_stasis_http.exports.in
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http.exports.in
    team/qwell/fun_with_transports/res/res_stasis_http_asterisk.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_asterisk.c
    team/qwell/fun_with_transports/res/res_stasis_http_bridges.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_bridges.c
    team/qwell/fun_with_transports/res/res_stasis_http_channels.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_channels.c
    team/qwell/fun_with_transports/res/res_stasis_http_endpoints.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_endpoints.c
    team/qwell/fun_with_transports/res/res_stasis_http_events.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_events.c
    team/qwell/fun_with_transports/res/res_stasis_http_playback.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_playback.c
    team/qwell/fun_with_transports/res/res_stasis_http_recordings.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_recordings.c
    team/qwell/fun_with_transports/res/res_stasis_http_sounds.c
      - copied unchanged from r386545, team/group/pimp_my_sip/res/res_stasis_http_sounds.c
    team/qwell/fun_with_transports/res/stasis_http/   (props changed)
      - copied from r386545, team/group/pimp_my_sip/res/stasis_http/
    team/qwell/fun_with_transports/res/stasis_http.make
      - copied unchanged from r386545, team/group/pimp_my_sip/res/stasis_http.make
    team/qwell/fun_with_transports/rest-api/
      - copied from r386545, team/group/pimp_my_sip/rest-api/
    team/qwell/fun_with_transports/rest-api-templates/   (props changed)
      - copied from r386545, team/group/pimp_my_sip/rest-api-templates/
    team/qwell/fun_with_transports/tests/test_stasis_http.c
      - copied unchanged from r386545, team/group/pimp_my_sip/tests/test_stasis_http.c
Modified:
    team/qwell/fun_with_transports/   (props changed)
    team/qwell/fun_with_transports/Makefile
    team/qwell/fun_with_transports/apps/app_confbridge.c
    team/qwell/fun_with_transports/apps/app_meetme.c
    team/qwell/fun_with_transports/apps/confbridge/conf_config_parser.c
    team/qwell/fun_with_transports/channels/chan_gulp.c
    team/qwell/fun_with_transports/channels/chan_sip.c
    team/qwell/fun_with_transports/configs/res_sip.conf.sample
    team/qwell/fun_with_transports/include/asterisk/http.h
    team/qwell/fun_with_transports/include/asterisk/http_websocket.h
    team/qwell/fun_with_transports/include/asterisk/json.h
    team/qwell/fun_with_transports/include/asterisk/res_sip.h
    team/qwell/fun_with_transports/include/asterisk/srv.h
    team/qwell/fun_with_transports/include/asterisk/stasis_app.h
    team/qwell/fun_with_transports/include/asterisk/strings.h
    team/qwell/fun_with_transports/main/channel.c
    team/qwell/fun_with_transports/main/cli.c
    team/qwell/fun_with_transports/main/http.c
    team/qwell/fun_with_transports/main/json.c
    team/qwell/fun_with_transports/main/message.c
    team/qwell/fun_with_transports/res/Makefile
    team/qwell/fun_with_transports/res/res_http_websocket.c
    team/qwell/fun_with_transports/res/res_sip/location.c
    team/qwell/fun_with_transports/res/res_sip/sip_configuration.c
    team/qwell/fun_with_transports/res/res_sip/sip_distributor.c
    team/qwell/fun_with_transports/res/res_sip_sdp_rtp.c
    team/qwell/fun_with_transports/res/res_sip_session.c
    team/qwell/fun_with_transports/res/res_stasis.c
    team/qwell/fun_with_transports/res/res_timing_pthread.c
    team/qwell/fun_with_transports/tests/test_stasis.c
    team/qwell/fun_with_transports/tests/test_strings.c

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Propchange: team/qwell/fun_with_transports/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Apr 25 14:51:16 2013
@@ -1,1 +1,1 @@
-/team/group/pimp_my_sip:1-386004 /trunk:1-383466
+/team/group/pimp_my_sip:1-386566 /trunk:1-383466

Modified: team/qwell/fun_with_transports/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/Makefile?view=diff&rev=386567&r1=386566&r2=386567
==============================================================================
--- team/qwell/fun_with_transports/Makefile (original)
+++ team/qwell/fun_with_transports/Makefile Thu Apr 25 14:51:16 2013
@@ -453,6 +453,9 @@
 		$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
 	done
 	$(MAKE) -C sounds install
+	find rest-api -name "*.json" | while read x; do \
+		$(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
+	done
 
 ifneq ($(GREP),)
   XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
@@ -537,8 +540,8 @@
 	"$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
 	"$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
 	"$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
-	"$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/static-http" "$(ASTDATADIR)/sounds" \
-	"$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
+	"$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
+	"$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
 
 installdirs:
 	@for i in $(INSTALLDIRS); do \
@@ -958,6 +961,19 @@
 	@cat sounds/sounds.xml >> $@
 	@echo "</menu>" >> $@
 
+# We don't want to require Python or Pystache for every build, so this is its
+# own target.
+stasis-stubs:
+ifeq ($(PYTHON),:)
+	@echo "--------------------------------------------------------------------------"
+	@echo "---        Please install python to build Stasis HTTP stubs            ---"
+	@echo "--------------------------------------------------------------------------"
+	@false
+else
+	$(PYTHON) rest-api-templates/make_stasis_http_stubs.py \
+		rest-api/resources.json res/
+endif
+
 .PHONY: menuselect
 .PHONY: main
 .PHONY: sounds
@@ -977,6 +993,7 @@
 .PHONY: installdirs
 .PHONY: validate-docs
 .PHONY: _clean
+.PHONY: stasis-stubs
 .PHONY: $(SUBDIRS_INSTALL)
 .PHONY: $(SUBDIRS_DIST_CLEAN)
 .PHONY: $(SUBDIRS_CLEAN)

Modified: team/qwell/fun_with_transports/apps/app_confbridge.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_confbridge.c?view=diff&rev=386567&r1=386566&r2=386567
==============================================================================
--- team/qwell/fun_with_transports/apps/app_confbridge.c (original)
+++ team/qwell/fun_with_transports/apps/app_confbridge.c Thu Apr 25 14:51:16 2013
@@ -317,14 +317,47 @@
 static int conference_bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct confbridge_conference *conference = obj;
-	return ast_str_case_hash(conference->name);
+	const char *name = obj;
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = conference->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! \brief Comparison function used for conference bridges container */
 static int conference_bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct confbridge_conference *conference0 = obj, *conference1 = arg;
-	return (!strcasecmp(conference0->name, conference1->name) ? CMP_MATCH | CMP_STOP : 0);
+	const struct confbridge_conference *left = obj;
+	const struct confbridge_conference *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
 }
 
 const char *conf_get_sound(enum conf_sounds sound, struct bridge_profile_sounds *custom_sounds)
@@ -1233,12 +1266,9 @@
  */
 static struct confbridge_conference *join_conference_bridge(const char *conference_name, struct confbridge_user *user)
 {
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct post_join_action *action;
-	struct confbridge_conference tmp;
 	int max_members_reached = 0;
-
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
 
 	/* We explictly lock the conference bridges container ourselves so that other callers can not create duplicate conferences at the same */
 	ao2_lock(conference_bridges);
@@ -1246,8 +1276,7 @@
 	ast_debug(1, "Trying to find conference bridge '%s'\n", conference_name);
 
 	/* Attempt to find an existing conference bridge */
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
-
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (conference && conference->b_profile.max_members) {
 		max_members_reached = conference->b_profile.max_members > conference->activeusers ? 0 : 1;
 	}
@@ -2225,7 +2254,7 @@
 static char *complete_confbridge_name(const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	char *res = NULL;
 	int wordlen = strlen(word);
 	struct ao2_iterator iter;
@@ -2244,17 +2273,15 @@
 	return res;
 }
 
-static char *complete_confbridge_participant(const char *bridge_name, const char *line, const char *word, int pos, int state)
+static char *complete_confbridge_participant(const char *conference_name, const char *line, const char *word, int pos, int state)
 {
 	int which = 0;
 	RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
-	struct confbridge_conference tmp;
 	struct confbridge_user *user;
 	char *res = NULL;
 	int wordlen = strlen(word);
 
-	ast_copy_string(tmp.name, bridge_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return NULL;
 	}
@@ -2280,8 +2307,7 @@
 
 static char *handle_cli_confbridge_kick(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2304,8 +2330,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 		return CLI_SUCCESS;
@@ -2395,10 +2420,8 @@
 
 	if (a->argc == 3) {
 		struct confbridge_user *user;
-		struct confbridge_conference tmp;
-
-		ast_copy_string(tmp.name, a->argv[2], sizeof(tmp.name));
-		conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+		conference = ao2_find(conference_bridges, a->argv[2], OBJ_KEY);
 		if (!conference) {
 			ast_cli(a->fd, "No conference bridge named '%s' found!\n", a->argv[2]);
 			return CLI_SUCCESS;
@@ -2428,12 +2451,10 @@
  */
 static int generic_lock_unlock_helper(int lock, const char *conference_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int res = 0;
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2455,12 +2476,11 @@
  */
 static int generic_mute_unmute_helper(int mute, const char *conference_name, const char *chan_name)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
-	struct confbridge_user *user = NULL;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int res = 0;
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		return -1;
 	}
@@ -2607,8 +2627,7 @@
 static char *handle_cli_confbridge_start_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	const char *rec_file = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	switch (cmd) {
 	case CLI_INIT:
@@ -2633,8 +2652,7 @@
 		rec_file = a->argv[4];
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_FAILURE;
@@ -2665,8 +2683,7 @@
 
 static char *handle_cli_confbridge_stop_record(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int ret;
 
 	switch (cmd) {
@@ -2686,8 +2703,7 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_copy_string(tmp.name, a->argv[3], sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, a->argv[3], OBJ_KEY);
 	if (!conference) {
 		ast_cli(a->fd, "Conference not found.\n");
 		return CLI_SUCCESS;
@@ -2754,7 +2770,6 @@
 	const char *conference_name = astman_get_header(m, "Conference");
 	struct confbridge_user *user;
 	struct confbridge_conference *conference;
-	struct confbridge_conference tmp;
 	char id_text[80];
 	int total = 0;
 
@@ -2770,8 +2785,7 @@
 		astman_send_error(s, m, "No active conferences.");
 		return 0;
 	}
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2804,7 +2818,7 @@
 static int action_confbridgelistrooms(struct mansession *s, const struct message *m)
 {
 	const char *actionid = astman_get_header(m, "ActionID");
-	struct confbridge_conference *conference = NULL;
+	struct confbridge_conference *conference;
 	struct ao2_iterator iter;
 	char id_text[512] = "";
 	int totalitems = 0;
@@ -2930,8 +2944,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 	int found = 0;
 
 	if (ast_strlen_zero(conference_name)) {
@@ -2943,8 +2956,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -2965,8 +2977,7 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *recordfile = astman_get_header(m, "RecordFile");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -2977,8 +2988,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3011,8 +3021,7 @@
 static int action_confbridgestoprecord(struct mansession *s, const struct message *m)
 {
 	const char *conference_name = astman_get_header(m, "Conference");
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3023,8 +3032,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3048,9 +3056,8 @@
 {
 	const char *conference_name = astman_get_header(m, "Conference");
 	const char *channel = astman_get_header(m, "Channel");
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_conference tmp;
+	struct confbridge_user *user;
+	struct confbridge_conference *conference;
 
 	if (ast_strlen_zero(conference_name)) {
 		astman_send_error(s, m, "No Conference name provided.");
@@ -3065,8 +3072,7 @@
 		return 0;
 	}
 
-	ast_copy_string(tmp.name, conference_name, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, conference_name, OBJ_KEY);
 	if (!conference) {
 		astman_send_error(s, m, "No Conference by that name found.");
 		return 0;
@@ -3095,10 +3101,9 @@
 
 static int func_confbridge_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	char *parse = NULL;
-	struct confbridge_conference *conference = NULL;
-	struct confbridge_user *user = NULL;
-	struct confbridge_conference tmp;
+	char *parse;
+	struct confbridge_conference *conference;
+	struct confbridge_user *user;
 	int count = 0;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(type);
@@ -3114,12 +3119,7 @@
 	if (ast_strlen_zero(args.confno) || ast_strlen_zero(args.type)) {
 		return -1;
 	}
-	if (!ao2_container_count(conference_bridges)) {
-		snprintf(buf, len, "0");
-		return 0;
-	}
-	ast_copy_string(tmp.name, args.confno, sizeof(tmp.name));
-	conference = ao2_find(conference_bridges, &tmp, OBJ_POINTER);
+	conference = ao2_find(conference_bridges, args.confno, OBJ_KEY);
 	if (!conference) {
 		snprintf(buf, len, "0");
 		return 0;
@@ -3210,33 +3210,34 @@
 /*! \brief Called when module is being unloaded */
 static int unload_module(void)
 {
-	int res = ast_unregister_application(app);
+	ast_unregister_application(app);
 
 	ast_custom_function_unregister(&confbridge_function);
 	ast_custom_function_unregister(&confbridge_info_function);
 
-	ast_cli_unregister_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+	ast_cli_unregister_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
+	ast_manager_unregister("ConfbridgeList");
+	ast_manager_unregister("ConfbridgeListRooms");
+	ast_manager_unregister("ConfbridgeMute");
+	ast_manager_unregister("ConfbridgeUnmute");
+	ast_manager_unregister("ConfbridgeKick");
+	ast_manager_unregister("ConfbridgeUnlock");
+	ast_manager_unregister("ConfbridgeLock");
+	ast_manager_unregister("ConfbridgeStartRecord");
+	ast_manager_unregister("ConfbridgeStopRecord");
+	ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
 
 	/* Get rid of the conference bridges container. Since we only allow dynamic ones none will be active. */
-	ao2_ref(conference_bridges, -1);
+	ao2_cleanup(conference_bridges);
+	conference_bridges = NULL;
 
 	conf_destroy_config();
 
 	ast_channel_unregister(&record_tech);
 	record_tech.capabilities = ast_format_cap_destroy(record_tech.capabilities);
 
-	res |= ast_manager_unregister("ConfbridgeList");
-	res |= ast_manager_unregister("ConfbridgeListRooms");
-	res |= ast_manager_unregister("ConfbridgeMute");
-	res |= ast_manager_unregister("ConfbridgeUnmute");
-	res |= ast_manager_unregister("ConfbridgeKick");
-	res |= ast_manager_unregister("ConfbridgeUnlock");
-	res |= ast_manager_unregister("ConfbridgeLock");
-	res |= ast_manager_unregister("ConfbridgeStartRecord");
-	res |= ast_manager_unregister("ConfbridgeStopRecord");
-	res |= ast_manager_unregister("ConfbridgeSetSingleVideoSrc");
-
-	return res;
+	return 0;
 }
 
 /*!
@@ -3257,30 +3258,33 @@
 		ast_log(LOG_ERROR, "Unable to load config. Not loading module.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}
-	if ((ast_custom_function_register(&confbridge_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
-	if ((ast_custom_function_register(&confbridge_info_function))) {
-		return AST_MODULE_LOAD_FAILURE;
-	}
+
 	if (!(record_tech.capabilities = ast_format_cap_alloc())) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
 	ast_format_cap_add_all(record_tech.capabilities);
 	if (ast_channel_register(&record_tech)) {
 		ast_log(LOG_ERROR, "Unable to register ConfBridge recorder.\n");
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
+
 	/* Create a container to hold the conference bridges */
-	if (!(conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS, conference_bridge_hash_cb, conference_bridge_cmp_cb))) {
+	conference_bridges = ao2_container_alloc(CONFERENCE_BRIDGE_BUCKETS,
+		conference_bridge_hash_cb, conference_bridge_cmp_cb);
+	if (!conference_bridges) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
-	if (ast_register_application_xml(app, confbridge_exec)) {
-		ao2_ref(conference_bridges, -1);
-		return AST_MODULE_LOAD_FAILURE;
-	}
-
-	res |= ast_cli_register_multiple(cli_confbridge, sizeof(cli_confbridge) / sizeof(struct ast_cli_entry));
+
+	res |= ast_register_application_xml(app, confbridge_exec);
+
+	res |= ast_custom_function_register(&confbridge_function);
+	res |= ast_custom_function_register(&confbridge_info_function);
+
+	res |= ast_cli_register_multiple(cli_confbridge, ARRAY_LEN(cli_confbridge));
+
 	res |= ast_manager_register_xml("ConfbridgeList", EVENT_FLAG_REPORTING, action_confbridgelist);
 	res |= ast_manager_register_xml("ConfbridgeListRooms", EVENT_FLAG_REPORTING, action_confbridgelistrooms);
 	res |= ast_manager_register_xml("ConfbridgeMute", EVENT_FLAG_CALL, action_confbridgemute);
@@ -3292,6 +3296,7 @@
 	res |= ast_manager_register_xml("ConfbridgeStopRecord", EVENT_FLAG_CALL, action_confbridgestoprecord);
 	res |= ast_manager_register_xml("ConfbridgeSetSingleVideoSrc", EVENT_FLAG_CALL, action_confbridgesetsinglevideosrc);
 	if (res) {
+		unload_module();
 		return AST_MODULE_LOAD_FAILURE;
 	}
 

Modified: team/qwell/fun_with_transports/apps/app_meetme.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/app_meetme.c?view=diff&rev=386567&r1=386566&r2=386567
==============================================================================
--- team/qwell/fun_with_transports/apps/app_meetme.c (original)
+++ team/qwell/fun_with_transports/apps/app_meetme.c Thu Apr 25 14:51:16 2013
@@ -6437,17 +6437,18 @@
 
 static int sla_load_config(int reload);
 
-/*! \brief Check if we can do a reload of SLA, and do it if we can */
+/*!
+ * \internal
+ * \brief Check if we can do a reload of SLA, and do it if we can
+ * \pre sla.lock is locked.
+ */
 static void sla_check_reload(void)
 {
 	struct sla_station *station;
 	struct sla_trunk *trunk;
 
-	ast_mutex_lock(&sla.lock);
-
 	if (!AST_LIST_EMPTY(&sla.event_q) || !AST_LIST_EMPTY(&sla.ringing_trunks) 
 		|| !AST_LIST_EMPTY(&sla.ringing_stations)) {
-		ast_mutex_unlock(&sla.lock);
 		return;
 	}
 
@@ -6458,7 +6459,6 @@
 	}
 	AST_RWLIST_UNLOCK(&sla_stations);
 	if (station) {
-		ast_mutex_unlock(&sla.lock);
 		return;
 	}
 
@@ -6469,15 +6469,12 @@
 	}
 	AST_RWLIST_UNLOCK(&sla_trunks);
 	if (trunk) {
-		ast_mutex_unlock(&sla.lock);
 		return;
 	}
 
 	/* yay */
 	sla_load_config(1);
 	sla.reload = 0;
-
-	ast_mutex_unlock(&sla.lock);
 }
 
 static void *sla_thread(void *data)

Modified: team/qwell/fun_with_transports/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/apps/confbridge/conf_config_parser.c?view=diff&rev=386567&r1=386566&r2=386567
==============================================================================
--- team/qwell/fun_with_transports/apps/confbridge/conf_config_parser.c (original)
+++ team/qwell/fun_with_transports/apps/confbridge/conf_config_parser.c Thu Apr 25 14:51:16 2013
@@ -648,32 +648,95 @@
 /*! bridge profile container functions */
 static int bridge_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct bridge_profile *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct bridge_profile *left = obj;
+	const struct bridge_profile *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int bridge_hash_cb(const void *obj, const int flags)
 {
 	const struct bridge_profile *b_profile = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : b_profile->name);
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = b_profile->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! menu container functions */
 static int menu_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct conf_menu *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct conf_menu *left = obj;
+	const struct conf_menu *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int menu_hash_cb(const void *obj, const int flags)
 {
 	const struct conf_menu *menu = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : menu->name);
-}
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = menu->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
+}
+
 static void menu_destructor(void *obj)
 {
 	struct conf_menu *menu = obj;
@@ -688,16 +751,47 @@
 /*! User profile container functions */
 static int user_cmp_cb(void *obj, void *arg, int flags)
 {
-	const struct user_profile *entry1 = obj, *entry2 = arg;
-	const char *name = arg;
-	return (!strcasecmp(entry1->name, flags & OBJ_KEY ? name : entry2->name)) ?
-		CMP_MATCH | CMP_STOP : 0;
-}
+	const struct user_profile *left = obj;
+	const struct user_profile *right = arg;
+	const char *right_name = arg;
+	int cmp;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		right_name = right->name;
+		/* Fall through */
+	case OBJ_KEY:
+		cmp = strcasecmp(left->name, right_name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		cmp = strncasecmp(left->name, right_name, strlen(right_name));
+		break;
+	}
+	return cmp ? 0 : CMP_MATCH;
+}
+
 static int user_hash_cb(const void *obj, const int flags)
 {
 	const struct user_profile *u_profile = obj;
 	const char *name = obj;
-	return ast_str_case_hash(flags & OBJ_KEY ? name : u_profile->name);
+	int hash;
+
+	switch (flags & (OBJ_POINTER | OBJ_KEY | OBJ_PARTIAL_KEY)) {
+	default:
+	case OBJ_POINTER:
+		name = u_profile->name;
+		/* Fall through */
+	case OBJ_KEY:
+		hash = ast_str_case_hash(name);
+		break;
+	case OBJ_PARTIAL_KEY:
+		/* Should never happen in hash callback. */
+		ast_assert(0);
+		hash = 0;
+		break;
+	}
+	return hash;
 }
 
 /*! Bridge Profile Sounds functions */

Modified: team/qwell/fun_with_transports/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/fun_with_transports/channels/chan_gulp.c?view=diff&rev=386567&r1=386566&r2=386567
==============================================================================
--- team/qwell/fun_with_transports/channels/chan_gulp.c (original)
+++ team/qwell/fun_with_transports/channels/chan_gulp.c Thu Apr 25 14:51:16 2013
@@ -824,6 +824,67 @@

[... 2104 lines stripped ...]



More information about the asterisk-commits mailing list