[svn-commits] rmudgett: branch rmudgett/misdn_facility r183387 - in /team/rmudgett/misdn_fa...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 19 14:52:11 CDT 2009


Author: rmudgett
Date: Thu Mar 19 14:52:06 2009
New Revision: 183387

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183387
Log:
Merged revisions 183236-183237,183269,183332,183343 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/group/issue8824

................
  r183236 | mmichelson | 2009-03-19 12:37:48 -0500 (Thu, 19 Mar 2009) | 3 lines
  
  Handle allocation failures of ast_strdupa calls in chan_local
................
  r183237 | mmichelson | 2009-03-19 12:39:01 -0500 (Thu, 19 Mar 2009) | 3 lines
  
  Resolve conflict. Reset automerge
................
  r183269 | root | 2009-03-19 13:22:30 -0500 (Thu, 19 Mar 2009) | 45 lines
  
  Merged revisions 183239,183242,183244 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
    r183239 | russell | 2009-03-19 12:42:06 -0500 (Thu, 19 Mar 2009) | 9 lines
    
    Merged revisions 183238 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
    r183238 | russell | 2009-03-19 12:41:39 -0500 (Thu, 19 Mar 2009) | 1 line
    
    Allow the AES API to work.
    ........
  ................
    r183242 | russell | 2009-03-19 13:00:15 -0500 (Thu, 19 Mar 2009) | 10 lines
    
    Merged revisions 183241 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
    r183241 | russell | 2009-03-19 12:52:52 -0500 (Thu, 19 Mar 2009) | 2 lines
    
    Remove the use of RTLD_NOLOAD, as it is not behaving like expected.
    
    ........
  ................
    r183244 | mmichelson | 2009-03-19 13:10:34 -0500 (Thu, 19 Mar 2009) | 16 lines
    
    Fix a memory leak associated with queues.
    
    For every attempt that app_queue made to place an outbound call to a queue member,
    we would allocate a queue_end_bridge structure. When the bridge for the call had
    completed, we would free the structure. Unfortunately not all call attempts actually
    end up bridged to a member, so we need to be more selective of when to allocate
    the structure. With this change, the allocation occurs in an area where we can
    guarantee that the call will be bridged.
    
    (closes issue #14680)
    Reported by: caspy
    Patches:
          14680.patch uploaded by mmichelson (license 60)
    Tested by: caspy
  ................
................
  r183332 | mmichelson | 2009-03-19 14:19:26 -0500 (Thu, 19 Mar 2009) | 5 lines
  
  Some progress towards addressing Russell's comments.
  
  Please don't look at the diff of chan_local. It is embarrassing.
................
  r183343 | root | 2009-03-19 14:21:52 -0500 (Thu, 19 Mar 2009) | 33 lines
  
  Merged revisions 183312,183321 via svnmerge from 
  file:///srv/subversion/repos/asterisk/trunk
  
  ................
    r183312 | qwell | 2009-03-19 13:34:11 -0500 (Thu, 19 Mar 2009) | 9 lines
    
    Merged revisions 183291 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r183291 | qwell | 2009-03-19 13:28:16 -0500 (Thu, 19 Mar 2009) | 1 line
      
      Export some more required symbols.
    ........
  ................
    r183321 | tilghman | 2009-03-19 14:17:31 -0500 (Thu, 19 Mar 2009) | 15 lines
    
    Merged revisions 183319 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r183319 | tilghman | 2009-03-19 14:15:33 -0500 (Thu, 19 Mar 2009) | 8 lines
      
      Delay signalling progress until a PRI channel really signals progress.
      (closes issue #13034)
       Reported by: klaus3000
       Patches: 
             20090316__bug13034.diff.txt uploaded by tilghman (license 14)
             patch_trunk_183progress_klaus3000.txt uploaded by klaus3000 (license 65)
       Tested by: klaus3000
    ........
  ................
................

Modified:
    team/rmudgett/misdn_facility/   (props changed)
    team/rmudgett/misdn_facility/apps/app_dial.c
    team/rmudgett/misdn_facility/apps/app_queue.c
    team/rmudgett/misdn_facility/channels/chan_dahdi.c
    team/rmudgett/misdn_facility/channels/chan_local.c
    team/rmudgett/misdn_facility/channels/chan_sip.c
    team/rmudgett/misdn_facility/configure
    team/rmudgett/misdn_facility/configure.ac
    team/rmudgett/misdn_facility/include/asterisk/autoconfig.h.in
    team/rmudgett/misdn_facility/include/asterisk/features.h
    team/rmudgett/misdn_facility/main/asterisk.exports
    team/rmudgett/misdn_facility/main/features.c
    team/rmudgett/misdn_facility/main/loader.c
    team/rmudgett/misdn_facility/res/res_odbc.exports

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
--- automerge-email (original)
+++ automerge-email Thu Mar 19 14:52:06 2009
@@ -1,1 +1,1 @@
-rmudgett at digium.com
+mmichelson at digium.com, rmudgett at digium.com

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
--- misdn-facility (original)
+++ misdn-facility Thu Mar 19 14:52:06 2009
@@ -1,1 +1,1 @@
-/team/group/issue8824:1-183229
+/team/group/issue8824:1-183386

Propchange: team/rmudgett/misdn_facility/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Mar 19 14:52:06 2009
@@ -1,1 +1,1 @@
-/trunk:1-183151
+/trunk:1-183342

Modified: team/rmudgett/misdn_facility/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/apps/app_dial.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/apps/app_dial.c (original)
+++ team/rmudgett/misdn_facility/apps/app_dial.c Thu Mar 19 14:52:06 2009
@@ -568,6 +568,7 @@
 	struct ast_party_connected_line connected;
 };
 
+static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode);
 
 static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, int answered_elsewhere)
 {
@@ -820,7 +821,7 @@
 	struct chanlist *epollo;
 #endif
 	struct ast_party_connected_line connected_caller;
-
+	struct ast_str *featurecode = ast_str_alloca(FEATURE_MAX_LEN + 1);
 	if (single) {
 		/* Turn off hold music, etc */
 		if (!ast_test_flag64(outgoing, OPT_MUSICBACK | OPT_RINGBACK))
@@ -1118,8 +1119,8 @@
 				}
 
 				if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
-						(f->subclass == '*')) { /* hmm it it not guaranteed to be '*' anymore. */
-					ast_verb(3, "User hit %c to disconnect call.\n", f->subclass);
+					detect_disconnect(in, f->subclass, featurecode)) {
+					ast_verb(3, "User requested call disconnect.\n");
 					*to = 0;
 					strcpy(pa->status, "CANCEL");
 					ast_cdr_noanswer(in->cdr);
@@ -1163,6 +1164,26 @@
 #endif
 
 	return peer;
+}
+
+static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode)
+{
+	struct ast_flags features = { AST_FEATURE_DISCONNECT }; /* only concerned with disconnect feature */
+	struct ast_call_feature feature;
+	int res;
+
+	ast_str_append(&featurecode, 1, "%c", code);
+
+	res = ast_feature_detect(chan, &features, ast_str_buffer(featurecode), &feature);
+
+	if (res != AST_FEATURE_RETURN_STOREDIGITS) {
+		ast_str_reset(featurecode);
+	}
+	if (feature.feature_mask & AST_FEATURE_DISCONNECT) {
+		return 1;
+	}
+
+	return 0;
 }
 
 static void replace_macro_delimiter(char *s)
@@ -1659,7 +1680,7 @@
 		res = -1; /* reset default */
 	}
 
-	if (ast_test_flag64(&opts, OPT_DTMF_EXIT)) {
+	if (ast_test_flag64(&opts, OPT_DTMF_EXIT) || ast_test_flag64(&opts, OPT_CALLER_HANGUP)) {
 		__ast_answer(chan, 0, 0);
 	}
 

Modified: team/rmudgett/misdn_facility/apps/app_queue.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/apps/app_queue.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/apps/app_queue.c (original)
+++ team/rmudgett/misdn_facility/apps/app_queue.c Thu Mar 19 14:52:06 2009
@@ -3656,19 +3656,6 @@
 			break;
 		}
 
-	if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) {
-		queue_end_bridge->q = qe->parent;
-		queue_end_bridge->chan = qe->chan;
-		bridge_config.end_bridge_callback = end_bridge_callback;
-		bridge_config.end_bridge_callback_data = queue_end_bridge;
-		bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
-		/* Since queue_end_bridge can survive beyond the life of this call to Queue, we need
-		 * to make sure to increase the refcount of this queue so it cannot be freed until we
-		 * are done with it. We remove this reference in end_bridge_callback.
-		 */
-		queue_ref(qe->parent);
-	}
-
 	/* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. 
 		(this is mainly to support chan_local)
 	*/
@@ -4232,6 +4219,20 @@
 					qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : "");
 		ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
 		ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
+	
+		if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) {
+			queue_end_bridge->q = qe->parent;
+			queue_end_bridge->chan = qe->chan;
+			bridge_config.end_bridge_callback = end_bridge_callback;
+			bridge_config.end_bridge_callback_data = queue_end_bridge;
+			bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup;
+			/* Since queue_end_bridge can survive beyond the life of this call to Queue, we need
+			 * to make sure to increase the refcount of this queue so it cannot be freed until we
+			 * are done with it. We remove this reference in end_bridge_callback.
+			 */
+			queue_ref(qe->parent);
+		}
+
 		time(&callstart);
 		transfer_ds = setup_transfer_datastore(qe, member, callstart, callcompletedinsl);
 		bridge = ast_bridge_call(qe->chan,peer, &bridge_config);

Modified: team/rmudgett/misdn_facility/channels/chan_dahdi.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/channels/chan_dahdi.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/channels/chan_dahdi.c (original)
+++ team/rmudgett/misdn_facility/channels/chan_dahdi.c Thu Mar 19 14:52:06 2009
@@ -3394,6 +3394,7 @@
 	case SIG_MFCR2:
 		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
 		p->dialdest[0] = '\0';
+		p->dialing = 1;
 		break;
 	default:
 		ast_debug(1, "not yet implemented\n");
@@ -4468,6 +4469,7 @@
 		p->onhooktime = time(NULL);
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
 		p->proceeding = 0;
+		p->dialing = 0;
 		p->progress = 0;
 		p->alerting = 0;
 		p->setup_ack = 0;
@@ -4769,6 +4771,7 @@
 		/* Send a pri acknowledge */
 		if (!pri_grab(p, p->pri)) {
 			p->proceeding = 1;
+			p->dialing = 0;
 			res = pri_answer(p->pri->pri, p->call, 0, !p->digital);
 			pri_rel(p->pri);
 		} else {
@@ -7209,6 +7212,7 @@
 						ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
 				}
 				p->proceeding = 1;
+				p->dialing = 0;
 			}
 #endif
 #ifdef HAVE_SS7
@@ -12991,8 +12995,12 @@
 								ast_dsp_set_features(pri->pvts[chanpos]->dsp, pri->pvts[chanpos]->dsp_features);
 								pri->pvts[chanpos]->dsp_features = 0;
 							}
+							/* Bring voice path up */
+							f.subclass = AST_CONTROL_PROGRESS;
+							dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
 						}
 						pri->pvts[chanpos]->progress = 1;
+						pri->pvts[chanpos]->dialing = 0;
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -13024,6 +13032,7 @@
 							dahdi_queue_frame(pri->pvts[chanpos], &f, pri);
 						}
 						pri->pvts[chanpos]->proceeding = 1;
+						pri->pvts[chanpos]->dialing = 0;
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}

Modified: team/rmudgett/misdn_facility/channels/chan_local.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/channels/chan_local.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/channels/chan_local.c (original)
+++ team/rmudgett/misdn_facility/channels/chan_local.c Thu Mar 19 14:52:06 2009
@@ -536,17 +536,40 @@
 
 	if (!p)
 		return -1;
-	
-	ast_mutex_lock(&p->lock);
+
+	/* If you value your sanity, please don't look at this code */
+start_over:
+	while (ast_channel_trylock(p->chan)) {
+		ast_channel_unlock(p->owner);
+		usleep(1);
+		ast_channel_lock(p->owner);
+	}
+
+	/* p->owner and p->chan are locked now. Let's get p locked */
+	if (ast_mutex_trylock(&p->lock)) {
+		/* @#$&$@ */
+		ast_channel_unlock(p->chan);
+		ast_channel_unlock(p->owner);
+		usleep(1);
+		ast_channel_lock(p->owner);
+		goto start_over;
+	}
 
 	/*
 	 * Note that cid_num and cid_name aren't passed in the ast_channel_alloc
 	 * call, so it's done here instead.
+	 *
+	 * All these failure points just return -1. The individual strings will
+	 * be cleared when we destroy the channel.
 	 */
-	p->chan->cid.cid_rdnis = ast_strdup(p->owner->cid.cid_rdnis);
+	if (!(p->chan->cid.cid_rdnis = ast_strdup(p->owner->cid.cid_rdnis))) {
+		return -1;
+	}
 	ast_party_redirecting_copy(&p->chan->redirecting, &p->owner->redirecting);
 
-	p->chan->cid.cid_dnid = ast_strdup(p->owner->cid.cid_dnid);
+	if (!(p->chan->cid.cid_dnid = ast_strdup(p->owner->cid.cid_dnid))) {
+		return -1;
+	}
 	p->chan->cid.cid_tns = p->owner->cid.cid_tns;
 
 	ast_copy_connected_to_caller(&p->chan->cid, &p->owner->connected);
@@ -587,6 +610,7 @@
 		ast_set_flag(p, LOCAL_LAUNCHED_PBX);
 
 	ast_mutex_unlock(&p->lock);
+	ast_channel_unlock(p->chan);
 	return res;
 }
 

Modified: team/rmudgett/misdn_facility/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/channels/chan_sip.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/channels/chan_sip.c (original)
+++ team/rmudgett/misdn_facility/channels/chan_sip.c Thu Mar 19 14:52:06 2009
@@ -5096,7 +5096,9 @@
 		p->t38.jointcapability = p->t38.capability;
 		ast_debug(2, "Our T38 capability (%d), joint T38 capability (%d)\n", p->t38.capability, p->t38.jointcapability);
 
+		sip_pvt_lock(p);
 		xmitres = transmit_invite(p, SIP_INVITE, 1, 2);
+		sip_pvt_unlock(p);
 		if (xmitres == XMIT_ERROR)
 			return -1;
 		p->invitestate = INV_CALLING;
@@ -19766,7 +19768,7 @@
 			} else if (p->t38.state == T38_DISABLED) {
 				/* If this is not a re-invite or something to ignore - it's critical */
 				ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED);
-				transmit_response_with_sdp(p, "200 OK", req, (reinvite ? XMIT_RELIABLE : (req->ignore ?  XMIT_UNRELIABLE : XMIT_CRITICAL)), p->session_modify == TRUE ? FALSE:TRUE); 
+				transmit_response_with_sdp(p, "200 OK", req, (reinvite ? XMIT_RELIABLE : (req->ignore ?  XMIT_UNRELIABLE : XMIT_CRITICAL)), p->session_modify == TRUE ? FALSE : TRUE, FALSE); 
 			}
 
 			p->invitestate = INV_TERMINATED;

Modified: team/rmudgett/misdn_facility/configure.ac
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/configure.ac?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/configure.ac (original)
+++ team/rmudgett/misdn_facility/configure.ac Thu Mar 19 14:52:06 2009
@@ -608,8 +608,6 @@
 	),
 	AC_MSG_RESULT(no)
 )
-
-AST_C_DEFINE_CHECK([RTLD_NOLOAD], [RTLD_NOLOAD], [dlfcn.h])
 
 AST_C_DEFINE_CHECK([IP_MTU_DISCOVER], [IP_MTU_DISCOVER], [netinet/in.h])
 

Modified: team/rmudgett/misdn_facility/include/asterisk/autoconfig.h.in
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/include/asterisk/autoconfig.h.in?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/include/asterisk/autoconfig.h.in (original)
+++ team/rmudgett/misdn_facility/include/asterisk/autoconfig.h.in Thu Mar 19 14:52:06 2009
@@ -766,12 +766,6 @@
 
 /* Define to indicate the ${ROUND_DESCRIP} library version */
 #undef HAVE_ROUND_VERSION
-
-/* Define if your system has the RTLD_NOLOAD headers. */
-#undef HAVE_RTLD_NOLOAD
-
-/* Define RTLD_NOLOAD headers version */
-#undef HAVE_RTLD_NOLOAD_VERSION
 
 /* Define to 1 if your system has /sbin/launchd. */
 #undef HAVE_SBIN_LAUNCHD

Modified: team/rmudgett/misdn_facility/include/asterisk/features.h
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/include/asterisk/features.h?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/include/asterisk/features.h (original)
+++ team/rmudgett/misdn_facility/include/asterisk/features.h Thu Mar 19 14:52:06 2009
@@ -36,6 +36,21 @@
 
 #define PARK_APP_NAME "Park"
 
+#define AST_FEATURE_RETURN_HANGUP           -1
+#define AST_FEATURE_RETURN_SUCCESSBREAK     0
+#define AST_FEATURE_RETURN_PBX_KEEPALIVE    AST_PBX_KEEPALIVE
+#define AST_FEATURE_RETURN_NO_HANGUP_PEER   AST_PBX_NO_HANGUP_PEER
+#define AST_FEATURE_RETURN_PASSDIGITS       21
+#define AST_FEATURE_RETURN_STOREDIGITS      22
+#define AST_FEATURE_RETURN_SUCCESS          23
+#define AST_FEATURE_RETURN_KEEPTRYING       24
+#define AST_FEATURE_RETURN_PARKFAILED       25
+
+#define FEATURE_SENSE_CHAN	(1 << 0)
+#define FEATURE_SENSE_PEER	(1 << 1)
+
+typedef int (*ast_feature_operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data);
+
 /*! \brief main call feature structure */
 
 enum {
@@ -53,21 +68,13 @@
 	char sname[FEATURE_SNAME_LEN];
 	char exten[FEATURE_MAX_LEN];
 	char default_exten[FEATURE_MAX_LEN];
-	int (*operation)(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense, void *data);
+	ast_feature_operation operation;
 	unsigned int flags;
 	char app[FEATURE_APP_LEN];		
 	char app_args[FEATURE_APP_ARGS_LEN];
 	char moh_class[FEATURE_MOH_LEN];
 	AST_LIST_ENTRY(ast_call_feature) feature_entry;
 };
-
-#define AST_FEATURE_RETURN_HANGUP                   -1
-#define AST_FEATURE_RETURN_SUCCESSBREAK             0
-#define AST_FEATURE_RETURN_PASSDIGITS               21
-#define AST_FEATURE_RETURN_STOREDIGITS              22
-#define AST_FEATURE_RETURN_SUCCESS                  23
-#define AST_FEATURE_RETURN_KEEPTRYING               24
-#define AST_FEATURE_RETURN_PARKFAILED               25
 
 /*!
  * \brief Park a call and read back parked location 
@@ -123,6 +130,10 @@
     \param feature the ast_call_feature object which was registered before*/
 void ast_unregister_feature(struct ast_call_feature *feature);
 
+/*! \brief detect a feature before bridging 
+    \para chan, ast_flags ptr, code, ast_call_feature ptr to be set if found */
+int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, char *code, struct ast_call_feature *feature);
+
 /*! \brief look for a call feature entry by its sname
 	\param name a string ptr, should match "automon", "blindxfer", "atxfer", etc. */
 struct ast_call_feature *ast_find_call_feature(const char *name);

Modified: team/rmudgett/misdn_facility/main/asterisk.exports
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/main/asterisk.exports?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/main/asterisk.exports (original)
+++ team/rmudgett/misdn_facility/main/asterisk.exports Thu Mar 19 14:52:06 2009
@@ -20,6 +20,10 @@
 		sched_*;
 		io_*;
 		jb_*;
+		aes_*;
+		config_*;
+		tdd_*;
+		term_*;
 		channelreloadreason2txt;
 		devstate2str;
 		__manager_event;

Modified: team/rmudgett/misdn_facility/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/main/features.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/main/features.c (original)
+++ team/rmudgett/misdn_facility/main/features.c Thu Mar 19 14:52:06 2009
@@ -889,9 +889,6 @@
 	return masq_park_call(rchan, peer, timeout, extout, 1, NULL);
 }
 
-#define FEATURE_SENSE_CHAN	(1 << 0)
-#define FEATURE_SENSE_PEER	(1 << 1)
-
 /*! 
  * \brief set caller and callee according to the direction 
  * \param caller, callee, peer, chan, sense
@@ -2012,53 +2009,42 @@
 }
 
 /*!
- * \brief Check the dynamic features
- * \param chan,peer,config,code,sense
+ * \brief Helper function for feature_interpret and ast_feature_detect
+ * \param chan,peer,config,code,sense,dynamic_features char buf,feature flags,operation,feature
  *
  * Lock features list, browse for code, unlock list
+ * If a feature is found and the operation variable is set, that feature's
+ * operation is executed.  The first feature found is copied to the feature parameter.
  * \retval res on success.
  * \retval -1 on failure.
 */
-static int feature_interpret(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
+static int feature_interpret_helper(struct ast_channel *chan, struct ast_channel *peer,
+	struct ast_bridge_config *config, char *code, int sense, char *dynamic_features_buf,
+	struct ast_flags *features, int operation, struct ast_call_feature *feature)
 {
 	int x;
-	struct ast_flags features;
-	struct ast_call_feature *feature;
 	struct feature_group *fg = NULL;
 	struct feature_group_exten *fge;
-	const char *peer_dynamic_features, *chan_dynamic_features;
-	char dynamic_features_buf[128];
+	struct ast_call_feature *tmpfeature;
 	char *tmp, *tok;
 	int res = AST_FEATURE_RETURN_PASSDIGITS;
 	int feature_detected = 0;
 
-	if (sense == FEATURE_SENSE_CHAN) {
-		ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);
-	}
-	else {
-		ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
-	}
-
-	ast_channel_lock(peer);
-	peer_dynamic_features = ast_strdupa(S_OR(pbx_builtin_getvar_helper(peer, "DYNAMIC_FEATURES"),""));
-	ast_channel_unlock(peer);
-
-	ast_channel_lock(chan);
-	chan_dynamic_features = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"),""));
-	ast_channel_unlock(chan);
-
-	snprintf(dynamic_features_buf, sizeof(dynamic_features_buf), "%s%s%s", S_OR(chan_dynamic_features, ""), chan_dynamic_features && peer_dynamic_features ? "#" : "", S_OR(peer_dynamic_features,""));
-
-	ast_debug(3, "Feature interpret: chan=%s, peer=%s, code=%s, sense=%d, features=%d, dynamic=%s\n", chan->name, peer->name, code, sense, features.flags, dynamic_features_buf);
+	if (!(peer && chan && config) && operation) {
+		return -1; /* can not run feature operation */
+	}
 
 	ast_rwlock_rdlock(&features_lock);
 	for (x = 0; x < FEATURES_COUNT; x++) {
-		if ((ast_test_flag(&features, builtin_features[x].feature_mask)) &&
+		if ((ast_test_flag(features, builtin_features[x].feature_mask)) &&
 		    !ast_strlen_zero(builtin_features[x].exten)) {
 			/* Feature is up for consideration */
 			if (!strcmp(builtin_features[x].exten, code)) {
 				ast_debug(3, "Feature detected: fname=%s sname=%s exten=%s\n", builtin_features[x].fname, builtin_features[x].sname, builtin_features[x].exten);
-				res = builtin_features[x].operation(chan, peer, config, code, sense, NULL);
+				if (operation) {
+					res = builtin_features[x].operation(chan, peer, config, code, sense, NULL);
+				}
+				memcpy(feature, &builtin_features[x], sizeof(feature));
 				feature_detected = 1;
 				break;
 			} else if (!strncmp(builtin_features[x].exten, code, strlen(code))) {
@@ -2069,8 +2055,9 @@
 	}
 	ast_rwlock_unlock(&features_lock);
 
-	if (ast_strlen_zero(dynamic_features_buf) || feature_detected)
+	if (ast_strlen_zero(dynamic_features_buf) || feature_detected) {
 		return res;
+	}
 
 	tmp = dynamic_features_buf;
 
@@ -2083,8 +2070,10 @@
 			AST_LIST_TRAVERSE(&fg->features, fge, entry) {
 				if (strcasecmp(fge->exten, code))
 					continue;
-
-				res = fge->feature->operation(chan, peer, config, code, sense, fge->feature);
+				if (operation) {
+					res = fge->feature->operation(chan, peer, config, code, sense, fge->feature);
+				}
+				memcpy(feature, fge->feature, sizeof(feature));
 				if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 					AST_RWLIST_UNLOCK(&feature_groups);
 					break;
@@ -2099,33 +2088,83 @@
 
 		AST_RWLIST_RDLOCK(&feature_list);
 
-		if (!(feature = find_dynamic_feature(tok))) {
+		if (!(tmpfeature = find_dynamic_feature(tok))) {
 			AST_RWLIST_UNLOCK(&feature_list);
 			continue;
 		}
-			
+
 		/* Feature is up for consideration */
-		if (!strcmp(feature->exten, code)) {
-			ast_verb(3, " Feature Found: %s exten: %s\n",feature->sname, tok);
-			res = feature->operation(chan, peer, config, code, sense, feature);
+		if (!strcmp(tmpfeature->exten, code)) {
+			ast_verb(3, " Feature Found: %s exten: %s\n",tmpfeature->sname, tok);
+			if (operation) {
+				res = tmpfeature->operation(chan, peer, config, code, sense, tmpfeature);
+			}
+			memcpy(feature, tmpfeature, sizeof(feature));
 			if (res != AST_FEATURE_RETURN_KEEPTRYING) {
 				AST_RWLIST_UNLOCK(&feature_list);
 				break;
 			}
 			res = AST_FEATURE_RETURN_PASSDIGITS;
-		} else if (!strncmp(feature->exten, code, strlen(code)))
+		} else if (!strncmp(tmpfeature->exten, code, strlen(code)))
 			res = AST_FEATURE_RETURN_STOREDIGITS;
 
 		AST_RWLIST_UNLOCK(&feature_list);
 	}
-	
+
 	return res;
 }
 
+/*!
+ * \brief Check the dynamic features
+ * \param chan,peer,config,code,sense
+ *
+ * \retval res on success.
+ * \retval -1 on failure.
+*/
+
+static int feature_interpret(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense) {
+
+	char dynamic_features_buf[128];
+	const char *peer_dynamic_features, *chan_dynamic_features;
+	struct ast_flags features;
+	struct ast_call_feature feature;
+	if (sense == FEATURE_SENSE_CHAN) {
+		ast_copy_flags(&features, &(config->features_caller), AST_FLAGS_ALL);
+	}
+	else {
+		ast_copy_flags(&features, &(config->features_callee), AST_FLAGS_ALL);
+	}
+
+	ast_channel_lock(peer);
+	peer_dynamic_features = ast_strdupa(S_OR(pbx_builtin_getvar_helper(peer, "DYNAMIC_FEATURES"),""));
+	ast_channel_unlock(peer);
+
+	ast_channel_lock(chan);
+	chan_dynamic_features = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"),""));
+	ast_channel_unlock(chan);
+
+	snprintf(dynamic_features_buf, sizeof(dynamic_features_buf), "%s%s%s", S_OR(chan_dynamic_features, ""), chan_dynamic_features && peer_dynamic_features ? "#" : "", S_OR(peer_dynamic_features,""));
+
+	ast_debug(3, "Feature interpret: chan=%s, peer=%s, code=%s, sense=%d, features=%d, dynamic=%s\n", chan->name, peer->name, code, sense, features.flags, dynamic_features_buf);
+
+	return feature_interpret_helper(chan, peer, config, code, sense, dynamic_features_buf, &features, 1, &feature);
+}
+
+
+int ast_feature_detect(struct ast_channel *chan, struct ast_flags *features, char *code, struct ast_call_feature *feature) {
+
+	char *dynamic_features;
+	ast_channel_lock(chan);
+	dynamic_features = ast_strdupa(S_OR(pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES"),""));
+	ast_channel_unlock(chan);
+
+	return feature_interpret_helper(chan, NULL, NULL, code, 0, dynamic_features, features, 0, feature);
+}
+
 static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config)
 {
 	int x;
-	
+
 	ast_clear_flag(config, AST_FLAGS_ALL);
 
 	ast_rwlock_rdlock(&features_lock);
@@ -2140,7 +2179,7 @@
 			ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_1);
 	}
 	ast_rwlock_unlock(&features_lock);
-	
+
 	if (chan && peer && !(ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_0) && ast_test_flag(config, AST_BRIDGE_DTMF_CHANNEL_1))) {
 		const char *dynamic_features = pbx_builtin_getvar_helper(chan, "DYNAMIC_FEATURES");
 

Modified: team/rmudgett/misdn_facility/main/loader.c
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/main/loader.c?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/main/loader.c (original)
+++ team/rmudgett/misdn_facility/main/loader.c Thu Mar 19 14:52:06 2009
@@ -403,18 +403,6 @@
 		return NULL;
 	}
 
-	/* if the system supports RTLD_NOLOAD, we can just 'promote' the flags
-	   on the already-opened library to what we want... if not, we have to
-	   close it and start over
-	*/
-#if defined(HAVE_RTLD_NOLOAD) && !defined(__Darwin__)
-	if (!dlopen(fn, RTLD_NOLOAD | (wants_global ? RTLD_LAZY | RTLD_GLOBAL : RTLD_NOW | RTLD_LOCAL))) {
-		ast_log(LOG_WARNING, "Unable to promote flags on module '%s': %s\n", resource_in, dlerror());
-		while (!dlclose(lib));
-		ast_free(resource_being_loaded);
-		return NULL;
-	}
-#else
 	while (!dlclose(lib));
 	resource_being_loaded = NULL;
 
@@ -435,7 +423,6 @@
 	/* since the module was successfully opened, and it registered itself
 	   the previous time we did that, we're going to assume it worked this
 	   time too :) */
-#endif
 
 	AST_LIST_LAST(&module_list)->lib = lib;
 	resource_being_loaded = NULL;

Modified: team/rmudgett/misdn_facility/res/res_odbc.exports
URL: http://svn.digium.com/svn-view/asterisk/team/rmudgett/misdn_facility/res/res_odbc.exports?view=diff&rev=183387&r1=183386&r2=183387
==============================================================================
--- team/rmudgett/misdn_facility/res/res_odbc.exports (original)
+++ team/rmudgett/misdn_facility/res/res_odbc.exports Thu Mar 19 14:52:06 2009
@@ -9,7 +9,9 @@
 		ast_odbc_prepare_and_execute;
 		ast_odbc_release_obj;
 		ast_odbc_request_obj;
+		_ast_odbc_request_obj;
 		ast_odbc_request_obj2;
+		_ast_odbc_request_obj2;
 		ast_odbc_retrieve_transaction_obj;
 		ast_odbc_sanity_check;
 		ast_odbc_smart_execute;




More information about the svn-commits mailing list