[asterisk-commits] oej: branch oej/obproxy r99019 - in /team/oej/obproxy: ./ apps/ build_tools/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 18 04:30:40 CST 2008


Author: oej
Date: Fri Jan 18 04:30:39 2008
New Revision: 99019

URL: http://svn.digium.com/view/asterisk?view=rev&rev=99019
Log:
Resolve conflict in this branch

Added:
    team/oej/obproxy/include/asterisk/audiohook.h
      - copied unchanged from r99014, branches/1.4/include/asterisk/audiohook.h
    team/oej/obproxy/main/audiohook.c
      - copied unchanged from r99014, branches/1.4/main/audiohook.c
Removed:
    team/oej/obproxy/include/asterisk/chanspy.h
Modified:
    team/oej/obproxy/   (props changed)
    team/oej/obproxy/.cleancount
    team/oej/obproxy/apps/app_chanspy.c
    team/oej/obproxy/apps/app_followme.c
    team/oej/obproxy/apps/app_meetme.c
    team/oej/obproxy/apps/app_mixmonitor.c
    team/oej/obproxy/apps/app_queue.c
    team/oej/obproxy/apps/app_voicemail.c
    team/oej/obproxy/build_tools/menuselect-deps.in
    team/oej/obproxy/channels/chan_iax2.c
    team/oej/obproxy/channels/chan_local.c
    team/oej/obproxy/channels/chan_sip.c
    team/oej/obproxy/codecs/codec_speex.c
    team/oej/obproxy/codecs/codec_zap.c
    team/oej/obproxy/codecs/gsm/Makefile
    team/oej/obproxy/configs/zapata.conf.sample
    team/oej/obproxy/configure
    team/oej/obproxy/configure.ac
    team/oej/obproxy/doc/security.txt
    team/oej/obproxy/include/asterisk/autoconfig.h.in
    team/oej/obproxy/include/asterisk/channel.h
    team/oej/obproxy/include/asterisk/frame.h
    team/oej/obproxy/include/asterisk/translate.h
    team/oej/obproxy/main/Makefile
    team/oej/obproxy/main/abstract_jb.c
    team/oej/obproxy/main/asterisk.c
    team/oej/obproxy/main/channel.c
    team/oej/obproxy/main/dial.c
    team/oej/obproxy/main/frame.c
    team/oej/obproxy/main/http.c
    team/oej/obproxy/main/rtp.c
    team/oej/obproxy/main/translate.c
    team/oej/obproxy/makeopts.in
    team/oej/obproxy/pbx/pbx_dundi.c
    team/oej/obproxy/res/res_agi.c
    team/oej/obproxy/res/res_odbc.c

Propchange: team/oej/obproxy/
------------------------------------------------------------------------------
    automerge = http://www.codename-pineapple.org/

Propchange: team/oej/obproxy/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jan 18 04:30:39 2008
@@ -1,1 +1,1 @@
-/branches/1.4:1-98108
+/branches/1.4:1-99018

Modified: team/oej/obproxy/.cleancount
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/.cleancount?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/.cleancount (original)
+++ team/oej/obproxy/.cleancount Fri Jan 18 04:30:39 2008
@@ -1,1 +1,1 @@
-30
+32

Modified: team/oej/obproxy/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_chanspy.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_chanspy.c (original)
+++ team/oej/obproxy/apps/app_chanspy.c Fri Jan 18 04:30:39 2008
@@ -40,7 +40,7 @@
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
+#include "asterisk/audiohook.h"
 #include "asterisk/features.h"
 #include "asterisk/options.h"
 #include "asterisk/app.h"
@@ -143,7 +143,8 @@
 
 struct chanspy_translation_helper {
 	/* spy data */
-	struct ast_channel_spy spy;
+	struct ast_audiohook spy_audiohook;
+	struct ast_audiohook whisper_audiohook;
 	int fd;
 	int volfactor;
 };
@@ -163,15 +164,17 @@
 {
 	struct chanspy_translation_helper *csth = data;
 	struct ast_frame *f;
-		
-	if (csth->spy.status != CHANSPY_RUNNING)
-		/* Channel is already gone more than likely */
+
+	ast_audiohook_lock(&csth->spy_audiohook);
+	if (csth->spy_audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
+		ast_audiohook_unlock(&csth->spy_audiohook);
 		return -1;
-
-	ast_mutex_lock(&csth->spy.lock);
-	f = ast_channel_spy_read_frame(&csth->spy, samples);
-	ast_mutex_unlock(&csth->spy.lock);
-		
+	}
+
+	f = ast_audiohook_read_frame(&csth->spy_audiohook, samples, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR);
+
+	ast_audiohook_unlock(&csth->spy_audiohook);
+
 	if (!f)
 		return 0;
 		
@@ -194,50 +197,19 @@
 	.generate = spy_generate, 
 };
 
-static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_channel_spy *spy) 
+static int start_spying(struct ast_channel *chan, struct ast_channel *spychan, struct ast_audiohook *audiohook) 
 {
 	int res;
 	struct ast_channel *peer;
 
 	ast_log(LOG_NOTICE, "Attaching %s to %s\n", spychan->name, chan->name);
 
-	ast_channel_lock(chan);
-	res = ast_channel_spy_add(chan, spy);
-	ast_channel_unlock(chan);
+	res = ast_audiohook_attach(chan, audiohook);
 
 	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
 		ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);	
 
 	return res;
-}
-
-/* Map 'volume' levels from -4 through +4 into
-   decibel (dB) settings for channel drivers
-*/
-static signed char volfactor_map[] = {
-	-24,
-	-18,
-	-12,
-	-6,
-	0,
-	6,
-	12,
-	18,
-	24,
-};
-
-/* attempt to set the desired gain adjustment via the channel driver;
-   if successful, clear it out of the csth structure so the
-   generator will not attempt to do the adjustment itself
-*/
-static void set_volume(struct ast_channel *chan, struct chanspy_translation_helper *csth)
-{
-	signed char volume_adjust = volfactor_map[csth->volfactor + 4];
-
-	if (!ast_channel_setoption(chan, AST_OPTION_TXGAIN, &volume_adjust, sizeof(volume_adjust), 0))
-		csth->volfactor = 0;
-	csth->spy.read_vol_adjustment = csth->volfactor;
-	csth->spy.write_vol_adjustment = csth->volfactor;
 }
 
 static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd,
@@ -258,49 +230,27 @@
 		ast_verbose(VERBOSE_PREFIX_2 "Spying on channel %s\n", name);
 
 	memset(&csth, 0, sizeof(csth));
-	ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO);
-	ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE);
-	ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO);
-	csth.spy.type = "ChanSpy";
-	csth.spy.status = CHANSPY_RUNNING;
-	csth.spy.read_queue.format = AST_FORMAT_SLINEAR;
-	csth.spy.write_queue.format = AST_FORMAT_SLINEAR;
-	ast_mutex_init(&csth.spy.lock);
+	
+	ast_audiohook_init(&csth.spy_audiohook, AST_AUDIOHOOK_TYPE_SPY, "ChanSpy");
+	
+	if (start_spying(spyee, chan, &csth.spy_audiohook)) {
+		ast_audiohook_destroy(&csth.spy_audiohook);
+		return 0;
+	}
+	
+	if (ast_test_flag(flags, OPTION_WHISPER)) {
+		ast_audiohook_init(&csth.whisper_audiohook, AST_AUDIOHOOK_TYPE_WHISPER, "ChanSpy");
+		start_spying(spyee, chan, &csth.whisper_audiohook);
+	}
+	
 	csth.volfactor = *volfactor;
-	set_volume(chan, &csth);
+	
 	if (csth.volfactor) {
-		ast_set_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-		csth.spy.read_vol_adjustment = csth.volfactor;
-		ast_set_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-		csth.spy.write_vol_adjustment = csth.volfactor;
-	}
+		csth.spy_audiohook.options.read_volume = csth.volfactor;
+		csth.spy_audiohook.options.write_volume = csth.volfactor;
+	}
+	
 	csth.fd = fd;
-	
-	if (start_spying(spyee, chan, &csth.spy)) {
-		ast_mutex_destroy(&csth.spy.lock);
-		return 0;
-	}
-
-	if (ast_test_flag(flags, OPTION_WHISPER)) {
-		struct ast_filestream *beepstream;
-		int old_write_format = 0;
-
-		ast_channel_whisper_start(csth.spy.chan);
-		old_write_format = chan->writeformat;
-		if ((beepstream = ast_openstream_full(chan, "beep", chan->language, 1))) {
-			struct ast_frame *f;
-
-			while ((f = ast_readframe(beepstream))) {
-				ast_channel_whisper_feed(csth.spy.chan, f);
-				ast_frfree(f);
-			}
-
-			ast_closestream(beepstream);
-			chan->stream = NULL;
-		}
-		if (old_write_format)
-			ast_set_write_format(chan, old_write_format);
-	}
 
 	if (ast_test_flag(flags, OPTION_PRIVATE))
 		silgen = ast_channel_start_silence_generator(chan);
@@ -321,17 +271,16 @@
 	   has arrived, since the spied-on channel could have gone away while
 	   we were waiting
 	*/
-	while ((res = ast_waitfor(chan, -1) > -1) &&
-	       csth.spy.status == CHANSPY_RUNNING &&
-	       csth.spy.chan) {
+	while ((res = ast_waitfor(chan, -1) > -1) && csth.spy_audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
 		if (!(f = ast_read(chan)) || ast_check_hangup(chan)) {
 			running = -1;
 			break;
 		}
 
-		if (ast_test_flag(flags, OPTION_WHISPER) &&
-		    (f->frametype == AST_FRAME_VOICE)) {
-			ast_channel_whisper_feed(csth.spy.chan, f);
+		if (ast_test_flag(flags, OPTION_WHISPER) && (f->frametype == AST_FRAME_VOICE)) {
+			ast_audiohook_lock(&csth.whisper_audiohook);
+			ast_audiohook_write_frame(&csth.whisper_audiohook, AST_AUDIOHOOK_DIRECTION_WRITE, f);
+			ast_audiohook_unlock(&csth.whisper_audiohook);
 			ast_frfree(f);
 			continue;
 		}
@@ -364,38 +313,29 @@
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "Setting spy volume on %s to %d\n", chan->name, *volfactor);
 			csth.volfactor = *volfactor;
-			set_volume(chan, &csth);
-			if (csth.volfactor) {
-				ast_set_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-				csth.spy.read_vol_adjustment = csth.volfactor;
-				ast_set_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-				csth.spy.write_vol_adjustment = csth.volfactor;
-			} else {
-				ast_clear_flag(&csth.spy, CHANSPY_READ_VOLADJUST);
-				ast_clear_flag(&csth.spy, CHANSPY_WRITE_VOLADJUST);
-			}
+			csth.spy_audiohook.options.read_volume = csth.volfactor;
+			csth.spy_audiohook.options.write_volume = csth.volfactor;
 		} else if (res >= '0' && res <= '9') {
 			inp[x++] = res;
 		}
 	}
-
-	if (ast_test_flag(flags, OPTION_WHISPER) && csth.spy.chan)
-		ast_channel_whisper_stop(csth.spy.chan);
 
 	if (ast_test_flag(flags, OPTION_PRIVATE))
 		ast_channel_stop_silence_generator(chan, silgen);
 	else
 		ast_deactivate_generator(chan);
 
-	csth.spy.status = CHANSPY_DONE;
-
-	/* If a channel still exists on our spy structure then we need to remove ourselves */
-	if (csth.spy.chan) {
-		ast_channel_lock(csth.spy.chan);
-		ast_channel_spy_remove(csth.spy.chan, &csth.spy);
-		ast_channel_unlock(csth.spy.chan);
-	}
-	ast_channel_spy_free(&csth.spy);
+	if (ast_test_flag(flags, OPTION_WHISPER)) {
+		ast_audiohook_lock(&csth.whisper_audiohook);
+		ast_audiohook_detach(&csth.whisper_audiohook);
+		ast_audiohook_unlock(&csth.whisper_audiohook);
+		ast_audiohook_destroy(&csth.whisper_audiohook);
+	}
+	
+	ast_audiohook_lock(&csth.spy_audiohook);
+	ast_audiohook_detach(&csth.spy_audiohook);
+	ast_audiohook_unlock(&csth.spy_audiohook);
+	ast_audiohook_destroy(&csth.spy_audiohook);
 	
 	if (option_verbose >= 2)
 		ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);

Modified: team/oej/obproxy/apps/app_followme.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_followme.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_followme.c (original)
+++ team/oej/obproxy/apps/app_followme.c Fri Jan 18 04:30:39 2008
@@ -1048,7 +1048,6 @@
 			pbx_builtin_setvar_helper(caller, "ANSWEREDTIME", toast);
 			if (outbound)
 				ast_hangup(outbound);
-			res = 1;
 		}
 	}
 	outrun:

Modified: team/oej/obproxy/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_meetme.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_meetme.c (original)
+++ team/oej/obproxy/apps/app_meetme.c Fri Jan 18 04:30:39 2008
@@ -1578,7 +1578,7 @@
 		goto outrun;
 	}
 
-	retryzap = (strcasecmp(chan->tech->type, "Zap") || (chan->spies || chan->monitor) ? 1 : 0);
+	retryzap = (strcasecmp(chan->tech->type, "Zap") || (chan->audiohooks || chan->monitor) ? 1 : 0);
 	user->zapchannel = !retryzap;
 
  zapretry:
@@ -1896,14 +1896,14 @@
 				break;
 
 			if (c) {
-				if (c->fds[0] != origfd || (user->zapchannel && (c->spies || c->monitor))) {
+				if (c->fds[0] != origfd || (user->zapchannel && (c->audiohooks || c->monitor))) {
 					if (using_pseudo) {
 						/* Kill old pseudo */
 						close(fd);
 						using_pseudo = 0;
 					}
 					ast_log(LOG_DEBUG, "Ooh, something swapped out under us, starting over\n");
-					retryzap = (strcasecmp(c->tech->type, "Zap") || (c->spies || c->monitor) ? 1 : 0);
+					retryzap = (strcasecmp(c->tech->type, "Zap") || (c->audiohooks || c->monitor) ? 1 : 0);
 					user->zapchannel = !retryzap;
 					goto zapretry;
 				}

Modified: team/oej/obproxy/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_mixmonitor.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_mixmonitor.c (original)
+++ team/oej/obproxy/apps/app_mixmonitor.c Fri Jan 18 04:30:39 2008
@@ -45,7 +45,7 @@
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
-#include "asterisk/chanspy.h"
+#include "asterisk/audiohook.h"
 #include "asterisk/pbx.h"
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
@@ -93,11 +93,12 @@
 static const char *mixmonitor_spy_type = "MixMonitor";
 
 struct mixmonitor {
-	struct ast_channel_spy spy;
+	struct ast_audiohook audiohook;
 	char *filename;
 	char *post_process;
 	char *name;
 	unsigned int flags;
+	struct ast_channel *chan;
 };
 
 enum {
@@ -123,7 +124,7 @@
 	AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
 });
 
-static int startmon(struct ast_channel *chan, struct ast_channel_spy *spy) 
+static int startmon(struct ast_channel *chan, struct ast_audiohook *audiohook) 
 {
 	struct ast_channel *peer;
 	int res;
@@ -131,9 +132,7 @@
 	if (!chan)
 		return -1;
 
-	ast_channel_lock(chan);
-	res = ast_channel_spy_add(chan, spy);
-	ast_channel_unlock(chan);
+	res = ast_audiohook_attach(chan, audiohook);
 
 	if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
 		ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);	
@@ -146,7 +145,6 @@
 static void *mixmonitor_thread(void *obj) 
 {
 	struct mixmonitor *mixmonitor = obj;
-	struct ast_frame *f = NULL;
 	struct ast_filestream *fs = NULL;
 	unsigned int oflags;
 	char *ext;
@@ -155,58 +153,48 @@
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "Begin MixMonitor Recording %s\n", mixmonitor->name);
 	
-	ast_mutex_lock(&mixmonitor->spy.lock);
-
-	while (mixmonitor->spy.chan) {
-		struct ast_frame *next;
-		int write;
-
-		ast_channel_spy_trigger_wait(&mixmonitor->spy);
-		
-		if (!mixmonitor->spy.chan || mixmonitor->spy.status != CHANSPY_RUNNING)
+	ast_audiohook_lock(&mixmonitor->audiohook);
+
+	while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING) {
+		struct ast_frame *fr = NULL;
+		
+		ast_audiohook_trigger_wait(&mixmonitor->audiohook);
+		
+		if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING)
 			break;
 		
-		while (1) {
-			if (!(f = ast_channel_spy_read_frame(&mixmonitor->spy, SAMPLES_PER_FRAME)))
-				break;
-
-			write = (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) ||
-				 ast_bridged_channel(mixmonitor->spy.chan));
-
-			/* it is possible for ast_channel_spy_read_frame() to return a chain
-			   of frames if a queue flush was necessary, so process them
-			*/
-			for (; f; f = next) {
-				next = AST_LIST_NEXT(f, frame_list);
-				if (write && errflag == 0) {
-					if (!fs) {
-						/* Determine creation flags and filename plus extension for filestream */
-						oflags = O_CREAT | O_WRONLY;
-						oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
-
-						if ((ext = strrchr(mixmonitor->filename, '.')))
-							*(ext++) = '\0';
-						else
-							ext = "raw";
-
-						/* Move onto actually creating the filestream */
-						if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) {
-							ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
-							errflag = 1;
-						}
-
-					}
-					if (fs)
-						ast_writestream(fs, f);
+		if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
+			continue;
+		
+		if (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) || ast_bridged_channel(mixmonitor->chan)) {
+			/* Initialize the file if not already done so */
+			if (!fs && !errflag) {
+				oflags = O_CREAT | O_WRONLY;
+				oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
+				
+				if ((ext = strrchr(mixmonitor->filename, '.')))
+					*(ext++) = '\0';
+				else
+					ext = "raw";
+				
+				if (!(fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644))) {
+					ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
+					errflag = 1;
 				}
-				ast_frame_free(f, 0);
 			}
+
+			/* Write out the frame */
+			if (fs)
+				ast_writestream(fs, fr);
 		}
-	}
-
-	ast_mutex_unlock(&mixmonitor->spy.lock);
-
-	ast_channel_spy_free(&mixmonitor->spy);
+
+		/* All done! free it. */
+		ast_frame_free(fr, 0);
+	}
+
+	ast_audiohook_detach(&mixmonitor->audiohook);
+	ast_audiohook_unlock(&mixmonitor->audiohook);
+	ast_audiohook_destroy(&mixmonitor->audiohook);
 	
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", mixmonitor->name);
@@ -271,27 +259,23 @@
 	strcpy(mixmonitor->filename, filename);
 
 	/* Setup the actual spy before creating our thread */
-	ast_set_flag(&mixmonitor->spy, CHANSPY_FORMAT_AUDIO);
-	ast_set_flag(&mixmonitor->spy, CHANSPY_MIXAUDIO);
-	mixmonitor->spy.type = mixmonitor_spy_type;
-	mixmonitor->spy.status = CHANSPY_RUNNING;
-	mixmonitor->spy.read_queue.format = AST_FORMAT_SLINEAR;
-	mixmonitor->spy.write_queue.format = AST_FORMAT_SLINEAR;
-	if (readvol) {
-		ast_set_flag(&mixmonitor->spy, CHANSPY_READ_VOLADJUST);
-		mixmonitor->spy.read_vol_adjustment = readvol;
-	}
-	if (writevol) {
-		ast_set_flag(&mixmonitor->spy, CHANSPY_WRITE_VOLADJUST);
-		mixmonitor->spy.write_vol_adjustment = writevol;
-	}
-	ast_mutex_init(&mixmonitor->spy.lock);
-
-	if (startmon(chan, &mixmonitor->spy)) {
+	if (ast_audiohook_init(&mixmonitor->audiohook, AST_AUDIOHOOK_TYPE_SPY, mixmonitor_spy_type)) {
+		free(mixmonitor);
+		return;
+	}
+	
+	ast_set_flag(&mixmonitor->audiohook, AST_AUDIOHOOK_TRIGGER_WRITE);
+	
+	if (readvol)
+		mixmonitor->audiohook.options.read_volume = readvol;
+	if (writevol)
+		mixmonitor->audiohook.options.write_volume = writevol;
+
+	if (startmon(chan, &mixmonitor->audiohook)) {
 		ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
-			mixmonitor->spy.type, chan->name);
+			mixmonitor_spy_type, chan->name);
 		/* Since we couldn't add ourselves - bail out! */
-		ast_mutex_destroy(&mixmonitor->spy.lock);
+		ast_audiohook_destroy(&mixmonitor->audiohook);
 		free(mixmonitor);
 		return;
 	}
@@ -391,9 +375,7 @@
 
 	u = ast_module_user_add(chan);
 
-	ast_channel_lock(chan);
-	ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
-	ast_channel_unlock(chan);
+	ast_audiohook_detach_source(chan, mixmonitor_spy_type);
 
 	ast_module_user_remove(u);
 
@@ -415,7 +397,7 @@
 	if (!strcasecmp(argv[1], "start"))
 		mixmonitor_exec(chan, argv[3]);
 	else if (!strcasecmp(argv[1], "stop"))
-		ast_channel_spy_stop_by_type(chan, mixmonitor_spy_type);
+		ast_audiohook_detach_source(chan, mixmonitor_spy_type);
 
 	ast_channel_unlock(chan);
 

Modified: team/oej/obproxy/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_queue.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_queue.c (original)
+++ team/oej/obproxy/apps/app_queue.c Fri Jan 18 04:30:39 2008
@@ -795,6 +795,17 @@
 	q->context[0] = '\0';
 	q->monfmt[0] = '\0';
 	q->periodicannouncefrequency = 0;
+	q->reportholdtime = 0;
+	q->monjoin = 0;
+	q->wrapuptime = 0;
+	q->autofill = 0;
+	q->joinempty = 0;
+	q->leavewhenempty = 0;
+	q->memberdelay = 0;
+	q->maskmemberstatus = 0;
+	q->eventwhencalled = 0;
+	q->weight = 0;
+	q->timeoutrestart = 0;
 	if (!q->members)
 		q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn);
 	q->membercount = 0;

Modified: team/oej/obproxy/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/apps/app_voicemail.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/apps/app_voicemail.c (original)
+++ team/oej/obproxy/apps/app_voicemail.c Fri Jan 18 04:30:39 2008
@@ -8812,8 +8812,10 @@
 			if (vlist->vms->imapuser) {
 				if (!strcmp(vlist->vms->imapuser,user)) {
 					if (interactive == 2) {
+						ast_mutex_unlock(&vmstate_lock);
 						return vlist->vms;
 					} else if (vlist->vms->interactive == interactive) {
+						ast_mutex_unlock(&vmstate_lock);
 						return vlist->vms;
 					}
 				}
@@ -8849,6 +8851,7 @@
 				if (!strcmp(vlist->vms->username,mailbox) && vlist->vms->interactive == interactive) {
 					if (option_debug > 2)
 						ast_log(LOG_DEBUG, "	Found it!\n");
+					ast_mutex_unlock(&vmstate_lock);
 					return vlist->vms;
 				}
 			} else {

Modified: team/oej/obproxy/build_tools/menuselect-deps.in
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/build_tools/menuselect-deps.in?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/build_tools/menuselect-deps.in (original)
+++ team/oej/obproxy/build_tools/menuselect-deps.in Fri Jan 18 04:30:39 2008
@@ -22,6 +22,7 @@
 PRI=@PBX_PRI@
 RADIUS=@PBX_RADIUS@
 SPEEX=@PBX_SPEEX@
+SPEEXDSP=@PBX_SPEEXDSP@
 SQLITE=@PBX_SQLITE@
 SSL=@PBX_OPENSSL@
 TONEZONE=@PBX_TONEZONE@

Modified: team/oej/obproxy/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/channels/chan_iax2.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/channels/chan_iax2.c (original)
+++ team/oej/obproxy/channels/chan_iax2.c Fri Jan 18 04:30:39 2008
@@ -1801,7 +1801,7 @@
 	  the IAX thread with the iaxsl lock held. */
 	struct iax_frame *fr = data;
 	fr->retrans = -1;
-	fr->af.has_timing_info = 0;
+	ast_clear_flag(&fr->af, AST_FRFLAG_HAS_TIMING_INFO);
 	if (iaxs[fr->callno] && !ast_test_flag(iaxs[fr->callno], IAX_ALREADYGONE))
 		iax2_queue_frame(fr->callno, &fr->af);
 	/* Free our iax frame */
@@ -2683,7 +2683,7 @@
 	if (peername) {
 		var = ast_load_realtime("iaxpeers", "name", peername, "host", "dynamic", NULL);
 		if (!var && sin)
-			var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr));
+			var = ast_load_realtime("iaxpeers", "name", peername, "host", ast_inet_ntoa(sin->sin_addr), NULL);
 	} else if (sin) {
 		char porta[25];
 		sprintf(porta, "%d", ntohs(sin->sin_port));
@@ -2802,7 +2802,7 @@
 
 	var = ast_load_realtime("iaxusers", "name", username, "host", "dynamic", NULL);
 	if (!var)
-		var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr));
+		var = ast_load_realtime("iaxusers", "name", username, "host", ast_inet_ntoa(sin->sin_addr), NULL);
 	if (!var && sin) {
 		char porta[6];
 		snprintf(porta, sizeof(porta), "%d", ntohs(sin->sin_port));
@@ -2896,12 +2896,13 @@
 	char mohsuggest[MAX_MUSICCLASS];
 };
 
-static int create_addr(const char *peername, struct sockaddr_in *sin, struct create_addr_info *cai)
+static int create_addr(const char *peername, struct ast_channel *c, struct sockaddr_in *sin, struct create_addr_info *cai)
 {
 	struct ast_hostent ahp;
 	struct hostent *hp;
 	struct iax2_peer *peer;
 	int res = -1;
+	struct ast_codec_pref ourprefs;
 
 	ast_clear_flag(cai, IAX_SENDANI | IAX_TRUNK);
 	cai->sockfd = defaultsockfd;
@@ -2916,7 +2917,11 @@
 			memcpy(&sin->sin_addr, hp->h_addr, sizeof(sin->sin_addr));
 			sin->sin_port = htons(IAX_DEFAULT_PORTNO);
 			/* use global iax prefs for unknown peer/user */
-			ast_codec_pref_convert(&prefs, cai->prefs, sizeof(cai->prefs), 1);
+			/* But move the calling channel's native codec to the top of the preference list */
+			memcpy(&ourprefs, &prefs, sizeof(ourprefs));
+			if (c)
+				ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+			ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
 			return 0;
 		} else {
 			ast_log(LOG_WARNING, "No such host: %s\n", peername);
@@ -2940,7 +2945,13 @@
 	cai->encmethods = peer->encmethods;
 	cai->sockfd = peer->sockfd;
 	cai->adsi = peer->adsi;
-	ast_codec_pref_convert(&peer->prefs, cai->prefs, sizeof(cai->prefs), 1);
+	memcpy(&ourprefs, &peer->prefs, sizeof(ourprefs));
+	/* Move the calling channel's native codec to the top of the preference list */
+	if (c) {
+		ast_log(LOG_DEBUG, "prepending %x to prefs\n", c->nativeformats);
+		ast_codec_pref_prepend(&ourprefs, c->nativeformats, 1);
+	}
+	ast_codec_pref_convert(&ourprefs, cai->prefs, sizeof(cai->prefs), 1);
 	ast_copy_string(cai->context, peer->context, sizeof(cai->context));
 	ast_copy_string(cai->peercontext, peer->peercontext, sizeof(cai->peercontext));
 	ast_copy_string(cai->username, peer->username, sizeof(cai->username));
@@ -3115,7 +3126,7 @@
 	if (!pds.exten)
 		pds.exten = defaultrdest;
 
-	if (create_addr(pds.peer, &sin, &cai)) {
+	if (create_addr(pds.peer, c, &sin, &cai)) {
 		ast_log(LOG_WARNING, "No address associated with '%s'\n", pds.peer);
 		return -1;
 	}
@@ -8499,7 +8510,7 @@
 	if (end) {
 		memcpy(&sin, end, sizeof(sin));
 		cai.sockfd = sockfd;
-	} else if (create_addr(dest, &sin, &cai))
+	} else if (create_addr(dest, NULL, &sin, &cai))
 		return -1;
 
 	/* Build the rest of the message */
@@ -8722,7 +8733,7 @@
 	       
 	
 	/* Populate our address from the given */
-	if (create_addr(pds.peer, &sin, &cai)) {
+	if (create_addr(pds.peer, NULL, &sin, &cai)) {
 		*cause = AST_CAUSE_UNREGISTERED;
 		return NULL;
 	}
@@ -10037,7 +10048,7 @@
 	parse_dial_string(tmpstr, &pds);
 
 	/* Populate our address from the given */
-	if (create_addr(pds.peer, &sin, &cai))
+	if (create_addr(pds.peer, NULL, &sin, &cai))
 		return -1;
 
 	if (option_debug)

Modified: team/oej/obproxy/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/channels/chan_local.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/channels/chan_local.c (original)
+++ team/oej/obproxy/channels/chan_local.c Fri Jan 18 04:30:39 2008
@@ -493,8 +493,16 @@
 	isoutbound = IS_OUTBOUND(ast, p);
 	if (isoutbound) {
 		const char *status = pbx_builtin_getvar_helper(p->chan, "DIALSTATUS");
-		if ((status) && (p->owner))
+		if ((status) && (p->owner)) {
+			/* Deadlock avoidance */
+			while (ast_channel_trylock(p->owner)) {
+				ast_mutex_unlock(&p->lock);
+				usleep(1);
+				ast_mutex_lock(&p->lock);
+			}
 			pbx_builtin_setvar_helper(p->owner, "CHANLOCALSTATUS", status);
+			ast_channel_unlock(p->owner);
+		}
 		p->chan = NULL;
 		ast_clear_flag(p, LOCAL_LAUNCHED_PBX);
 		ast_module_user_remove(p->u_chan);

Modified: team/oej/obproxy/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/obproxy/channels/chan_sip.c?view=diff&rev=99019&r1=99018&r2=99019
==============================================================================
--- team/oej/obproxy/channels/chan_sip.c (original)
+++ team/oej/obproxy/channels/chan_sip.c Fri Jan 18 04:30:39 2008
@@ -150,7 +150,6 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/translate.h"
 #include "asterisk/dnsmgr.h"
-#include "asterisk/astobj2.h"
 
 #ifndef FALSE
 #define FALSE    0
@@ -1025,7 +1024,7 @@
 	struct sip_registry *registry;		/*!< If this is a REGISTER dialog, to which registry */
 	struct ast_rtp *rtp;			/*!< RTP Session */
 	struct ast_rtp *vrtp;			/*!< Video RTP session */
-	struct ao2_container *packets;		/*!< Packets scheduled for re-transmission */
+	struct sip_pkt *packets;		/*!< Packets scheduled for re-transmission */
 	struct sip_history_head *history;	/*!< History of this SIP dialog */
 	size_t history_entries;			/*!< Number of entires in the history */
 	struct ast_variable *chanvars;		/*!< Channel variables to set for inbound call */
@@ -1042,6 +1041,7 @@
 
 /*! \brief sip packet - raw format for outbound packets that are sent or scheduled for transmission */
 struct sip_pkt {
+	struct sip_pkt *next;			/*!< Next packet in linked list */
 	int retrans;				/*!< Retransmission number */
 	int method;				/*!< SIP method for this packet */
 	int seqno;				/*!< Sequence number */
@@ -1924,7 +1924,7 @@
 	if (!(hist = ast_calloc(1, sizeof(*hist) + l)))
 		return;
 	if (!p->history && !(p->history = ast_calloc(1, sizeof(*p->history)))) {
-		ast_free(hist);
+		free(hist);
 		return;
 	}
 	memcpy(hist->event, buf, l);
@@ -1961,15 +1961,12 @@
 /*! \brief Retransmit SIP message if no answer (Called from scheduler) */
 static int retrans_pkt(const void *data)
 {
-	struct sip_pkt *pkt = (struct sip_pkt *)data, *prev;
+	struct sip_pkt *pkt = (struct sip_pkt *)data, *prev, *cur = NULL;
 	int reschedule = DEFAULT_RETRANS;
 	int xmitres = 0;
 
-	ao2_ref(pkt, 1); /* Make sure this cannot go away while we're using it */
-
 	/* Lock channel PVT */
-	if (pkt->owner)
-		ast_mutex_lock(&pkt->owner->lock);
+	ast_mutex_lock(&pkt->owner->lock);
 
 	if (pkt->retrans < MAX_RETRANS) {
 		pkt->retrans++;
@@ -1997,7 +1994,7 @@
  				ast_log(LOG_DEBUG, "** SIP timers: Rescheduling retransmission %d to %d ms (t1 %d ms (Retrans id #%d)) \n", pkt->retrans +1, siptimer_a, pkt->timer_t1, pkt->retransid);
  		} 
 
-		if (pkt->owner && sip_debug_test_pvt(pkt->owner)) {
+		if (sip_debug_test_pvt(pkt->owner)) {
 			const struct sockaddr_in *dst = sip_real_dst(pkt->owner);
 			ast_verbose("Retransmitting #%d (%s) to %s:%d:\n%s\n---\n",
 				pkt->retrans, sip_nat_mode(pkt->owner),
@@ -2007,43 +2004,38 @@
 
 		append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data);
 		xmitres = __sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
-		if (pkt->owner)
-			ast_mutex_unlock(&pkt->owner->lock);
+		ast_mutex_unlock(&pkt->owner->lock);
 		if (xmitres == XMIT_ERROR)
-			ast_log(LOG_WARNING, "Network error on retransmit in dialog %s\n", pkt->owner ? pkt->owner->callid : "<unknown>");
-		else {
-			ao2_ref(pkt, -1);
+			ast_log(LOG_WARNING, "Network error on retransmit in dialog %s\n", pkt->owner->callid);
+		else
 			return  reschedule;
-		}
 	} 
 	/* Too many retries */
 	if (pkt->owner && pkt->method != SIP_OPTIONS && xmitres == 0) {
 		if (ast_test_flag(pkt, FLAG_FATAL) || sipdebug)	/* Tell us if it's critical or if we're debugging */
 			ast_log(LOG_WARNING, "Maximum retries exceeded on transmission %s for seqno %d (%s %s)\n", pkt->owner->callid, pkt->seqno, (ast_test_flag(pkt, FLAG_FATAL)) ? "Critical" : "Non-critical", (ast_test_flag(pkt, FLAG_RESPONSE)) ? "Response" : "Request");
-	} else if (pkt->owner && (pkt->method == SIP_OPTIONS) && sipdebug) {
-		ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
-	}
-	if (pkt->owner) {
-		if (xmitres == XMIT_ERROR) {
-			ast_log(LOG_WARNING, "Transmit error :: Cancelling transmission of transaction in call id %s \n", pkt->owner->callid);
-			append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
-		} else
-			append_history(pkt->owner, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
- 	}
+	} else if ((pkt->method == SIP_OPTIONS) && sipdebug) {
+			ast_log(LOG_WARNING, "Cancelling retransmit of OPTIONs (call id %s) \n", pkt->owner->callid);
+	}
+	if (xmitres == XMIT_ERROR) {
+		ast_log(LOG_WARNING, "Transmit error :: Cancelling transmission of transaction in call id %s \n", pkt->owner->callid);
+		append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+	} else
+		append_history(pkt->owner, "MaxRetries", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+ 		
 	pkt->retransid = -1;
 
 	if (ast_test_flag(pkt, FLAG_FATAL)) {
-		while (pkt->owner && pkt->owner->owner && ast_channel_trylock(pkt->owner->owner)) {
+		while(pkt->owner->owner && ast_channel_trylock(pkt->owner->owner)) {
 			ast_mutex_unlock(&pkt->owner->lock);	/* SIP_PVT, not channel */
 			usleep(1);
-			if (pkt->owner)
-				ast_mutex_lock(&pkt->owner->lock);
-		}
-
-		if (pkt->owner && pkt->owner->owner && !pkt->owner->owner->hangupcause) 
+			ast_mutex_lock(&pkt->owner->lock);
+		}
+
+		if (pkt->owner->owner && !pkt->owner->owner->hangupcause) 
 			pkt->owner->owner->hangupcause = AST_CAUSE_NO_USER_RESPONSE;
 		
-		if (pkt->owner && pkt->owner->owner) {
+		if (pkt->owner->owner) {
 			sip_alreadygone(pkt->owner);
 			ast_log(LOG_WARNING, "Hanging up call %s - no reply to our critical packet.\n", pkt->owner->callid);
 			ast_queue_hangup(pkt->owner->owner);
@@ -2052,7 +2044,7 @@
 			/* If no channel owner, destroy now */
 
 			/* Let the peerpoke system expire packets when the timer expires for poke_noanswer */
-			if (pkt->owner && pkt->method != SIP_OPTIONS) {
+			if (pkt->method != SIP_OPTIONS) {
 				ast_set_flag(&pkt->owner->flags[0], SIP_NEEDDESTROY);	
 				sip_alreadygone(pkt->owner);
 				if (option_debug)
@@ -2061,7 +2053,7 @@
 		}
 	}
 
-	if (pkt->owner && pkt->method == SIP_BYE) {
+	if (pkt->method == SIP_BYE) {
 		/* We're not getting answers on SIP BYE's.  Tear down the call anyway. */
 		if (pkt->owner->owner) 
 			ast_channel_unlock(pkt->owner->owner);
@@ -2070,23 +2062,23 @@
 	}
 
 	/* In any case, go ahead and remove the packet */
-	if (pkt->owner && (prev = ao2_find(pkt->owner->packets, pkt, OBJ_UNLINK | OBJ_POINTER))) {
-		/* Destroy the container's reference (inherited) */
-		ao2_ref(prev, -1);
+	for (prev = NULL, cur = pkt->owner->packets; cur; prev = cur, cur = cur->next) {
+		if (cur == pkt)
+			break;
+	}
+	if (cur) {
+		if (prev)
+			prev->next = cur->next;
+		else
+			pkt->owner->packets = cur->next;
 		ast_mutex_unlock(&pkt->owner->lock);
-		/* Now destroy our initial reference */
-		ao2_ref(pkt, -1);
-		/* And destroy the sched ref */
-		ao2_ref(pkt, -1);
-		return 0;
-	} else {
+		free(cur);
+		pkt = NULL;
+	} else
 		ast_log(LOG_WARNING, "Weird, couldn't find packet owner!\n");
-		if (pkt->owner)
-			ast_mutex_unlock(&pkt->owner->lock);
-		ao2_ref(pkt, -1); /* Initial ref */
-		ao2_ref(pkt, -1); /* Sched ref */
-		return 0;
-	}
+	if (pkt)
+		ast_mutex_unlock(&pkt->owner->lock);
+	return 0;
 }
 
 /*! \brief Transmit packet with retransmits 
@@ -2098,11 +2090,12 @@
 	int siptimer_a = DEFAULT_RETRANS;
 	int xmitres = 0;
 
-	if (!(pkt = ao2_alloc(sizeof(*pkt) + len + 1, ast_free)))
+	if (!(pkt = ast_calloc(1, sizeof(*pkt) + len + 1)))
 		return AST_FAILURE;
 	memcpy(pkt->data, data, len);
 	pkt->method = sipmethod;
 	pkt->packetlen = len;
+	pkt->next = p->packets;
 	pkt->owner = p;
 	pkt->seqno = seqno;
 	if (resp)
@@ -2114,9 +2107,12 @@
 	if (pkt->timer_t1)
 		siptimer_a = pkt->timer_t1 * 2;
 
+	/* Schedule retransmission */
+	pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
 	if (option_debug > 3 && sipdebug)
 		ast_log(LOG_DEBUG, "*** SIP TIMER: Initializing retransmit timer on packet: Id  #%d\n", pkt->retransid);
-
+	pkt->next = p->packets;
+	p->packets = pkt;
 	if (sipmethod == SIP_INVITE) {
 		/* Note this is a pending invite */
 		p->pendinginvite = seqno;
@@ -2126,25 +2122,11 @@
 
 	if (xmitres == XMIT_ERROR) {	/* Serious network trouble, no need to try again */
 		append_history(pkt->owner, "XmitErr", "%s", (ast_test_flag(pkt, FLAG_FATAL)) ? "(Critical)" : "(Non-critical)");
+		ast_sched_del(sched, pkt->retransid);	/* No more retransmission */
 		pkt->retransid = -1;
-		ao2_ref(pkt, -1);	/* and deallocate */
 		return AST_FAILURE;
-	} else {
-		/* Add refcount for scheduler pointer */
-		ao2_ref(pkt, 1);
-		/* Schedule retransmission */
-		pkt->retransid = ast_sched_add_variable(sched, siptimer_a, retrans_pkt, pkt, 1);
-		/* Link into the list of packets */
-		ao2_link(p->packets, pkt);
+	} else
 		return AST_SUCCESS;
-	}
-}
-
-static int __deref_ao2_owner_cb(void *obj, void *unused, int flags)
-{
-	struct sip_pkt *pkt = obj;
-	pkt->owner = NULL;
-	return 0;
 }
 
 /*! \brief Kill a SIP dialog (called by scheduler) */
@@ -2158,15 +2140,16 @@
 		p->subscribed = NONE;
 		append_history(p, "Subscribestatus", "timeout");
 		if (option_debug > 2)
-			ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subscription %s\n", p->callid ? p->callid : "<unknown>");
+			ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP subsription %s\n", p->callid ? p->callid : "<unknown>");
 		return 10000;	/* Reschedule this destruction so that we know that it's gone */
 	}
 
-	/* If there are packets still waiting for delivery, make sure they can't callback to us anymore. */
-	if (ao2_container_count(p->packets)) {
-		ast_mutex_lock(&p->lock);
-		ao2_callback(p->packets, 0, __deref_ao2_owner_cb, NULL);
-		ast_mutex_unlock(&p->lock);
+	/* If there are packets still waiting for delivery, delay the destruction */
+	if (p->packets) {
+		if (option_debug > 2)
+			ast_log(LOG_DEBUG, "Re-scheduled destruction of SIP call %s\n", p->callid ? p->callid : "<unknown>");
+		append_history(p, "ReliableXmit", "timeout");
+		return 10000;
 	}
 
 	/* If we're destroying a subscription, dereference peer object too */
@@ -2223,17 +2206,13 @@
 /*! \brief Acknowledges receipt of a packet and stops retransmission */
 static void __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
 {
-	struct sip_pkt *cur;
-	struct ao2_iterator ao2i;
+	struct sip_pkt *cur, *prev = NULL;
 
 	/* Just in case... */
 	char *msg;
 	int res = FALSE;
 
 	msg = sip_methods[sipmethod].text;
-
-	ast_mutex_lock(&p->lock);
-	
 	/* If we have an outbound proxy for this dialog, then delete it now since
 	   the rest of the requests in this dialog needs to follow the routing.
 	   If obforcing is set, we will keep the outbound proxy during the whole
@@ -2241,8 +2220,9 @@
  	 */
 	if (p->outboundproxy && !p->outboundproxy->force)
 		p->outboundproxy = NULL;
-	ao2i = ao2_iterator_init(p->packets, 0);
-	while ((cur = ao2_iterator_next(&ao2i))) {
+
+	ast_mutex_lock(&p->lock);
+	for (cur = p->packets; cur; prev = cur, cur = cur->next) {
 		if ((cur->seqno == seqno) && ((ast_test_flag(cur, FLAG_RESPONSE)) == resp) &&
 			((ast_test_flag(cur, FLAG_RESPONSE)) || 
 			 (!strncasecmp(msg, cur->data, strlen(msg)) && (cur->data[strlen(msg)] < 33)))) {
@@ -2253,68 +2233,60 @@
 			}
 			/* this is our baby */
 			res = TRUE;
+			UNLINK(cur, p->packets, prev);
 			if (cur->retransid > -1) {
 				if (sipdebug && option_debug > 3)
 					ast_log(LOG_DEBUG, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
-				if (!ast_sched_del(sched, cur->retransid))
-					ao2_ref(cur, -1); /* scheduler deref */
+				ast_sched_del(sched, cur->retransid);
 				cur->retransid = -1;
 			}
-
-			/* Remove it from the list */
-			ao2_unlink(p->packets, cur);
-			ao2_ref(cur, -1); /* iterator deref */
+			free(cur);
 			break;
 		}
-
-		ao2_ref(cur, -1); /* iterator deref */
 	}
 	ast_mutex_unlock(&p->lock);
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Stopping retransmission on '%s' of %s %d: Match %s\n", p->callid, resp ? "Response" : "Request", seqno, res ? "Not Found" : "Found");
 }
 
-static int __sip_pretend_ack_cb(void *obj, void *vp, int flags)
-{
-	struct sip_pvt *p = vp;
-	struct sip_pkt *pkt = obj;
-	__sip_ack(p, pkt->seqno, ast_test_flag(pkt, FLAG_RESPONSE), pkt->method ? pkt->method : find_sip_method(pkt->data));
-	return 0;
-}
-
-/*! \brief Pretend to ack all packets */
+
+/*! \brief Pretend to ack all packets
+ * maybe the lock on p is not strictly necessary but there might be a race */
 static void __sip_pretend_ack(struct sip_pvt *p)
 {
-	ao2_callback(p->packets, 0, __sip_pretend_ack_cb, p);
+	struct sip_pkt *cur = NULL;
+
+	while (p->packets) {
+		int method;
+		if (cur == p->packets) {

[... 1946 lines stripped ...]



More information about the asterisk-commits mailing list