[asterisk-commits] murf: branch murf/bug11210 r100881 - in /team/murf/bug11210: ./ apps/ build_t...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 29 11:00:04 CST 2008


Author: murf
Date: Tue Jan 29 11:00:03 2008
New Revision: 100881

URL: http://svn.digium.com/view/asterisk?view=rev&rev=100881
Log:
Merged revisions 100488,100497,100514,100532-100533,100549,100565,100582,100625,100627-100628,100630-100632,100671,100674,100676-100679 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r100488 | tilghman | 2008-01-27 15:35:29 -0700 (Sun, 27 Jan 2008) | 19 lines

Merged revisions 100465 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100465 | tilghman | 2008-01-27 15:59:53 -0600 (Sun, 27 Jan 2008) | 11 lines

When deleting a task from the scheduler, ignoring the return value could
possibly cause memory to be accessed after it is freed, which causes all
sorts of random memory corruption.  Instead, if a deletion fails, wait a
bit and try again (noting that another thread could change our taskid
value).
(closes issue #11386)
 Reported by: flujan
 Patches: 
       20080124__bug11386.diff.txt uploaded by Corydon76 (license 14)
 Tested by: Corydon76, flujan, stuarth`

........

................
r100497 | tilghman | 2008-01-27 16:14:48 -0700 (Sun, 27 Jan 2008) | 5 lines

With the switch to the ast_sched_replace* API in trunk, we lose the correction
that was just merged from 1.4, so this is a changeover to those APIs to use the
macro versions, so that we properly detect errors from ast_sched_del, instead
of simply ignoring the return values.

................
r100514 | russell | 2008-01-27 17:56:14 -0700 (Sun, 27 Jan 2008) | 5 lines

These readlocks always fail for me on my mac, and I saw it happen again
today on another mac.  We ignore the return value of locking operations almost
everywhere in Asterisk.  So, ignore these, as well, so Asterisk will actually
work on systems where this is occurring while I look into what the issue is.

................
r100532 | russell | 2008-01-27 21:30:44 -0700 (Sun, 27 Jan 2008) | 3 lines

 - Simplify a line with ARRAY_LEN()
 - Make a few little formatting changes

................
r100533 | russell | 2008-01-27 21:43:14 -0700 (Sun, 27 Jan 2008) | 2 lines

Make a couple more uses of ARRAY_LEN, and convert some spaces to tabs

................
r100549 | file | 2008-01-28 06:57:38 -0700 (Mon, 28 Jan 2008) | 4 lines

Don't do a network byte order conversion when setting the socket's port variable to that of bindaddr's. It is already in the correct network byte order.
(closes issue #11800)
Reported by: hmodes

................
r100565 | russell | 2008-01-28 07:27:28 -0700 (Mon, 28 Jan 2008) | 2 lines

Clean up some formatting, and simplify a bit of code using ast_str

................
r100582 | russell | 2008-01-28 10:21:24 -0700 (Mon, 28 Jan 2008) | 17 lines

Merged revisions 100581 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100581 | russell | 2008-01-28 11:15:41 -0600 (Mon, 28 Jan 2008) | 9 lines

Make some deadlock related fixes.  These bugs were discovered and reported
internally at Digium by Steve Pitts.
 - Fix up chan_local to ensure that the channel lock is held before the local
   pvt lock.
 - Don't hold the channel lock when executing the timing function, as it can
   cause a deadlock when using chan_local.  This actually changes the code back
   to be how it was before the change for issue #10765.  But, I added some other
   locking that I think will prevent the problem reported there, as well.

........

................
r100625 | qwell | 2008-01-28 11:24:40 -0700 (Mon, 28 Jan 2008) | 9 lines

Merged revisions 100624 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100624 | qwell | 2008-01-28 12:23:09 -0600 (Mon, 28 Jan 2008) | 1 line

Correct a comment which made little/no sense.
........

................
r100627 | russell | 2008-01-28 11:27:08 -0700 (Mon, 28 Jan 2008) | 15 lines

Merged revisions 100626 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100626 | russell | 2008-01-28 12:26:31 -0600 (Mon, 28 Jan 2008) | 7 lines

Fix a crash in ast_masq_park_call()

(issue #11342)
Reported by: DEA
Patches:
      res_features-park.txt uploaded by DEA (license 3)

........

................
r100628 | tilghman | 2008-01-28 11:27:29 -0700 (Mon, 28 Jan 2008) | 3 lines

Normalize the detection for execinfo, so that Linux (glibc) and other platforms
with libexecinfo will generate inline stack backtraces correctly.

................
r100630 | russell | 2008-01-28 11:38:56 -0700 (Mon, 28 Jan 2008) | 13 lines

Merged revisions 100629 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100629 | russell | 2008-01-28 12:34:20 -0600 (Mon, 28 Jan 2008) | 5 lines

For some reason, the use of this strdupa() is leading to memory corruption on
freebsd sparc64.  This trivial workaround fixes it.

(closes issue #10300, closes issue #11857, reported by mattias04 and Home-of-the-Brave)

........

................
r100631 | russell | 2008-01-28 11:41:23 -0700 (Mon, 28 Jan 2008) | 3 lines

Merge rev 100626 from Asterisk 1.4.  The svnmerge of this commit was a NoOp, since
res_features doesn't exist in trunk.  Thanks to qwell for pointing it out!

................
r100632 | file | 2008-01-28 12:04:53 -0700 (Mon, 28 Jan 2008) | 2 lines

Fix up two scheduling issues. In one instance a scheduled item was not deleted when it should have been and in the other it was scheduled again when it shouldn't have been.

................
r100671 | file | 2008-01-28 13:40:08 -0700 (Mon, 28 Jan 2008) | 6 lines

Fix up some T38 state change issues.
(closes issue #11630)
Reported by: dimas
Patches:
      v2-sip-t38state.patch uploaded by dimas (license 88)

................
r100674 | mmichelson | 2008-01-28 13:58:12 -0700 (Mon, 28 Jan 2008) | 10 lines

Blocked revisions 100673 via svnmerge

........
r100673 | mmichelson | 2008-01-28 14:55:56 -0600 (Mon, 28 Jan 2008) | 3 lines

Undoing the deprecation of chan_vpb. It is alive and well.


........

................
r100676 | qwell | 2008-01-28 14:02:11 -0700 (Mon, 28 Jan 2008) | 16 lines

Merged revisions 100672 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

(closes issue #11795)
........
r100672 | qwell | 2008-01-28 14:42:43 -0600 (Mon, 28 Jan 2008) | 7 lines

When using ODBC_STORAGE, make sure we put greeting files into the database like we do with the others.

Issue #11795
Reported by: dimas
Patches:
      vmgreet.patch uploaded by dimas (license 88)

........

................
r100677 | tilghman | 2008-01-28 14:05:29 -0700 (Mon, 28 Jan 2008) | 10 lines

Merged revisions 100675 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r100675 | tilghman | 2008-01-28 15:02:02 -0600 (Mon, 28 Jan 2008) | 2 lines

WaitExten didn't handle AbsoluteTimeout properly (went to 't' instead of 'T')

........

................
r100678 | mmichelson | 2008-01-28 14:07:18 -0700 (Mon, 28 Jan 2008) | 3 lines

Re-inserting chan_vpb into trunk.


................
r100679 | qwell | 2008-01-28 14:11:24 -0700 (Mon, 28 Jan 2008) | 1 line

Reintroduce more chan_vpb stuff that was removed in r100421 and r100422
................

Added:
    team/murf/bug11210/channels/chan_vpb.cc
      - copied unchanged from r100679, trunk/channels/chan_vpb.cc
    team/murf/bug11210/configs/vpb.conf.sample
      - copied unchanged from r100679, trunk/configs/vpb.conf.sample
Modified:
    team/murf/bug11210/   (props changed)
    team/murf/bug11210/apps/app_voicemail.c
    team/murf/bug11210/build_tools/menuselect-deps.in
    team/murf/bug11210/channels/Makefile
    team/murf/bug11210/channels/chan_h323.c
    team/murf/bug11210/channels/chan_iax2.c
    team/murf/bug11210/channels/chan_local.c
    team/murf/bug11210/channels/chan_mgcp.c
    team/murf/bug11210/channels/chan_misdn.c
    team/murf/bug11210/channels/chan_sip.c
    team/murf/bug11210/channels/chan_zap.c
    team/murf/bug11210/configure
    team/murf/bug11210/configure.ac
    team/murf/bug11210/doc/tex/channelvariables.tex
    team/murf/bug11210/include/asterisk/autoconfig.h.in
    team/murf/bug11210/include/asterisk/channel.h
    team/murf/bug11210/include/asterisk/sched.h
    team/murf/bug11210/main/cdr.c
    team/murf/bug11210/main/channel.c
    team/murf/bug11210/main/dnsmgr.c
    team/murf/bug11210/main/features.c
    team/murf/bug11210/main/file.c
    team/murf/bug11210/main/logger.c
    team/murf/bug11210/main/pbx.c
    team/murf/bug11210/main/rtp.c
    team/murf/bug11210/makeopts.in
    team/murf/bug11210/pbx/pbx_dundi.c

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
    automerge = yes

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/murf/bug11210/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jan 29 11:00:03 2008
@@ -1,1 +1,1 @@
-/trunk:1-100436
+/trunk:1-100738

Modified: team/murf/bug11210/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/apps/app_voicemail.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/apps/app_voicemail.c (original)
+++ team/murf/bug11210/apps/app_voicemail.c Tue Jan 29 11:00:03 2008
@@ -2244,36 +2244,55 @@
 	return ast_strftime(s, len, "%a %b %e %r UTC %Y", &tm);
 }
 
-static int invent_message(struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
+static int play_greeting(struct ast_channel *chan, struct ast_vm_user *vmu, char *filename, char *ecodes)
+{
+	int res = -2;
+	
+#ifdef ODBC_STORAGE
+	int success = 
+#endif
+	RETRIEVE(filename, -1, vmu->mailbox, vmu->context);
+	if (ast_fileexists(filename, NULL, NULL) > 0) {
+		res = ast_streamfile(chan, filename, chan->language);
+		if (res > -1) 
+			res = ast_waitstream(chan, ecodes);
+#ifdef ODBC_STORAGE
+		if (success == -1) {
+			/* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */
+			ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n");
+			store_file(filename, vmu->mailbox, vmu->context, -1);
+		}
+#endif
+	}
+	DISPOSE(filename, -1);
+
+	return res;
+}
+
+static int invent_message(struct ast_channel *chan, struct ast_vm_user *vmu, char *ext, int busy, char *ecodes)
 {
 	int res;
 	char fn[PATH_MAX];
 	char dest[PATH_MAX];
 
-	snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
-
-	if ((res = create_dirpath(dest, sizeof(dest), context, ext, ""))) {
+	snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, vmu->context, ext);
+
+	if ((res = create_dirpath(dest, sizeof(dest), vmu->context, ext, ""))) {
 		ast_log(LOG_WARNING, "Failed to make directory(%s)\n", fn);
 		return -1;
 	}
 
-	RETRIEVE(fn, -1, ext, context);
-	if (ast_fileexists(fn, NULL, NULL) > 0) {
-		res = ast_stream_and_wait(chan, fn, ecodes);
-		if (res) {
-			DISPOSE(fn, -1);
-			return res;
-		}
-	} else {
-		/* Dispose just in case */
-		DISPOSE(fn, -1);
+	res = play_greeting(chan, vmu, fn, ecodes);
+	if (res == -2) {
+		/* File did not exist */
 		res = ast_stream_and_wait(chan, "vm-theperson", ecodes);
 		if (res)
 			return res;
 		res = ast_say_digit_str(chan, ext, ecodes, chan->language);
-		if (res)
-			return res;
-	}
+	}
+	if (res)
+		return res;
+
 	res = ast_stream_and_wait(chan, busy ? "vm-isonphone" : "vm-isunavail", ecodes);
 	return res;
 }
@@ -3100,25 +3119,12 @@
 
 	/* Play the beginning intro if desired */
 	if (!ast_strlen_zero(prefile)) {
-#ifdef ODBC_STORAGE
-		int success = 
-#endif
-			RETRIEVE(prefile, -1, ext, context);
-		if (ast_fileexists(prefile, NULL, NULL) > 0) {
-			if (ast_streamfile(chan, prefile, chan->language) > -1) 
-				res = ast_waitstream(chan, ecodes);
-#ifdef ODBC_STORAGE
-			if (success == -1) {
-				/* We couldn't retrieve the file from the database, but we found it on the file system. Let's put it in the database. */
-				ast_debug(1, "Greeting not retrieved from database, but found in file storage. Inserting into database\n");
-				store_file(prefile, vmu->mailbox, vmu->context, -1);
-			}
-#endif
-		} else {
+		res = play_greeting(chan, vmu, prefile, ecodes);
+		if (res == -2) {
+			/* The file did not exist */
 			ast_debug(1, "%s doesn't exist, doing what we can\n", prefile);
-			res = invent_message(chan, vmu->context, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
-		}
-		DISPOSE(prefile, -1);
+			res = invent_message(chan, vmu, ext, ast_test_flag(options, OPT_BUSY_GREETING), ecodes);
+		}
 		if (res < 0) {
 			ast_debug(1, "Hang up during prefile playback\n");
 			free_user(vmu);

Modified: team/murf/bug11210/build_tools/menuselect-deps.in
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/build_tools/menuselect-deps.in?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/build_tools/menuselect-deps.in (original)
+++ team/murf/bug11210/build_tools/menuselect-deps.in Tue Jan 29 11:00:03 2008
@@ -40,6 +40,7 @@
 UNIXODBC=@PBX_UNIXODBC@
 USB=@PBX_USB@
 VORBIS=@PBX_VORBIS@
+VPBAPI=@PBX_VPB@
 WINARCH=@WINARCH@
 ZAPTEL=@PBX_ZAPTEL@
 ZAPTEL_TRANSCODE=@PBX_ZAPTEL_TRANSCODE@

Modified: team/murf/bug11210/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/Makefile?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/Makefile (original)
+++ team/murf/bug11210/channels/Makefile Tue Jan 29 11:00:03 2008
@@ -100,4 +100,6 @@
 
 $(if $(filter chan_misdn,$(EMBEDDED_MODS)),modules.link,chan_misdn.so): misdn_config.o misdn/isdn_lib.o misdn/isdn_msg_parser.o
 
+chan_vpb.oo: ASTCFLAGS:=$(filter-out -Wdeclaration-after-statement,$(ASTCFLAGS))
+
 $(if $(filter chan_oss,$(EMBEDDED_MODS)),modules.link,chan_oss.so): console_video.o vgrabbers.o console_board.o

Modified: team/murf/bug11210/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_h323.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_h323.c (original)
+++ team/murf/bug11210/channels/chan_h323.c Tue Jan 29 11:00:03 2008
@@ -368,14 +368,12 @@
 		if (pvt->newdigit == ' ') {		/* signalUpdate message */
 			f.subclass = pvt->curDTMF;
 			if (pvt->DTMFsched >= 0) {
-				ast_sched_del(sched, pvt->DTMFsched);
-				pvt->DTMFsched = -1;
+				AST_SCHED_DEL(sched, pvt->DTMFsched);
 			}
 		} else {						/* Regular input or signal message */
 			if (pvt->newduration) {		/* This is a signal, signalUpdate follows */
 				f.frametype = AST_FRAME_DTMF_BEGIN;
-				if (pvt->DTMFsched >= 0)
-					ast_sched_del(sched, pvt->DTMFsched);
+				AST_SCHED_DEL(sched, pvt->DTMFsched);
 				pvt->DTMFsched = ast_sched_add(sched, pvt->newduration, oh323_simulate_dtmf_end, pvt);
 				if (h323debug)
 					ast_log(LOG_DTMF, "Scheduled DTMF END simulation for %d ms, id=%d\n", pvt->newduration, pvt->DTMFsched);
@@ -448,10 +446,7 @@
 {
 	struct oh323_pvt *cur, *prev = NULL;
 
-	if (pvt->DTMFsched >= 0) {
-		ast_sched_del(sched, pvt->DTMFsched);
-		pvt->DTMFsched = -1;
-	}
+	AST_SCHED_DEL(sched, pvt->DTMFsched);
 
 	if (pvt->rtp) {
 		ast_rtp_destroy(pvt->rtp);
@@ -1846,15 +1841,11 @@
 			};
 			if (digit == ' ') {		/* signalUpdate message */
 				f.subclass = pvt->curDTMF;
-				if (pvt->DTMFsched >= 0) {
-					ast_sched_del(sched, pvt->DTMFsched);
-					pvt->DTMFsched = -1;
-				}
+				AST_SCHED_DEL(sched, pvt->DTMFsched);
 			} else {				/* Regular input or signal message */
 				if (pvt->DTMFsched >= 0) {
 					/* We still don't send DTMF END from previous event, send it now */
-					ast_sched_del(sched, pvt->DTMFsched);
-					pvt->DTMFsched = -1;
+					AST_SCHED_DEL(sched, pvt->DTMFsched);
 					f.subclass = pvt->curDTMF;
 					f.samples = f.len = 0;
 					ast_queue_frame(pvt->owner, &f);

Modified: team/murf/bug11210/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_iax2.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_iax2.c (original)
+++ team/murf/bug11210/channels/chan_iax2.c Tue Jan 29 11:00:03 2008
@@ -1229,14 +1229,12 @@
 #define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
 #endif
 
-static int iax2_sched_replace(int old_id, struct sched_context *con, int when, ast_sched_cb callback, const void *data)
-{
-	int res;
-
-	res = ast_sched_replace(old_id, con, when, callback, data);
+static int iax2_sched_replace(int id, struct sched_context *con, int when, ast_sched_cb callback, const void *data)
+{
+	AST_SCHED_REPLACE(id, con, when, callback, data);
 	signal_condition(&sched_lock, &sched_cond);
 
-	return res;
+	return id;
 }
 
 static int iax2_sched_add(struct sched_context *con, int when, ast_sched_cb callback, const void *data)
@@ -1290,7 +1288,7 @@
 	int callno = (long)data;
 	/* Ping only if it's real not if it's bridged */
 	ast_mutex_lock(&iaxsl[callno]);
-	if (iaxs[callno] && iaxs[callno]->lagid != -1) {
+	if (iaxs[callno] && iaxs[callno]->lagid > -1) {
 		send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1);
 		iaxs[callno]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, data);
 	}
@@ -1899,8 +1897,7 @@
 
 static void iax2_frame_free(struct iax_frame *fr)
 {
-	if (fr->retrans > -1)
-		ast_sched_del(sched, fr->retrans);
+	AST_SCHED_DEL(sched, fr->retrans);
 	iax_frame_free(fr);
 }
 
@@ -2372,24 +2369,12 @@
 		ast_clear_flag(pvt, IAX_MAXAUTHREQ);
 	}
 	/* No more pings or lagrq's */
-	if (pvt->pingid > -1)
-		ast_sched_del(sched, pvt->pingid);
-	pvt->pingid = -1;
-	if (pvt->lagid > -1)
-		ast_sched_del(sched, pvt->lagid);
-	pvt->lagid = -1;
-	if (pvt->autoid > -1)
-		ast_sched_del(sched, pvt->autoid);
-	pvt->autoid = -1;
-	if (pvt->authid > -1)
-		ast_sched_del(sched, pvt->authid);
-	pvt->authid = -1;
-	if (pvt->initid > -1)
-		ast_sched_del(sched, pvt->initid);
-	pvt->initid = -1;
-	if (pvt->jbid > -1)
-		ast_sched_del(sched, pvt->jbid);
-	pvt->jbid = -1;
+	AST_SCHED_DEL(sched, pvt->pingid);
+	AST_SCHED_DEL(sched, pvt->lagid);
+	AST_SCHED_DEL(sched, pvt->autoid);
+	AST_SCHED_DEL(sched, pvt->authid);
+	AST_SCHED_DEL(sched, pvt->initid);
+	AST_SCHED_DEL(sched, pvt->jbid);
 }
 
 /*!
@@ -3159,8 +3144,8 @@
 	when = ast_tvdiff_ms(ast_tvnow(), pvt->rxcore);
 	
 	when = jb_next(pvt->jb) - when;
-	
-	if(when <= 0) {
+
+	if (when <= 0) {
 		/* XXX should really just empty until when > 0.. */
 		when = 1;
 	}
@@ -3313,10 +3298,7 @@
 
 		jb_reset(iaxs[fr->callno]->jb);
 
-		if (iaxs[fr->callno]->jbid > -1)
-			ast_sched_del(sched, iaxs[fr->callno]->jbid);
-
-		iaxs[fr->callno]->jbid = -1;
+		AST_SCHED_DEL(sched, iaxs[fr->callno]->jbid);
 
 		/* deliver this frame now */
 		if (tsout)
@@ -8508,11 +8490,7 @@
 		}
 		if (f.frametype == AST_FRAME_IAX) {
 			int old1;
-			if (iaxs[fr->callno]->initid > -1) {
-				/* Don't auto congest anymore since we've gotten something usefulb ack */
-				ast_sched_del(sched, iaxs[fr->callno]->initid);
-				iaxs[fr->callno]->initid = -1;
-			}
+			AST_SCHED_DEL(sched, iaxs[fr->callno]->initid);
 			/* Handle the IAX pseudo frame itself */
 			if (iaxdebug)
 				ast_debug(1, "IAX subclass %d received\n", f.subclass);
@@ -10539,9 +10517,7 @@
 					}
 				} else {
 					/* Non-dynamic.  Make sure we become that way if we're not */
-					if (peer->expire > -1)
-						ast_sched_del(sched, peer->expire);
-					peer->expire = -1;
+					AST_SCHED_DEL(sched, peer->expire);
 					ast_clear_flag(peer, IAX_DYNAMIC);
 					if (ast_dnsmgr_lookup(v->value, &peer->addr.sin_addr, &peer->dnsmgr))
 						return peer_unref(peer);
@@ -10920,8 +10896,7 @@
 
 	AST_LIST_LOCK(&registrations);
 	while ((reg = AST_LIST_REMOVE_HEAD(&registrations, entry))) {
-		if (reg->expire > -1)
-			ast_sched_del(sched, reg->expire);
+		AST_SCHED_DEL(sched, reg->expire);
 		if (reg->callno) {
 			ast_mutex_lock(&iaxsl[reg->callno]);
 			if (iaxs[reg->callno]) {

Modified: team/murf/bug11210/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_local.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_local.c (original)
+++ team/murf/bug11210/channels/chan_local.c Tue Jan 29 11:00:03 2008
@@ -161,8 +161,6 @@
 {
 	struct ast_channel *other = NULL;
 
-retrylock:		
-
 	/* Recalculate outbound channel */
 	other = isoutbound ? p->owner : p->chan;
 
@@ -180,27 +178,28 @@
 		ast_clear_flag(p, LOCAL_GLARE_DETECT);
 		return 0;
 	}
-	if (ast_channel_trylock(other)) {
-		/* Failed to lock.  Release main lock and try again */
-		ast_mutex_unlock(&p->lock);
-		if (us) {
-			if (ast_channel_unlock(us)) {
-				ast_log(LOG_WARNING, "%s wasn't locked while sending %d/%d\n",
-					us->name, f->frametype, f->subclass);
-				us = NULL;
-			}
-		}
-		/* Wait just a bit */
-		usleep(1);
-		/* Only we can destroy ourselves, so we can't disappear here */
-		if (us)
+
+	ast_mutex_unlock(&p->lock);
+
+	/* Ensure that we have both channels locked */
+	if (us) {
+		while (ast_channel_trylock(other)) {
+			ast_channel_unlock(us);
+			usleep(1);
 			ast_channel_lock(us);
-		ast_mutex_lock(&p->lock);
-		goto retrylock;
-	}
+		}
+	} else {
+		ast_channel_lock(other);
+	}
+
 	ast_queue_frame(other, f);
+
 	ast_channel_unlock(other);
+
+	ast_mutex_lock(&p->lock);
+
 	ast_clear_flag(p, LOCAL_GLARE_DETECT);
+
 	return 0;
 }
 

Modified: team/murf/bug11210/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_mgcp.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_mgcp.c (original)
+++ team/murf/bug11210/channels/chan_mgcp.c Tue Jan 29 11:00:03 2008
@@ -3355,9 +3355,8 @@
 			}
 
 			/* stop retrans timer if the queue is empty */
-			if (!gw->msgs && (gw->retransid != -1)) {
-				ast_sched_del(sched, gw->retransid);
-				gw->retransid = -1;
+			if (!gw->msgs) {
+				AST_SCHED_DEL(sched, gw->retransid);
 			}
 
 			ast_mutex_unlock(&gw->msgs_lock);
@@ -3609,9 +3608,7 @@
 					}
 				} else {
 					/* Non-dynamic.  Make sure we become that way if we're not */
-					if (gw->expire > -1)
-						ast_sched_del(sched, gw->expire);
-					gw->expire = -1;
+					AST_SCHED_DEL(sched, gw->expire);
 					gw->dynamic = 0;
 					if (ast_get_ip(&gw->addr, v->value)) {
 						if (!gw_reload) {

Modified: team/murf/bug11210/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_misdn.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_misdn.c (original)
+++ team/murf/bug11210/channels/chan_misdn.c Tue Jan 29 11:00:03 2008
@@ -652,7 +652,7 @@
 
 static void misdn_tasks_remove (int task_id)
 {
-	ast_sched_del(misdn_tasks, task_id);
+	AST_SCHED_DEL(misdn_tasks, task_id);
 }
 
 static int misdn_l1_task (const void *data)

Modified: team/murf/bug11210/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/murf/bug11210/channels/chan_sip.c?view=diff&rev=100881&r1=100880&r2=100881
==============================================================================
--- team/murf/bug11210/channels/chan_sip.c (original)
+++ team/murf/bug11210/channels/chan_sip.c Tue Jan 29 11:00:03 2008
@@ -1778,6 +1778,12 @@
 		(head) = (element)->next;	\
 	} while (0)
 
+enum t38_action_flag {
+	SDP_T38_NONE = 0, /*!< Do not modify T38 information at all */
+	SDP_T38_INITIATE, /*!< Remote side has requested T38 with us */
+	SDP_T38_ACCEPT,   /*!< Remote side accepted our T38 request */
+};
+
 /*---------------------------- Forward declarations of functions in chan_sip.c */
 /*! \note This is added to help splitting up chan_sip.c into several files
 	in coming releases */
@@ -1843,7 +1849,7 @@
 				 int useglobal_nat, const int intended_method);
 static int __sip_autodestruct(const void *data);
 static void sip_scheddestroy(struct sip_pvt *p, int ms);
-static void sip_cancel_destroy(struct sip_pvt *p);
+static int sip_cancel_destroy(struct sip_pvt *p);
 static struct sip_pvt *sip_destroy(struct sip_pvt *p);
 static void *dialog_unlink_all(struct sip_pvt *dialog, int lockowner, int lockdialoglist);
 static void *registry_unref(struct sip_registry *reg, char *tag);
@@ -1872,7 +1878,7 @@
 static const char* get_sdp_iterate(int* start, struct sip_request *req, const char *name);
 static const char *get_sdp(struct sip_request *req, const char *name);
 static int find_sdp(struct sip_request *req);
-static int process_sdp(struct sip_pvt *p, struct sip_request *req);
+static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action);
 static void add_codec_to_sdp(const struct sip_pvt *p, int codec, int sample_rate,
 			     struct ast_str **m_buf, struct ast_str **a_buf,
 			     int debug, int *min_packet_size);
@@ -2980,8 +2986,7 @@
 		siptimer_a = pkt->timer_t1 * 2;
 
 	/* Schedule retransmission */
-	pkt->retransid = ast_sched_replace_variable(pkt->retransid, sched, 
-		siptimer_a, retrans_pkt, pkt, 1);
+	AST_SCHED_REPLACE_VARIABLE(pkt->retransid, sched, siptimer_a, retrans_pkt, pkt, 1);
 	if (sipdebug)
 		ast_debug(4, "*** SIP TIMER: Initializing retransmit timer on packet: Id  #%d\n", pkt->retransid);
 
@@ -2989,11 +2994,10 @@
 
 	if (xmitres == XMIT_ERROR) {	/* Serious network trouble, no need to try again */
 		append_history(pkt->owner, "XmitErr", "%s", pkt->is_fatal ? "(Critical)" : "(Non-critical)");
-		ast_sched_del(sched, pkt->retransid);	/* No more retransmission */
-		pkt->retransid = -1;
 		return AST_FAILURE;
-	} else
+	} else {
 		return AST_SUCCESS;
+	}
 }
 
 /*! \brief Kill a SIP dialog (called only by the scheduler)
@@ -3069,7 +3073,9 @@
 	}
 	if (sip_debug_test_pvt(p))
 		ast_verbose("Scheduling destruction of SIP dialog '%s' in %d ms (Method: %s)\n", p->callid, ms, sip_methods[p->method].text);
-	sip_cancel_destroy(p);
+	if (sip_cancel_destroy(p))
+		ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
+
 	if (p->do_history)
 		append_history(p, "SchedDestroy", "%d ms", ms);
 	p->autokillid = ast_sched_add(sched, ms, __sip_autodestruct, dialog_ref(p,"setting ref as passing into ast_sched_add for __sip_autodestruct"));
@@ -3082,16 +3088,19 @@
  * Be careful as this also absorbs the reference - if you call it
  * from within the scheduler, this might be the last reference.
  */
-static void sip_cancel_destroy(struct sip_pvt *p)
-{
+static int sip_cancel_destroy(struct sip_pvt *p)
+{
+	int res = 0;
 	if (p->autokillid > -1) {
 		int res3;
-		res3 = ast_sched_del(sched, p->autokillid);
-		append_history(p, "CancelDestroy", "");
-		p->autokillid = -1;
+		if (!(res3 = ast_sched_del(sched, p->autokillid))) {
+			append_history(p, "CancelDestroy", "");
+			p->autokillid = -1;
+		}
 		if (res3 == 0)
 			dialog_unref(p,"dialog unrefd because autokillid is de-sched'd");
 	}
+	return res;
 }
 
 /*! \brief Acknowledges receipt of a packet and stops retransmission */
@@ -3122,9 +3131,8 @@
 			if (cur->retransid > -1) {
 				if (sipdebug)
 					ast_debug(4, "** SIP TIMER: Cancelling retransmit of packet (reply received) Retransid #%d\n", cur->retransid);
-				ast_sched_del(sched, cur->retransid);
-				cur->retransid = -1;
 			}
+			AST_SCHED_DEL(sched, cur->retransid);
 			UNLINK(cur, p->packets, prev);
 			dialog_unref(cur->owner, "unref dialog from sip ack");
 			ast_free(cur);
@@ -3167,9 +3175,8 @@
 			if (cur->retransid > -1) {
 				if (sipdebug)
 					ast_debug(4, "*** SIP TIMER: Cancelling retransmission #%d - %s (got response)\n", cur->retransid, sip_methods[sipmethod].text);
-				ast_sched_del(sched, cur->retransid);
-				cur->retransid = -1;
 			}
+			AST_SCHED_DEL(sched, cur->retransid);
 			res = 0;
 			break;
 		}
@@ -3606,11 +3613,8 @@
 	 *
 	 * NOTE: once peer is refcounted, this probably is no longer necessary.
 	 */
-	
-	while (peer->expire > -1 && ast_sched_del(sched, peer->expire))
-		usleep(1);
-	while (peer->pokeexpire > -1 && ast_sched_del(sched, peer->pokeexpire))
-		usleep(1);
+	AST_SCHED_DEL(sched, peer->expire);
+	AST_SCHED_DEL(sched, peer->pokeexpire);
 
 	register_peer_exten(peer, FALSE);
 	ast_free_ha(peer->ha);
@@ -3832,10 +3836,9 @@
 		/* Cache peer */
 		ast_copy_flags(&peer->flags[1],&global_flags[1], SIP_PAGE2_RTAUTOCLEAR|SIP_PAGE2_RTCACHEFRIENDS);
 		if (ast_test_flag(&global_flags[1], SIP_PAGE2_RTAUTOCLEAR)) {
-			peer->expire = ast_sched_replace(peer->expire, sched, 
-				global_rtautoclear * 1000, expire_register, (void *) peer); /* HUH? peer is a refcounted object, and we are storing it in the sched struct, so 
-																			   really, really, we should be incr. its refcount right here, but I guess, since
-																			   peers hang around until module unload time anyway, it's not worth the trouble */
+			AST_SCHED_REPLACE(peer->expire, sched, global_rtautoclear * 1000, expire_register, (void *) peer); /* HUH? peer is a refcounted object, and we are storing it in the sched struct, so 
+																   really, really, we should be incr. its refcount right here, but I guess, since
+																   peers hang around until module unload time anyway, it's not worth the trouble */
 		}
 		ao2_t_link(peers, peer, "link peer into peers table");
 		if (peer->addr.sin_addr.s_addr) {
@@ -4366,10 +4369,8 @@
 		p->invitestate = INV_CALLING;
 	
 		/* Initialize auto-congest time */
-		p->initid = ast_sched_replace(p->initid, sched, p->timer_b, 
-									  auto_congest, dialog_ref(p,"sched:replace:this is a pointer for the autocongest callback to use (p->initid)"));
-	}
-
+		AST_SCHED_REPLACE(p->initid, sched, p->timer_b, auto_congest, dialog_ref(p,"sched:replace:this is a pointer for the autocongest callback to use (p->initid)"));
+	}
 	return res;
 }
 
@@ -4389,15 +4390,11 @@
 		reg->call = dialog_unref(reg->call,"unref reg->call");
 		/* reg->call = sip_destroy(reg->call); */
 	}
-	if (reg->expire > -1) {
-		ast_sched_del(sched, reg->expire);  /* HUH?  normally, if reg were being refcounted thru sched calls, we'd
+	AST_SCHED_DEL(sched, reg->expire);  /* HUH?  normally, if reg were being refcounted thru sched calls, we'd
 											   add code after this to unref the reg */
-	}
 	
-	if (reg->timeout > -1) {
-		ast_sched_del(sched, reg->timeout);   /* HUH?  normally, if peer were being refcounted thru sched calls, we'd
+	AST_SCHED_DEL(sched, reg->timeout);   /* HUH?  normally, if peer were being refcounted thru sched calls, we'd
 											   add code after this to unref the peer */
-	}
 	
 	ast_string_field_free_memory(reg);
 	regobjs--;
@@ -4436,26 +4433,10 @@
 
 	if (p->stateid > -1)
 		ast_extension_state_del(p->stateid, NULL);
-	if (p->waitid > -1)
-	{
-		if (ast_sched_del(sched, p->waitid) == 0)
-			dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr");
-		p->waitid = -1;
-	}
-	
-
-	if (p->initid > -1) {
-		/* Don't auto congest anymore since we've gotten something useful back */
-		if (ast_sched_del(sched, p->initid) == 0)
-			dialog_unref(p,"when you delete the initid sched, you should dec the refcount for the stored dialog ptr");
-		p->initid = -1;
-	}
-	if (p->autokillid > -1) {
-		p->autokillid = -1;
-		if (ast_sched_del(sched, p->autokillid)==0)
-			dialog_unref(p,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr");
-	}
-	
+	AST_SCHED_DEL_UNREF(sched, p->initid,dialog_unref(p,"when you delete the initid sched, you should dec the refcount for the stored dialog ptr"));
+	AST_SCHED_DEL_UNREF(sched, p->waitid, dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr"));
+	AST_SCHED_DEL_UNREF(sched, p->autokillid,dialog_unref(p,"when you delete the autokillid sched, you should dec the refcount for the stored dialog ptr"));
+
 	if (p->rtp)
 		ast_rtp_destroy(p->rtp);
 	if (p->vrtp)
@@ -4501,8 +4482,7 @@
 	/* remove all current packets in this dialog */
 	while((cp = p->packets)) {
 		p->packets = p->packets->next;
-		if (cp->retransid > -1)
-			ast_sched_del(sched, cp->retransid);
+		AST_SCHED_DEL(sched, cp->retransid);
 		dialog_unref(cp->owner,"remove all current packets in this dialog, and the pointer to the dialog too");
 		ast_free(cp);
 	}
@@ -4834,8 +4814,8 @@
 			update_call_counter(p, DEC_CALL_LIMIT);
 		}
 		ast_debug(4, "SIP Transfer: Not hanging up right now... Rescheduling hangup for %s.\n", p->callid);
-		if (p->autokillid > -1)
-			sip_cancel_destroy(p);
+		if (p->autokillid > -1 && sip_cancel_destroy(p))
+			ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 		ast_clear_flag(&p->flags[0], SIP_DEFER_BYE_ON_TRANSFER);	/* Really hang up next time */
 		p->needdestroy = 0;
@@ -4967,13 +4947,9 @@
 				   but we can't send one while we have "INVITE" outstanding. */
 				ast_set_flag(&p->flags[0], SIP_PENDINGBYE);	
 				ast_clear_flag(&p->flags[0], SIP_NEEDREINVITE);	
-				if (p->waitid) {
-					if (ast_sched_del(sched, p->waitid) == 0)
-						dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr");
-				}
-				
-				p->waitid = -1;
-				sip_cancel_destroy(p);
+				AST_SCHED_DEL_UNREF(sched, p->waitid, dialog_unref(p,"when you delete the waitid sched, you should dec the refcount for the stored dialog ptr"));
+				if (sip_cancel_destroy(p))
+					ast_log(LOG_WARNING, "Unable to cancel SIP destruction.  Expect bad things.\n");
 			}
 		}
 	}
@@ -6458,7 +6434,7 @@
  	Return 0 on success, a negative value on errors.
 	Must be called after find_sdp().
 */
-static int process_sdp(struct sip_pvt *p, struct sip_request *req)
+static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action)
 {
 	const char *m;		/* SDP media offer */
 	const char *c;
@@ -6675,14 +6651,6 @@
 				ast_verbose("Got T.38 offer in SDP in dialog %s\n", p->callid);
 			udptlportno = x;
 			numberofmediastreams++;
-			
-			if (p->owner && p->lastinvite) {
-				p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
-				ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>" );
-			} else {
-				p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
-				ast_debug(2, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
-			}
 		} else 
 			ast_log(LOG_WARNING, "Unsupported SDP media type in offer: %s\n", m);
 		if (numberofports > 1)
@@ -6991,10 +6959,24 @@
 				p->t38.capability,
 				p->t38.peercapability,
 				p->t38.jointcapability);
+
+
+		/* Remote party offers T38, we need to update state */
+		if (t38action == SDP_T38_ACCEPT) {
+			if (p->t38.state == T38_LOCAL_DIRECT || p->t38.state == T38_LOCAL_REINVITE)
+				p->t38.state = T38_ENABLED;
+		} else if (t38action == SDP_T38_INITIATE) {
+			if (p->owner && p->lastinvite) {
+				p->t38.state = T38_PEER_REINVITE; /* T38 Offered in re-invite from remote party */
+			} else {
+				p->t38.state = T38_PEER_DIRECT; /* T38 Offered directly from peer in first invite */
+			}
+		}
 	} else {
 		p->t38.state = T38_DISABLED;
-		ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
-	}
+	}
+
+	ast_debug(3, "T38 state changed to %d on channel %s\n", p->t38.state, p->owner ? p->owner->name : "<none>");
 
 	/* Now gather all of the codecs that we are asked for: */
 	ast_rtp_get_current_formats(newaudiortp, &peercapability, &peernoncodeccapability);
@@ -9373,11 +9355,10 @@
 			dialog_unref(p, "unref dialog after unlink_all");
 			/* sip_destroy(p); */
 			if (r->timeout > -1) {
-				r->timeout = ast_sched_replace(r->timeout, sched, 
-					global_reg_timeout * 1000, sip_reg_timeout, r);
+				AST_SCHED_REPLACE(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r);
 				ast_log(LOG_WARNING, "Still have a registration timeout for %s@%s (create_addr() error), %d\n", r->username, r->hostname, r->timeout);
 			} else {
-				r->timeout = ast_sched_add(sched, global_reg_timeout*1000, sip_reg_timeout, r);
+				r->timeout = ast_sched_add(sched, global_reg_timeout * 1000, sip_reg_timeout, r);
 				ast_log(LOG_WARNING, "Probably a DNS error for registration to %s@%s, trying REGISTER again (after %d seconds)\n", r->username, r->hostname, global_reg_timeout);
 			}
 			r->regattempts++;
@@ -9429,7 +9410,7 @@
 	if (auth == NULL)  {
 		if (r->timeout > -1)
 			ast_log(LOG_WARNING, "Still have a registration timeout, #%d - deleting it\n", r->timeout);
-		r->timeout = ast_sched_replace(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r);
+		AST_SCHED_REPLACE(r->timeout, sched, global_reg_timeout * 1000, sip_reg_timeout, r);
 		ast_debug(1, "Scheduled a registration timeout for %s id  #%d \n", r->hostname, r->timeout);
 	}
 
@@ -9829,12 +9810,10 @@
 	peer->addr.sin_port = htons(port);
 	if (sipsock < 0) {
 		/* SIP isn't up yet, so schedule a poke only, pretty soon */
-		peer->pokeexpire = ast_sched_replace(peer->pokeexpire, sched, 
-			ast_random() % 5000 + 1, sip_poke_peer_s, peer);
+		AST_SCHED_REPLACE(peer->pokeexpire, sched, ast_random() % 5000 + 1, sip_poke_peer_s, peer);
 	} else
 		sip_poke_peer(peer);
-	peer->expire = ast_sched_replace(peer->expire, sched, 
-		(expiry + 10) * 1000, expire_register, peer);
+	AST_SCHED_REPLACE(peer->expire, sched, (expiry + 10) * 1000, expire_register, peer);
 	register_peer_exten(peer, TRUE);
 }
 
@@ -9866,8 +9845,9 @@
 	struct ast_hostent ahp;
 	int port;
 	char *host, *pt;
+	char contact_buf[256];
+	char contact2_buf[256];
 	char *contact, *contact2;
-
 
 	if (ast_test_flag(&pvt->flags[0], SIP_NAT_ROUTE)) {
 		/* NAT: Don't trust the contact field.  Just use what they came to us
@@ -9876,10 +9856,12 @@
 		return 0;
 	}
 
-
 	/* Work on a copy */
-	contact = ast_strdupa(pvt->fullcontact);
-	contact2 = ast_strdupa(pvt->fullcontact);
+	ast_copy_string(contact_buf, pvt->fullcontact, sizeof(contact_buf));
+	ast_copy_string(contact2_buf, pvt->fullcontact, sizeof(contact2_buf));
+	contact = contact_buf;
+	contact2 = contact2_buf;
+
 	/* We have only the part in <brackets> here so we just need to parse a SIP URI.*/
 
 	if (pvt->socket.type == SIP_TRANSPORT_TLS) {
@@ -9960,11 +9942,7 @@
 	} else if (!strcasecmp(curi, "*") || !expiry) {	/* Unregister this peer */
 		/* This means remove all registrations and return OK */
 		memset(&peer->addr, 0, sizeof(peer->addr));
-		if (peer->expire > -1) {
-			ast_sched_del(sched, peer->expire);
-		}
-		
-		peer->expire = -1;
+		AST_SCHED_DEL(sched, peer->expire);
 
 		destroy_association(peer);
 		
@@ -10021,10 +9999,7 @@
 	if (!ast_strlen_zero(curi) && ast_strlen_zero(peer->username))
 		ast_copy_string(peer->username, curi, sizeof(peer->username));
 
-	if (peer->expire > -1) {
-		ast_sched_del(sched, peer->expire);
-		peer->expire = -1;
-	}
+	AST_SCHED_DEL(sched, peer->expire);
 	if (expiry > max_expiry)
 		expiry = max_expiry;
 	if (expiry < min_expiry)
@@ -10395,8 +10370,8 @@
 	switch(state) {
 	case AST_EXTENSION_DEACTIVATED:	/* Retry after a while */
 	case AST_EXTENSION_REMOVED:	/* Extension is gone */
-		if (p->autokillid > -1)

[... 1216 lines stripped ...]



More information about the asterisk-commits mailing list