[asterisk-commits] oej: branch oej/pinedanish-copybridgeflags-1.6.0 r261227 - in /team/oej/pined...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed May 5 04:03:50 CDT 2010


Author: oej
Date: Wed May  5 04:03:44 2010
New Revision: 261227

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261227
Log:
Reset again

Added:
    team/oej/pinedanish-copybridgeflags-1.6.0/doc/HOWTO_collect_debug_information.txt
      - copied unchanged from r261096, branches/1.6.0/doc/HOWTO_collect_debug_information.txt
Modified:
    team/oej/pinedanish-copybridgeflags-1.6.0/   (props changed)
    team/oej/pinedanish-copybridgeflags-1.6.0/Makefile
    team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c
    team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_mixmonitor.c
    team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_voicemail.c
    team/oej/pinedanish-copybridgeflags-1.6.0/build_tools/make_build_h
    team/oej/pinedanish-copybridgeflags-1.6.0/cdr/cdr_sqlite3_custom.c
    team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_dahdi.c
    team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_h323.c
    team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c
    team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_sip.c
    team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_usbradio.c
    team/oej/pinedanish-copybridgeflags-1.6.0/config.guess
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/cdr_odbc.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/chan_dahdi.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/extensions.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/features.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/manager.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configs/sip.conf.sample
    team/oej/pinedanish-copybridgeflags-1.6.0/configure
    team/oej/pinedanish-copybridgeflags-1.6.0/configure.ac
    team/oej/pinedanish-copybridgeflags-1.6.0/contrib/scripts/safe_asterisk
    team/oej/pinedanish-copybridgeflags-1.6.0/doc/backtrace.txt
    team/oej/pinedanish-copybridgeflags-1.6.0/doc/tex/localchannel.tex
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/acl.h
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/app.h
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/astobj2.h
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/audiohook.h
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/autoconfig.h.in
    team/oej/pinedanish-copybridgeflags-1.6.0/include/asterisk/lock.h
    team/oej/pinedanish-copybridgeflags-1.6.0/main/app.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/asterisk.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/astobj2.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/audiohook.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/cdr.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/channel.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/editline/Makefile.in
    team/oej/pinedanish-copybridgeflags-1.6.0/main/editline/configure
    team/oej/pinedanish-copybridgeflags-1.6.0/main/editline/configure.in
    team/oej/pinedanish-copybridgeflags-1.6.0/main/features.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/file.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/manager.c
    team/oej/pinedanish-copybridgeflags-1.6.0/main/rtp.c
    team/oej/pinedanish-copybridgeflags-1.6.0/makeopts.in
    team/oej/pinedanish-copybridgeflags-1.6.0/pbx/pbx_dundi.c
    team/oej/pinedanish-copybridgeflags-1.6.0/res/res_agi.c
    team/oej/pinedanish-copybridgeflags-1.6.0/res/res_monitor.c
    team/oej/pinedanish-copybridgeflags-1.6.0/res/res_musiconhold.c
    team/oej/pinedanish-copybridgeflags-1.6.0/sounds/Makefile
    team/oej/pinedanish-copybridgeflags-1.6.0/tests/Makefile
    team/oej/pinedanish-copybridgeflags-1.6.0/utils/Makefile

Propchange: team/oej/pinedanish-copybridgeflags-1.6.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Wed May  5 04:03:44 2010
@@ -1,1 +1,1 @@
-/branches/1.6.0:1-253709
+/branches/1.6.0:1-261226

Propchange: team/oej/pinedanish-copybridgeflags-1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-blocked' - no diff available.

Propchange: team/oej/pinedanish-copybridgeflags-1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/Makefile?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/Makefile (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/Makefile Wed May  5 04:03:44 2010
@@ -85,7 +85,6 @@
 export DOWNLOAD
 export AWK
 export GREP
-export ID
 export MD5
 export WGET_EXTRA_ARGS
 
@@ -465,9 +464,7 @@
 	rm -f build_tools/menuselect-deps
 
 datafiles: _all
-	if [ `$(ID) -u` = 0 ]; then \
-		CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; \
-	fi
+	CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)$(libdir)/pkgconfig;
 # Should static HTTP be installed during make samples or even with its own target ala
 # webvoicemail?  There are portions here that *could* be customized but might also be
 # improved a lot.  I'll put it here for now.

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_dial.c Wed May  5 04:03:44 2010
@@ -198,10 +198,12 @@
 "           answered the call.\n"
 "    t    - Allow the called party to transfer the calling party by sending the\n"
 "           DTMF sequence defined in the blindxfer setting in the featuremap section\n"
-"           of features.conf.\n"
+"           of features.conf. This setting does not perform policy enforcement on\n"
+"           transfers initiated by other methods.\n"
 "    T    - Allow the calling party to transfer the called party by sending the\n"
 "           DTMF sequence defined in the blindxfer setting in the featuremap section\n"
-"           of features.conf.\n"
+"           of features.conf. This setting does not perform policy enforcement on\n"
+"           transfers initiated by other methods.\n"
 "    U(x[^arg]) - Execute via Gosub the routine 'x' for the *called* channel before connecting\n"
 "           to the calling channel. Arguments can be specified to the Gosub\n"
 "           using '^' as a delimeter. The Gosub routine can set the variable\n"

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_mixmonitor.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_mixmonitor.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_mixmonitor.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_mixmonitor.c Wed May  5 04:03:44 2010
@@ -245,13 +245,14 @@
 	while (mixmonitor->audiohook.status == AST_AUDIOHOOK_STATUS_RUNNING && !mixmonitor->mixmonitor_ds->fs_quit) {
 		struct ast_frame *fr = NULL;
 
-		ast_audiohook_trigger_wait(&mixmonitor->audiohook);
-
-		if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING)
-			break;
-
-		if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR)))
+		if (!(fr = ast_audiohook_read_frame(&mixmonitor->audiohook, SAMPLES_PER_FRAME, AST_AUDIOHOOK_DIRECTION_BOTH, AST_FORMAT_SLINEAR))) {
+			ast_audiohook_trigger_wait(&mixmonitor->audiohook);
+
+			if (mixmonitor->audiohook.status != AST_AUDIOHOOK_STATUS_RUNNING) {
+				break;
+			}
 			continue;
+		}
 
 		/* audiohook lock is not required for the next block.
 		 * Unlock it, but remember to lock it before looping or exiting */

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_voicemail.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_voicemail.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/apps/app_voicemail.c Wed May  5 04:03:44 2010
@@ -210,7 +210,11 @@
 
 #define BASELINELEN 72
 #define BASEMAXINLINE 256
-#define eol "\r\n"
+#ifdef IMAP_STORAGE
+#define ENDL "\r\n"
+#else
+#define ENDL "\n"
+#endif
 
 #define MAX_DATETIME_FORMAT	512
 #define MAX_NUM_CID_CONTEXTS 10
@@ -232,8 +236,9 @@
 #define VM_SEARCH        (1 << 14)
 #define VM_TEMPGREETWARN (1 << 15)  /*!< Remind user tempgreeting is set */
 #define VM_MOVEHEARD     (1 << 16)  /*!< Move a "heard" message to Old after listening to it */
-#define ERROR_LOCK_PATH  -100
+#define ERROR_LOCK_PATH     -100
 #define ERROR_MAILBOX_FULL	-200
+#define OPERATOR_EXIT        300
 
 
 enum {
@@ -1470,6 +1475,128 @@
 		return 0;
 }
 
+static int imap_check_limits(struct ast_channel *chan, struct vm_state *vms, struct ast_vm_user *vmu, int msgnum)
+{
+	/* Check if mailbox is full */
+	check_quota(vms, imapfolder);
+	if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) {
+		ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
+		ast_play_and_wait(chan, "vm-mailboxfull");
+		return -1;
+	}
+	
+	/* Check if we have exceeded maxmsg */
+	if (msgnum >= vmu->maxmsg  - inprocess_count(vmu->mailbox, vmu->context, 0)) {
+		ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg);
+		ast_play_and_wait(chan, "vm-mailboxfull");
+		return -1;
+	}
+
+	return 0;
+}
+
+static int messagecount(const char *context, const char *mailbox, const char *folder)
+{
+	SEARCHPGM *pgm;
+	SEARCHHEADER *hdr;
+
+	struct ast_vm_user *vmu, vmus;
+	struct vm_state *vms_p;
+	int ret = 0;
+	int fold = folder_int(folder);
+	
+	if (ast_strlen_zero(mailbox))
+		return 0;
+
+	/* We have to get the user before we can open the stream! */
+	/* ast_log(LOG_DEBUG, "Before find_user, context is %s and mailbox is %s\n", context, mailbox); */
+	vmu = find_user(&vmus, context, mailbox);
+	if (!vmu) {
+		ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailbox, context);
+		return -1;
+	} else {
+		/* No IMAP account available */
+		if (vmu->imapuser[0] == '\0') {
+			ast_log(LOG_WARNING, "IMAP user not set for mailbox %s\n", vmu->mailbox);
+			return -1;
+		}
+	}
+	
+	/* No IMAP account available */
+	if (vmu->imapuser[0] == '\0') {
+		ast_log(LOG_WARNING, "IMAP user not set for mailbox %s\n", vmu->mailbox);
+		free_user(vmu);
+		return -1;
+	}
+
+	/* check if someone is accessing this box right now... */
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1);
+	if (!vms_p) {
+		vms_p = get_vm_state_by_mailbox(mailbox, 1);
+	}
+	if (vms_p) {
+		ast_debug(3, "Returning before search - user is logged in\n");
+		if (fold == 0) { /* INBOX */
+			return vms_p->newmessages;
+		}
+		if (fold == 1) { /* Old messages */
+			return vms_p->oldmessages;
+		}
+	}
+
+	/* add one if not there... */
+	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0);
+	if (!vms_p) {
+		vms_p = get_vm_state_by_mailbox(mailbox, 0);
+	}
+
+	if (!vms_p) {
+		vms_p = create_vm_state_from_user(vmu);
+	}
+	ret = init_mailstream(vms_p, fold);
+	if (!vms_p->mailstream) {
+		ast_log(LOG_ERROR, "Houston we have a problem - IMAP mailstream is NULL\n");
+		return -1;
+	}
+	if (ret == 0) {
+		ast_mutex_lock(&vms_p->lock);
+		pgm = mail_newsearchpgm ();
+		hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)(!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : mailbox));
+		hdr->next = mail_newsearchheader("X-Asterisk-VM-Context", (char *) S_OR(context, "default"));
+		pgm->header = hdr;
+		if (fold != 1) {
+			pgm->unseen = 1;
+			pgm->seen = 0;
+		}
+		/* In the special case where fold is 1 (old messages) we have to do things a bit
+		* differently. Old messages are stored in the INBOX but are marked as "seen"
+		*/
+		else {
+			pgm->unseen = 0;
+			pgm->seen = 1;
+		}
+		pgm->undeleted = 1;
+		pgm->deleted = 0;
+
+		vms_p->vmArrayIndex = 0;
+		mail_search_full (vms_p->mailstream, NULL, pgm, NIL);
+		if (fold == 0)
+			vms_p->newmessages = vms_p->vmArrayIndex;
+		if (fold == 1)
+			vms_p->oldmessages = vms_p->vmArrayIndex;
+		/* Freeing the searchpgm also frees the searchhdr */
+		mail_free_searchpgm(&pgm);
+		ast_mutex_unlock(&vms_p->lock);
+		vms_p->updated = 0;
+		return vms_p->vmArrayIndex;
+	} else {
+		ast_mutex_lock(&vms_p->lock);
+		mail_ping(vms_p->mailstream);
+		ast_mutex_unlock(&vms_p->lock);
+	}
+	return 0;
+}
+
 static int imap_store_file(char *dir, char *mailboxuser, char *mailboxcontext, int msgnum, struct ast_channel *chan, struct ast_vm_user *vmu, char *fmt, int duration, struct vm_state *vms)
 {
 	char *myserveremail = serveremail;
@@ -1482,10 +1609,14 @@
 	void *buf;
 	int tempcopy = 0;
 	STRING str;
+	int msgcount = (messagecount(vmu->context, vmu->mailbox, "INBOX") + messagecount(vmu->context, vmu->mailbox, "Old"));
 
 	/* Back out early if this is a greeting and we don't want to store greetings in IMAP */
 	if (msgnum < 0 && !imapgreetings) {
 		return 0;
+	}
+	if (imap_check_limits(chan, vms, vmu, msgcount)) {
+		return -1;
 	}
 	
 	/* Attach only the first format */
@@ -1564,107 +1695,6 @@
 
 }
 
-static int messagecount(const char *context, const char *mailbox, const char *folder)
-{
-	SEARCHPGM *pgm;
-	SEARCHHEADER *hdr;
-
-	struct ast_vm_user *vmu, vmus;
-	struct vm_state *vms_p;
-	int ret = 0;
-	int fold = folder_int(folder);
-	
-	if (ast_strlen_zero(mailbox))
-		return 0;
-
-	/* We have to get the user before we can open the stream! */
-	/* ast_log(LOG_DEBUG, "Before find_user, context is %s and mailbox is %s\n", context, mailbox); */
-	vmu = find_user(&vmus, context, mailbox);
-	if (!vmu) {
-		ast_log(LOG_ERROR, "Couldn't find mailbox %s in context %s\n", mailbox, context);
-		return -1;
-	} else {
-		/* No IMAP account available */
-		if (vmu->imapuser[0] == '\0') {
-			ast_log(LOG_WARNING, "IMAP user not set for mailbox %s\n", vmu->mailbox);
-			return -1;
-		}
-	}
-	
-	/* No IMAP account available */
-	if (vmu->imapuser[0] == '\0') {
-		ast_log(LOG_WARNING, "IMAP user not set for mailbox %s\n", vmu->mailbox);
-		free_user(vmu);
-		return -1;
-	}
-
-	/* check if someone is accessing this box right now... */
-	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 1);
-	if (!vms_p) {
-		vms_p = get_vm_state_by_mailbox(mailbox, 1);
-	}
-	if (vms_p) {
-		ast_debug(3, "Returning before search - user is logged in\n");
-		if (fold == 0) { /* INBOX */
-			return vms_p->newmessages;
-		}
-		if (fold == 1) { /* Old messages */
-			return vms_p->oldmessages;
-		}
-	}
-
-	/* add one if not there... */
-	vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0);
-	if (!vms_p) {
-		vms_p = get_vm_state_by_mailbox(mailbox, 0);
-	}
-
-	if (!vms_p) {
-		vms_p = create_vm_state_from_user(vmu);
-	}
-	ret = init_mailstream(vms_p, fold);
-	if (!vms_p->mailstream) {
-		ast_log(LOG_ERROR, "Houston we have a problem - IMAP mailstream is NULL\n");
-		return -1;
-	}
-	if (ret == 0) {
-		ast_mutex_lock(&vms_p->lock);
-		pgm = mail_newsearchpgm ();
-		hdr = mail_newsearchheader ("X-Asterisk-VM-Extension", (char *)(!ast_strlen_zero(vmu->imapvmshareid) ? vmu->imapvmshareid : mailbox));
-		hdr->next = mail_newsearchheader("X-Asterisk-VM-Context", (char *) S_OR(context, "default"));
-		pgm->header = hdr;
-		if (fold != 1) {
-			pgm->unseen = 1;
-			pgm->seen = 0;
-		}
-		/* In the special case where fold is 1 (old messages) we have to do things a bit
-		* differently. Old messages are stored in the INBOX but are marked as "seen"
-		*/
-		else {
-			pgm->unseen = 0;
-			pgm->seen = 1;
-		}
-		pgm->undeleted = 1;
-		pgm->deleted = 0;
-
-		vms_p->vmArrayIndex = 0;
-		mail_search_full (vms_p->mailstream, NULL, pgm, NIL);
-		if (fold == 0)
-			vms_p->newmessages = vms_p->vmArrayIndex;
-		if (fold == 1)
-			vms_p->oldmessages = vms_p->vmArrayIndex;
-		/* Freeing the searchpgm also frees the searchhdr */
-		mail_free_searchpgm(&pgm);
-		ast_mutex_unlock(&vms_p->lock);
-		vms_p->updated = 0;
-		return vms_p->vmArrayIndex;
-	} else {
-		ast_mutex_lock(&vms_p->lock);
-		mail_ping(vms_p->mailstream);
-		ast_mutex_unlock(&vms_p->lock);
-	}
-	return 0;
-}
 static int inboxcount(const char *mailbox_context, int *newmsgs, int *oldmsgs)
 {
 	char tmp[PATH_MAX] = "";
@@ -3315,14 +3345,16 @@
 static int ochar(struct baseio *bio, int c, FILE *so)
 {
 	if (bio->linelength >= BASELINELEN) {
-		if (fputs(eol, so) == EOF)
+		if (fputs(ENDL, so) == EOF) {
 			return -1;
-
-		bio->linelength= 0;
-	}
-
-	if (putc(((unsigned char)c), so) == EOF)
+		}
+
+		bio->linelength = 0;
+	}
+
+	if (putc(((unsigned char)c), so) == EOF) {
 		return -1;
+	}
 
 	bio->linelength++;
 
@@ -3382,8 +3414,9 @@
 
 	fclose(fi);
 	
-	if (fputs(eol, so) == EOF)
+	if (fputs(ENDL, so) == EOF) {
 		return 0;
+	}
 
 	return 1;
 }
@@ -3581,12 +3614,6 @@
 	size_t len_passdata = 0, len_passdata2, tmplen;
 	char *greeting_attachment;
 
-#ifdef IMAP_STORAGE
-#define ENDL "\r\n"
-#else
-#define ENDL "\n"
-#endif
-
 	/* One alloca for multiple fields */
 	len_passdata2 = strlen(vmu->fullname);
 	if (emailsubject && (tmplen = strlen(emailsubject)) > len_passdata2) {
@@ -3754,7 +3781,22 @@
 			memset(passdata, 0, vmlen);
 			prep_email_sub_vars(ast, vmu, msgnum + 1, context, mailbox, fromfolder, cidnum, cidname, dur, date, passdata, vmlen, category);
 			pbx_substitute_variables_helper(ast, emailbody, passdata, vmlen);
+#ifdef IMAP_STORAGE
+			{
+				/* Convert body to native line terminators for IMAP backend */
+				char *line = passdata, *next;
+				do {
+					/* Terminate line before outputting it to the file */
+					if ((next = strchr(line, '\n'))) {
+						*next++ = '\0';
+					}
+					fprintf(p, "%s" ENDL, line);
+					line = next;
+				} while (!ast_strlen_zero(line));
+			}
+#else
 			fprintf(p, "%s" ENDL, passdata);
+#endif
 			ast_channel_free(ast);
 		} else
 			ast_log(LOG_WARNING, "Cannot allocate the channel for variables substitution\n");
@@ -3852,7 +3894,6 @@
 			unlink(newtmp);
 		}
 	}
-#undef ENDL
 }
 
 static int sendmail(char *srcemail, struct ast_vm_user *vmu, int msgnum, char *context, char *mailbox, const char *fromfolder, char *cidnum, char *cidname, char *attach, char *format, int duration, int attach_user_voicemail, struct ast_channel *chan, const char *category)
@@ -4208,6 +4249,7 @@
 		char fromdir[PATH_MAX], todir[PATH_MAX], frompath[PATH_MAX], topath[PATH_MAX];
 		const char *frombox = mbox(imbox);
 		int recipmsgnum;
+		int res = 0;
 
 		ast_log(LOG_NOTICE, "Copying message from %s@%s to %s@%s\n", vmu->mailbox, vmu->context, recip->mailbox, recip->context);
 
@@ -4230,11 +4272,12 @@
 			COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath);
 		} else {
 			ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
+			res = -1;
 		}
 		ast_unlock_path(todir);
 		notify_new_message(chan, recip, NULL, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));
 		
-		return 0;
+		return res;
 	}
 #endif
 #if !(defined(IMAP_STORAGE) || defined(ODBC_STORAGE))
@@ -4582,7 +4625,7 @@
 			pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT");
 		}
 		ast_free(tmp);
-		return 0;
+		return OPERATOR_EXIT;
 	}
 
 	/* Allow all other digits to exit Voicemail and return to the dialplan */
@@ -4635,22 +4678,10 @@
 		/* set variable for compatibility */
 		pbx_builtin_setvar_helper(chan, "VM_MESSAGEFILE", "IMAP_STORAGE");
 
-		/* Check if mailbox is full */
-		check_quota(vms, imapfolder);
-		if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) {
-			ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit);
-			ast_play_and_wait(chan, "vm-mailboxfull");
-			ast_free(tmp);
-			return -1;
-		}
-
-		/* Check if we have exceeded maxmsg */
-		if (msgnum >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, 0)) {
-			ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg);
-			ast_play_and_wait(chan, "vm-mailboxfull");
-			ast_free(tmp);
-			return -1;
-		}
+		if ((res = imap_check_limits(chan, vms, vmu, msgnum))) {
+			goto leave_vm_out;
+		}
+
 #else
 		if (count_messages(vmu, dir) >= vmu->maxmsg - inprocess_count(vmu->mailbox, vmu->context, +1)) {
 			res = ast_streamfile(chan, "vm-mailboxfull", chan->language);
@@ -5491,10 +5522,16 @@
 	static int get_folder2(struct ast_channel *chan, char *fn, int start)
 	{
 		int res = 0;
+		int loops = 0;
 		res = ast_play_and_wait(chan, fn);	/* Folder name */
 		while (((res < '0') || (res > '9')) &&
-				(res != '#') && (res >= 0)) {
+				(res != '#') && (res >= 0) &&
+				loops < 4) {
 			res = get_folder(chan, 0);
+			loops++;
+		}
+		if (loops == 4) { /* give up */
+			return '#';
 		}
 		return res;
 	}
@@ -5711,6 +5748,7 @@
 		int valid_extensions = 0;
 		char *dir;
 		int curmsg;
+		int prompt_played = 0;
 
 		if (vms == NULL) return -1;
 		dir = vms->curdir;
@@ -5790,7 +5828,8 @@
 			} else {
 				/* Ask for an extension */
 				res = ast_streamfile(chan, "vm-extension", chan->language);	/* "extension" */
-				if (res)
+				prompt_played++;
+				if (res || prompt_played > 4)
 					break;
 				if ((res = ast_readstring(chan, username, sizeof(username) - 1, 2000, 10000, "#") < 0))
 					break;
@@ -5860,6 +5899,7 @@
 			long duration = 0;
 			char origmsgfile[PATH_MAX], msgfile[PATH_MAX];
 			struct vm_state vmstmp;
+			int copy_msg_result = 0;
 			memcpy(&vmstmp, vms, sizeof(vmstmp));
 
 			make_file(origmsgfile, sizeof(origmsgfile), dir, curmsg);
@@ -5887,7 +5927,7 @@
 						if (!dstvms->mailstream) {
 							ast_log(LOG_ERROR, "IMAP mailstream for %s is NULL\n", vmtmp->mailbox);
 						} else {
-							STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms);
+							copy_msg_result = STORE(vmstmp.curdir, vmtmp->mailbox, vmtmp->context, dstvms->curmsg, chan, vmtmp, fmt, duration, dstvms);
 							run_externnotify(vmtmp->context, vmtmp->mailbox); 
 						}
 					} else {
@@ -5899,7 +5939,7 @@
 					/* NULL category for IMAP storage */
 					sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, dstvms->curbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
 #else
-					copy_message(chan, sender, -1, curmsg, duration, vmtmp, fmt, vmstmp.curdir);
+					copy_msg_result = copy_message(chan, sender, -1, curmsg, duration, vmtmp, fmt, vmstmp.curdir);
 #endif
 					saved_messages++;
 					AST_LIST_REMOVE_CURRENT(list);
@@ -5908,7 +5948,7 @@
 						break;
 				}
 				AST_LIST_TRAVERSE_SAFE_END;
-				if (saved_messages > 0) {
+				if (saved_messages > 0 && !copy_msg_result) {
 					/* give confirmation that the message was saved */
 					/* commented out since we can't forward batches yet
 					if (saved_messages == 1)
@@ -5920,6 +5960,10 @@
 					res = ast_play_and_wait(chan, "vm-msgsaved");
 				}
 #ifndef IMAP_STORAGE
+				else {
+					/* with IMAP, mailbox full warning played by imap_check_limits */
+					res = ast_play_and_wait(chan, "vm-mailboxfull");
+				}
 				/* Restore original message without prepended message if backup exists */
 				make_file(msgfile, sizeof(msgfile), dir, curmsg);
 				strcpy(textfile, msgfile);
@@ -8328,7 +8372,7 @@
 				case '1': /* Reply */
 					if (vms.lastmsg > -1 && !vms.starting) {
 						cmd = advanced_options(chan, vmu, &vms, vms.curmsg, 1, record_gain);
-						if (cmd == ERROR_LOCK_PATH) {
+						if (cmd == ERROR_LOCK_PATH || cmd == OPERATOR_EXIT) {
 							res = cmd;
 							goto out;
 						}
@@ -8378,9 +8422,8 @@
 				case '5': /* Leave VoiceMail */
 					if (ast_test_flag(vmu, VM_SVMAIL)) {
 						cmd = forward_message(chan, context, &vms, vmu, vmfmts, 1, record_gain);
-						if (cmd == ERROR_LOCK_PATH) {
+						if (cmd == ERROR_LOCK_PATH || cmd == OPERATOR_EXIT) {
 							res = cmd;
-							ast_log(LOG_WARNING, "forward_message failed to lock path.\n");
 							goto out;
 						}
 					} else
@@ -8571,13 +8614,14 @@
 	if (res > -1) {
 		ast_stopstream(chan);
 		adsi_goodbye(chan);
-		if (valid) {
+		if (valid && res != OPERATOR_EXIT) {
 			if (silentexit)
 				res = ast_play_and_wait(chan, "vm-dialout");
 			else 
 				res = ast_play_and_wait(chan, "vm-goodbye");
-			if (res > 0)
-				res = 0;
+		}
+		if ((valid && res > 0) || res == OPERATOR_EXIT) {
+			res = 0;
 		}
 		if (useadsi)
 			ast_adsi_unload_session(chan);
@@ -10502,10 +10546,10 @@
 			}
 		}
 	}
-	if (outsidecaller)
-		ast_play_and_wait(chan, "vm-goodbye");
 	if (cmd == 't')
 		cmd = 0;
+	else if (outsidecaller) /* won't play if time out occurs */
+		ast_play_and_wait(chan, "vm-goodbye");
 	return cmd;
 }
 

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/build_tools/make_build_h
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/build_tools/make_build_h?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/build_tools/make_build_h (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/build_tools/make_build_h Wed May  5 04:03:44 2010
@@ -3,7 +3,7 @@
 KERNEL=`uname -r`
 MACHINE=`uname -m`
 OS=`uname -s`
-USER=`${ID} -un`
+USER=`id | awk -F")" '{print $1}'| awk -F"(" '{print $2}'`
 DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
 cat << END
 /*

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/cdr/cdr_sqlite3_custom.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/cdr/cdr_sqlite3_custom.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/cdr/cdr_sqlite3_custom.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/cdr/cdr_sqlite3_custom.c Wed May  5 04:03:44 2010
@@ -51,6 +51,7 @@
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
+#include "asterisk/app.h"
 
 AST_MUTEX_DEFINE_STATIC(lock);
 
@@ -64,8 +65,8 @@
 static char *columns;
 
 struct values {
-	char *expression;
 	AST_LIST_ENTRY(values) list;
+	char expression[1];
 };
 
 static AST_LIST_HEAD_STATIC(sql_values, values);
@@ -121,9 +122,12 @@
 
 static int load_values_config(const char *tmp)
 {
-	char *val = NULL;
 	char *vals = NULL, *save = NULL;
 	struct values *value = NULL;
+	int i;
+	AST_DECLARE_APP_ARGS(val,
+		AST_APP_ARG(ues)[200]; /* More than 200 columns in this CDR?  Yeah, right... */
+	);
 
 	if (ast_strlen_zero(tmp)) {
 		ast_log(LOG_WARNING, "Values not specified. Module not loaded.\n");
@@ -133,17 +137,17 @@
 		ast_log(LOG_ERROR, "Out of memory creating temporary buffer for value '%s'\n", tmp);
 		return -1;
 	}
-	while ((val = strsep(&vals, ","))) {
+	AST_STANDARD_RAW_ARGS(val, vals);
+	for (i = 0; i < val.argc; i++) {
 		/* Strip the single quotes off if they are there */
-		val = ast_strip_quoted(val, "'", "'");
-		value = ast_calloc(sizeof(char), sizeof(*value) + strlen(val) + 1);
+		char *v = ast_strip_quoted(val.ues[i], "'", "'");
+		value = ast_calloc(sizeof(char), sizeof(*value) + strlen(v));
 		if (!value) {
-			ast_log(LOG_ERROR, "Out of memory creating entry for value '%s'\n", val);
+			ast_log(LOG_ERROR, "Out of memory creating entry for value '%s'\n", v);
 			ast_free(save);
 			return -1;
 		}
-		value->expression = (char *) value + sizeof(*value);
-		ast_copy_string(value->expression, val, strlen(val) + 1);
+		strcpy(value->expression, v); /* SAFE */
 		AST_LIST_INSERT_TAIL(&sql_values, value, list);
 	}
 	ast_free(save);

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_dahdi.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_dahdi.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_dahdi.c Wed May  5 04:03:44 2010
@@ -4146,7 +4146,6 @@
 
 #ifdef PRI_2BCT
 	int triedtopribridge = 0;
-	q931_call *q931c0 = NULL, *q931c1 = NULL;
 #endif
 
 	/* For now, don't attempt to native bridge if either channel needs DTMF detection.
@@ -4367,13 +4366,15 @@
 		}
 
 #ifdef PRI_2BCT
-		q931c0 = p0->call;
-		q931c1 = p1->call;
-		if (p0->transfer && p1->transfer 
-		    && q931c0 && q931c1 
-		    && !triedtopribridge) {
-			pri_channel_bridge(q931c0, q931c1);
+		if (!triedtopribridge) {
 			triedtopribridge = 1;
+			if (p0->pri && p0->pri == p1->pri && p0->transfer && p1->transfer) {
+				ast_mutex_lock(&p0->pri->lock);
+				if (p0->call && p1->call) {
+					pri_channel_bridge(p0->call, p1->call);
+				}
+				ast_mutex_unlock(&p0->pri->lock);
+			}
 		}
 #endif
 
@@ -5020,6 +5021,7 @@
 					p->subs[index].f.frametype = AST_FRAME_CONTROL;
 					p->subs[index].f.subclass = AST_CONTROL_ANSWER;
 					/* Make sure it stops ringing */
+					p->subs[SUB_REAL].needringing = 0;
 					dahdi_set_hook(p->subs[index].dfd, DAHDI_OFFHOOK);
 					ast_debug(1, "channel %d answered\n", p->channel);
 					if (p->cidspill) {
@@ -7238,14 +7240,25 @@
 			if (p->cid_signalling == CID_SIG_DTMF) {
 				int i = 0;
 				cs = NULL;
-				ast_debug(1, "Receiving DTMF cid on "
-					"channel %s\n", chan->name);
+				ast_debug(1, "Receiving DTMF cid on channel %s\n", chan->name);
 				dahdi_setlinear(p->subs[index].dfd, 0);
-				res = 2000;
+				/*
+				 * We are the only party interested in the Rx stream since
+				 * we have not answered yet.  We don't need or even want DTMF
+				 * emulation.  The DTMF digits can come so fast that emulation
+				 * can drop some of them.
+				 */
+				ast_set_flag(chan, AST_FLAG_END_DTMF_ONLY);
+				res = 4000;/* This is a typical OFF time between rings. */
 				for (;;) {
 					struct ast_frame *f;
 					res = ast_waitfor(chan, res);
 					if (res <= 0) {
+						/*
+						 * We do not need to restore the dahdi_setlinear()
+						 * or AST_FLAG_END_DTMF_ONLY flag settings since we
+						 * are hanging up the channel.
+						 */
 						ast_log(LOG_WARNING, "DTMFCID timed out waiting for ring. "
 							"Exiting simple switch\n");
 						ast_hangup(chan);
@@ -7255,22 +7268,24 @@
 					if (!f)
 						break;
 					if (f->frametype == AST_FRAME_DTMF) {
-						dtmfbuf[i++] = f->subclass;
+						if (i < ARRAY_LEN(dtmfbuf) - 1) {
+							dtmfbuf[i++] = f->subclass;
+						}
 						ast_debug(1, "CID got digit '%c'\n", f->subclass);
-						res = 2000;
+						res = 4000;/* This is a typical OFF time between rings. */
 					}
 					ast_frfree(f);
 					if (chan->_state == AST_STATE_RING ||
 					    chan->_state == AST_STATE_RINGING) 
 						break; /* Got ring */
 				}
+				ast_clear_flag(chan, AST_FLAG_END_DTMF_ONLY);
 				dtmfbuf[i] = '\0';
 				dahdi_setlinear(p->subs[index].dfd, p->subs[index].linear);
 				/* Got cid and ring. */
 				ast_debug(1, "CID got string '%s'\n", dtmfbuf);
 				callerid_get_dtmf(dtmfbuf, dtmfcid, &flags);
-				ast_debug(1, "CID is '%s', flags %d\n", 
-					dtmfcid, flags);
+				ast_debug(1, "CID is '%s', flags %d\n", dtmfcid, flags);
 				/* If first byte is NULL, we have no cid */
 				if (!ast_strlen_zero(dtmfcid)) 
 					number = dtmfcid;
@@ -7330,9 +7345,14 @@
 							} else {
 								res = callerid_feed(cs, buf, res, AST_LAW(p));
 							}
-
 							if (res < 0) {
-								ast_log(LOG_WARNING, "CallerID feed failed on channel '%s'\n", chan->name);
+								/*
+								 * The previous diagnostic message output likely
+								 * explains why it failed.
+								 */
+								ast_log(LOG_WARNING,
+									"Failed to decode CallerID on channel '%s'\n",
+									chan->name);
 								break;
 							} else if (res)
 								break;
@@ -7348,13 +7368,10 @@
 					if (p->cid_signalling == CID_SIG_V23_JP) {
 						res = dahdi_set_hook(p->subs[SUB_REAL].dfd, DAHDI_ONHOOK);
 						usleep(1);
-						res = 4000;
-					} else {
-
-						/* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */ 
-						res = 2000;
 					}
 
+					/* Finished with Caller*ID, now wait for a ring to make sure there really is a call coming */
+					res = 4000;/* This is a typical OFF time between rings. */
 					for (;;) {
 						struct ast_frame *f;
 						res = ast_waitfor(chan, res);
@@ -7599,7 +7616,13 @@
 						samples += res;
 						res = callerid_feed(cs, buf, res, AST_LAW(p));
 						if (res < 0) {
-							ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno));
+							/*
+							 * The previous diagnostic message output likely
+							 * explains why it failed.
+							 */
+							ast_log(LOG_WARNING,
+								"Failed to decode CallerID on channel '%s'\n",
+								chan->name);
 							break;
 						} else if (res)
 							break;
@@ -7859,7 +7882,11 @@
 			samples += res;
 			if (!spill_done) {
 				if ((spill_result = callerid_feed(cs, mtd->buf, res, AST_LAW(mtd->pvt))) < 0) {
-					ast_log(LOG_WARNING, "CallerID feed failed: %s\n", strerror(errno));
+					/*
+					 * The previous diagnostic message output likely
+					 * explains why it failed.
+					 */
+					ast_log(LOG_WARNING, "Failed to decode CallerID\n");
 					break;
 				} else if (spill_result) {
 					spill_done = 1;
@@ -8939,6 +8966,7 @@
 		tmp->adsi = conf->chan.adsi;
 		tmp->use_smdi = conf->chan.use_smdi;
 		tmp->permhidecallerid = conf->chan.hidecallerid;
+		tmp->hidecalleridname = conf->chan.hidecalleridname;
 		tmp->callreturn = conf->chan.callreturn;
 		tmp->echocancel = conf->chan.echocancel;
 		tmp->echotraining = conf->chan.echotraining;
@@ -9003,12 +9031,18 @@
 		ast_copy_string(tmp->mohsuggest, conf->chan.mohsuggest, sizeof(tmp->mohsuggest));
 		ast_copy_string(tmp->context, conf->chan.context, sizeof(tmp->context));
 		tmp->cid_ton = 0;
-		if ((tmp->sig != SIG_PRI) || (tmp->sig != SIG_SS7) || (tmp->sig != SIG_BRI) || (tmp->sig != SIG_BRI_PTMP)) {
+		switch (tmp->sig) {
+		case SIG_PRI:
+		case SIG_BRI:
+		case SIG_BRI_PTMP:
+		case SIG_SS7:
+			tmp->cid_num[0] = '\0';
+			tmp->cid_name[0] = '\0';
+			break;
+		default:
 			ast_copy_string(tmp->cid_num, conf->chan.cid_num, sizeof(tmp->cid_num));
 			ast_copy_string(tmp->cid_name, conf->chan.cid_name, sizeof(tmp->cid_name));
-		} else {
-			tmp->cid_num[0] = '\0';
-			tmp->cid_name[0] = '\0';
+			break;
 		}
 		ast_copy_string(tmp->mailbox, conf->chan.mailbox, sizeof(tmp->mailbox));
 		if (channel != CHAN_PSEUDO && !ast_strlen_zero(tmp->mailbox)) {

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_h323.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_h323.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_h323.c Wed May  5 04:03:44 2010
@@ -3304,7 +3304,7 @@
 			ASTOBJ_CONTAINER_DESTROYALL(&aliasl, oh323_destroy_alias);
 			ASTOBJ_CONTAINER_DESTROY(&aliasl);
 
-			return AST_MODULE_LOAD_FAILURE;
+			return AST_MODULE_LOAD_DECLINE;
 		}
 		/* Possibly register with a GK */
 		if (!gatekeeper_disable) {

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c (original)
+++ team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_local.c Wed May  5 04:03:44 2010
@@ -252,7 +252,11 @@
 	return res;
 }
 
-static void check_bridge(struct local_pvt *p, int isoutbound)
+/*!
+ * \internal
+ * \note This function assumes that we're only called from the "outbound" local channel side
+ */
+static void check_bridge(struct local_pvt *p)
 {
 	struct ast_channel_monitor *tmp;
 	if (ast_test_flag(p, LOCAL_ALREADY_MASQED) || ast_test_flag(p, LOCAL_NO_OPTIMIZATION) || !p->chan || !p->owner || (p->chan->_bridge != ast_bridged_channel(p->chan)))
@@ -263,7 +267,7 @@
 	   frames on the owner channel (because they would be transferred to the
 	   outbound channel during the masquerade)
 	*/
-	if (isoutbound && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && AST_LIST_EMPTY(&p->owner->readq)) {
+	if (p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && AST_LIST_EMPTY(&p->owner->readq)) {
 		/* Masquerade bridged channel into owner */
 		/* Lock everything we need, one by one, and give up if
 		   we can't get everything.  Remember, we'll get another
@@ -302,26 +306,6 @@
 				ast_channel_unlock(p->chan->_bridge);
 			}
 		}
-	/* We only allow masquerading in one 'direction'... it's important to preserve the state
-	   (group variables, etc.) that live on p->chan->_bridge (and were put there by the dialplan)
-	   when the local channels go away.
-	*/
-#if 0
-	} else if (!isoutbound && p->owner && p->owner->_bridge && p->chan && AST_LIST_EMPTY(&p->chan->readq)) {
-		/* Masquerade bridged channel into chan */
-		if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
-			if (!ast_check_hangup(p->owner->_bridge)) {
-				if (!ast_mutex_trylock(&p->chan->lock)) {
-					if (!ast_check_hangup(p->chan)) {
-						ast_channel_masquerade(p->chan, p->owner->_bridge);
-						ast_set_flag(p, LOCAL_ALREADY_MASQED);
-					}
-					ast_mutex_unlock(&p->chan->lock);
-				}
-			}
-			ast_mutex_unlock(&(p->owner->_bridge)->lock);
-		}
-#endif
 	}
 }
 
@@ -342,8 +326,8 @@
 	/* Just queue for delivery to the other side */
 	ast_mutex_lock(&p->lock);
 	isoutbound = IS_OUTBOUND(ast, p);
-	if (f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO))
-		check_bridge(p, isoutbound);
+	if (isoutbound && f && (f->frametype == AST_FRAME_VOICE || f->frametype == AST_FRAME_VIDEO))
+		check_bridge(p);
 	if (!ast_test_flag(p, LOCAL_ALREADY_MASQED))
 		res = local_queue_frame(p, isoutbound, f, ast, 1);
 	else {
@@ -561,12 +545,12 @@
 			/* Deadlock avoidance */
 			while (p->owner && ast_channel_trylock(p->owner)) {
 				ast_mutex_unlock(&p->lock);
-				if (ast) {
-					ast_channel_unlock(ast);
+				if (p->chan) {
+					ast_channel_unlock(p->chan);
 				}
 				usleep(1);
-				if (ast) {
-					ast_channel_lock(ast);
+				if (p->chan) {
+					ast_channel_lock(p->chan);
 				}
 				ast_mutex_lock(&p->lock);
 			}
@@ -581,8 +565,17 @@
 	} else {
 		ast_module_user_remove(p->u_owner);
 		while (p->chan && ast_channel_trylock(p->chan)) {
-			DEADLOCK_AVOIDANCE(&p->lock);
-		}
+				ast_mutex_unlock(&p->lock);
+				if (p->owner) {
+					ast_channel_unlock(p->owner);
+				}
+				usleep(1);
+				if (p->owner) {
+					ast_channel_lock(p->owner);
+				}
+				ast_mutex_lock(&p->lock);
+		}
+
 		p->owner = NULL;
 		if (p->chan) {
 			ast_queue_hangup(p->chan);

Modified: team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_sip.c?view=diff&rev=261227&r1=261226&r2=261227
==============================================================================
--- team/oej/pinedanish-copybridgeflags-1.6.0/channels/chan_sip.c (original)

[... 2588 lines stripped ...]



More information about the asterisk-commits mailing list