[asterisk-commits] seanbright: branch seanbright/resolve-shadow-warnings r115307 - in /team/sean...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon May 5 14:51:57 CDT 2008


Author: seanbright
Date: Mon May  5 14:51:57 2008
New Revision: 115307

URL: http://svn.digium.com/view/asterisk?view=rev&rev=115307
Log:
Merged revisions 115258,115268,115270,115272,115274,115277,115280,115283,115286,115288,115290,115301 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r115258 | bbryant | 2008-05-02 16:26:00 -0400 (Fri, 02 May 2008) | 9 lines

Blocked revisions 115257 via svnmerge

........
r115257 | bbryant | 2008-05-02 15:25:42 -0500 (Fri, 02 May 2008) | 2 lines

Add new "pri show version" command to show the libpri version for support reasons.

........

................
r115268 | dhubbard | 2008-05-02 23:40:32 -0400 (Fri, 02 May 2008) | 11 lines

A taskprocessor is an object that has a name, a task queue, and an event processing thread.  Modules reference a taskprocessor, push tasks into the taskprocessor as needed, and unreference the taskprocessor when the taskprocessor is no longer needed.

A task wraps a callback function pointer and a data pointer and is managed internal to the taskprocessor subsystem.  The callback function is responsible for releasing task data.

Taskprocessor API
 * ast_taskprocessor_get(..) - returns a reference to a taskprocessor
 * ast_taskprocessor_unreference(..) - releases reference to a taskprocessor
 * ast_taskprocessor_push(..) - push a task into a taskprocessor queue

Check doxygen for more details

................
r115270 | dhubbard | 2008-05-02 23:57:42 -0400 (Fri, 02 May 2008) | 1 line

app_queue uses a taskprocessor for device state changes
................
r115272 | dhubbard | 2008-05-03 00:12:54 -0400 (Sat, 03 May 2008) | 1 line

pbx uses a taskprocessor for device state changes
................
r115274 | dhubbard | 2008-05-03 00:23:18 -0400 (Sat, 03 May 2008) | 1 line

app_voicemail uses a taskprocessor for mwi notification subscriptions
................
r115277 | file | 2008-05-03 21:45:21 -0400 (Sat, 03 May 2008) | 10 lines

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

........
r115276 | file | 2008-05-03 22:43:26 -0300 (Sat, 03 May 2008) | 2 lines

Treat warnings as errors when checking if a GCC attribute exists. We have to do this as GCC will just ignore the attribute and pop up a warning, it won't actually fail to compile.

........

................
r115280 | file | 2008-05-03 21:52:00 -0400 (Sat, 03 May 2008) | 10 lines

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

........
r115279 | file | 2008-05-03 22:50:59 -0300 (Sat, 03 May 2008) | 2 lines

For my next trick I will make these work with what our autoconf header file gives us.

........

................
r115283 | file | 2008-05-03 22:11:01 -0400 (Sat, 03 May 2008) | 10 lines

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

........
r115282 | file | 2008-05-03 23:09:44 -0300 (Sat, 03 May 2008) | 2 lines

Expand the test function for GCC attributes so that more complex attributes are properly recognized.

........

................
r115286 | tilghman | 2008-05-04 23:25:35 -0400 (Sun, 04 May 2008) | 15 lines

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

........
r115285 | tilghman | 2008-05-04 22:22:25 -0500 (Sun, 04 May 2008) | 7 lines

When starting Asterisk, bug out if Asterisk is already running.
(closes issue #12525)
 Reported by: explidous
 Patches: 
       20080428__bug12525.diff.txt uploaded by Corydon76 (license 14)
 Tested by: mvanbaak

........

................
r115288 | kpfleming | 2008-05-05 06:55:09 -0400 (Mon, 05 May 2008) | 2 lines

clarify wording

................
r115290 | file | 2008-05-05 09:52:44 -0400 (Mon, 05 May 2008) | 6 lines

Document the 'B' option of app_chanspy.
(closes issue #12582)
Reported by: IgorG
Patches:
      app_chanspy_B_option.diff uploaded by IgorG (license 20)

................
r115301 | tilghman | 2008-05-05 15:33:14 -0400 (Mon, 05 May 2008) | 3 lines

Optionally display the value of several variables within the Status command.
(Closes issue AST-34)

................

Added:
    team/seanbright/resolve-shadow-warnings/include/asterisk/taskprocessor.h
      - copied unchanged from r115301, trunk/include/asterisk/taskprocessor.h
    team/seanbright/resolve-shadow-warnings/main/taskprocessor.c
      - copied, changed from r115301, trunk/main/taskprocessor.c
Modified:
    team/seanbright/resolve-shadow-warnings/   (props changed)
    team/seanbright/resolve-shadow-warnings/CHANGES
    team/seanbright/resolve-shadow-warnings/UPGRADE.txt
    team/seanbright/resolve-shadow-warnings/acinclude.m4
    team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c
    team/seanbright/resolve-shadow-warnings/apps/app_queue.c
    team/seanbright/resolve-shadow-warnings/apps/app_voicemail.c
    team/seanbright/resolve-shadow-warnings/configure
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.debian.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.gentoo.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.mandrake.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.redhat.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.slackware.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.suse.asterisk
    team/seanbright/resolve-shadow-warnings/contrib/scripts/safe_asterisk
    team/seanbright/resolve-shadow-warnings/include/asterisk/_private.h
    team/seanbright/resolve-shadow-warnings/include/asterisk/compiler.h
    team/seanbright/resolve-shadow-warnings/main/Makefile
    team/seanbright/resolve-shadow-warnings/main/asterisk.c
    team/seanbright/resolve-shadow-warnings/main/manager.c
    team/seanbright/resolve-shadow-warnings/main/pbx.c

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
Binary property 'branch-1.4-blocked' - no diff available.

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/seanbright/resolve-shadow-warnings/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon May  5 14:51:57 2008
@@ -1,1 +1,1 @@
-/trunk:1-115246
+/trunk:1-115301

Modified: team/seanbright/resolve-shadow-warnings/CHANGES
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/CHANGES?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/CHANGES (original)
+++ team/seanbright/resolve-shadow-warnings/CHANGES Mon May  5 14:51:57 2008
@@ -96,6 +96,11 @@
 Dialplan function changes
 -------------------------
  * TIMEOUT() has been modified to be accurate down to the millisecond.
+
+AMI - The manager (TCP/TLS/HTTP)
+--------------------------------
+  * The Status command now takes an optional list of variables to display
+    along with channel status.
 
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 1.4.X to Asterisk 1.6.0  -------------

Modified: team/seanbright/resolve-shadow-warnings/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/UPGRADE.txt?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/UPGRADE.txt (original)
+++ team/seanbright/resolve-shadow-warnings/UPGRADE.txt Mon May  5 14:51:57 2008
@@ -94,8 +94,8 @@
   these functions in any location where you desire to ensure that only one
   channel is executing that path at any one time.  The Macro() applications
   are deprecated for performance reasons.  However, since Macro() has been
-  around for a long time and so many dialplans depend heavily on it, it will
-  not be removed for the sake of backwards compatibility.  It is also worth
+  around for a long time and so many dialplans depend heavily on it, for the
+  sake of backwards compatibility it will not be removed .  It is also worth
   noting that using both Macro() and GoSub() at the same time is _heavily_
   discouraged.
 * Read() now sets a READSTATUS variable on exit.  It does NOT automatically

Modified: team/seanbright/resolve-shadow-warnings/acinclude.m4
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/acinclude.m4?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/acinclude.m4 (original)
+++ team/seanbright/resolve-shadow-warnings/acinclude.m4 Mon May  5 14:51:57 2008
@@ -7,13 +7,17 @@
 AC_DEFUN([AST_GCC_ATTRIBUTE],
 [
 AC_MSG_CHECKING(for compiler 'attribute $1' support)
+saved_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -Werror"
 AC_COMPILE_IFELSE(
-	AC_LANG_PROGRAM([static int __attribute__(($1)) test(void) {}],
+	AC_LANG_PROGRAM([static void __attribute__(($1)) *test(void *muffin, ...) {}],
 			[]),
 	AC_MSG_RESULT(yes)
 	AC_DEFINE_UNQUOTED([HAVE_ATTRIBUTE_$1], 1, [Define to 1 if your GCC C compiler supports the '$1' attribute.]),
 	AC_MSG_RESULT(no))
-])
+]
+CFLAGS="$saved_CFLAGS"
+)
 
 # Helper function to setup variables for a package.
 # $1 -> the package name. Used in configure.ac and also as a prefix

Modified: team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c (original)
+++ team/seanbright/resolve-shadow-warnings/apps/app_chanspy.c Mon May  5 14:51:57 2008
@@ -71,6 +71,8 @@
 "        and a digit sequence.\n"
 "  Options:\n"
 "    b                      - Only spy on channels involved in a bridged call.\n"
+"    B                      - Instead of whispering on a single channel barge in on both\n"
+"                             channels involved in the call.\n"
 "    g(grp)                 - Only spy on channels in which one or more of the groups \n"
 "                             listed in 'grp' matches one or more groups from the\n"
 "                             SPYGROUP variable set on the channel to be spied upon.\n"

Modified: team/seanbright/resolve-shadow-warnings/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/apps/app_queue.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/apps/app_queue.c (original)
+++ team/seanbright/resolve-shadow-warnings/apps/app_queue.c Mon May  5 14:51:57 2008
@@ -92,6 +92,7 @@
 #include "asterisk/astobj2.h"
 #include "asterisk/strings.h"
 #include "asterisk/global_datastores.h"
+#include "asterisk/taskprocessor.h"
 
 /*!
  * \par Please read before modifying this file.
@@ -130,6 +131,8 @@
 	{ QUEUE_STRATEGY_LINEAR, "linear" },
 	{ QUEUE_STRATEGY_WRANDOM, "wrandom"},
 };
+
+static struct ast_taskprocessor *devicestate_tps;
 
 #define DEFAULT_RETRY		5
 #define DEFAULT_TIMEOUT		15
@@ -739,18 +742,20 @@
 }
 
 /*! \brief set a member's status based on device state of that member's interface*/
-static void *handle_statechange(struct statechange *sc)
+static int handle_statechange(void *datap)
 {
 	struct member_interface *curint;
 	char *loc;
 	char *technology;
+	struct statechange *sc = datap;
 
 	technology = ast_strdupa(sc->dev);
 	loc = strchr(technology, '/');
 	if (loc) {
 		*loc++ = '\0';
 	} else {
-		return NULL;
+		ast_free(sc);
+		return 0;
 	}
 
 	AST_LIST_LOCK(&interfaces);
@@ -770,84 +775,14 @@
 	if (!curint) {
 		if (option_debug > 2)
 			ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
-		return NULL;
+		return 0;
 	}
 
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
 
 	update_status(sc->dev, sc->state);
-
-	return NULL;
-}
-
-/*! \brief Data used by the device state thread */
-static struct {
-	/*! Set to 1 to stop the thread */
-	unsigned int stop:1;
-	/*! The device state monitoring thread */
-	pthread_t thread;
-	/*! Lock for the state change queue */
-	ast_mutex_t lock;
-	/*! Condition for the state change queue */
-	ast_cond_t cond;
-	/*! Queue of state changes */
-	AST_LIST_HEAD_NOLOCK(, statechange) state_change_q;
-} device_state = {
-	.thread = AST_PTHREADT_NULL,
-};
-
-/*! \brief Consumer of the statechange queue */
-static void *device_state_thread(void *data)
-{
-	struct statechange *sc = NULL;
-
-	while (!device_state.stop) {
-		ast_mutex_lock(&device_state.lock);
-		if (!(sc = AST_LIST_REMOVE_HEAD(&device_state.state_change_q, entry))) {
-			ast_cond_wait(&device_state.cond, &device_state.lock);
-			sc = AST_LIST_REMOVE_HEAD(&device_state.state_change_q, entry);
-		}
-		ast_mutex_unlock(&device_state.lock);
-
-		/* Check to see if we were woken up to see the request to stop */
-		if (device_state.stop)
-			break;
-
-		if (!sc)
-			continue;
-
-		handle_statechange(sc);
-
-		ast_free(sc);
-		sc = NULL;
-	}
-
-	if (sc)
-		ast_free(sc);
-
-	while ((sc = AST_LIST_REMOVE_HEAD(&device_state.state_change_q, entry)))
-		ast_free(sc);
-
-	return NULL;
-}
-
-/*! \brief Producer of the statechange queue */
-static int statechange_queue(const char *dev, enum ast_device_state state)
-{
-	struct statechange *sc;
-
-	if (!(sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1)))
-		return 0;
-
-	sc->state = state;
-	strcpy(sc->dev, dev);
-
-	ast_mutex_lock(&device_state.lock);
-	AST_LIST_INSERT_TAIL(&device_state.state_change_q, sc, entry);
-	ast_cond_signal(&device_state.cond);
-	ast_mutex_unlock(&device_state.lock);
-
+	ast_free(sc);
 	return 0;
 }
 
@@ -855,6 +790,8 @@
 {
 	enum ast_device_state state;
 	const char *device;
+	struct statechange *sc;
+	size_t datapsize;
 
 	state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE);
 	device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE);
@@ -863,8 +800,16 @@
 		ast_log(LOG_ERROR, "Received invalid event that had no device IE\n");
 		return;
 	}
-
-	statechange_queue(device, state);
+	datapsize = sizeof(*sc) + strlen(device) + 1;
+	if (!(sc = ast_calloc(1, datapsize))) {
+		ast_log(LOG_ERROR, "failed to calloc a state change struct\n");
+		return;
+	}
+	sc->state = state;
+	strcpy(sc->dev, device);
+	if (ast_taskprocessor_push(devicestate_tps, handle_statechange, sc) < 0) {
+		ast_free(sc);
+	}
 }
 
 /*! \brief allocate space for new queue member and set fields based on parameters passed */
@@ -6249,14 +6194,6 @@
 	struct ao2_iterator q_iter;
 	struct call_queue *q = NULL;
 
-	if (device_state.thread != AST_PTHREADT_NULL) {
-		device_state.stop = 1;
-		ast_mutex_lock(&device_state.lock);
-		ast_cond_signal(&device_state.cond);
-		ast_mutex_unlock(&device_state.lock);
-		pthread_join(device_state.thread, NULL);
-	}
-
 	ast_cli_unregister_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
 	res = ast_manager_unregister("QueueStatus");
 	res |= ast_manager_unregister("Queues");
@@ -6296,7 +6233,7 @@
 		queue_unref(q);
 	}
 	ao2_ref(queues, -1);
-
+	devicestate_tps = ast_taskprocessor_unreference(devicestate_tps);
 	return res;
 }
 
@@ -6318,10 +6255,6 @@
 
 	if (queue_persistent_members)
 		reload_queue_members();
-
-	ast_mutex_init(&device_state.lock);
-	ast_cond_init(&device_state.cond, NULL);
-	ast_pthread_create(&device_state.thread, NULL, device_state_thread, NULL);
 
 	ast_cli_register_multiple(cli_queue, sizeof(cli_queue) / sizeof(struct ast_cli_entry));
 	res = ast_register_application(app, queue_exec, synopsis, descrip);
@@ -6345,6 +6278,11 @@
 	res |= ast_custom_function_register(&queuememberlist_function);
 	res |= ast_custom_function_register(&queuewaitingcount_function);
 	res |= ast_custom_function_register(&queuememberpenalty_function);
+
+	if (!(devicestate_tps = ast_taskprocessor_get("app_queue", 0))) {
+		ast_log(LOG_WARNING, "devicestate taskprocessor reference failed - devicestate notifications will not occur\n");
+	}
+
 	if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, AST_EVENT_IE_END)))
 		res = -1;
 

Modified: team/seanbright/resolve-shadow-warnings/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/apps/app_voicemail.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/apps/app_voicemail.c (original)
+++ team/seanbright/resolve-shadow-warnings/apps/app_voicemail.c Mon May  5 14:51:57 2008
@@ -114,6 +114,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/smdi.h"
 #include "asterisk/event.h"
+#include "asterisk/taskprocessor.h"
 
 #ifdef ODBC_STORAGE
 #include "asterisk/res_odbc.h"
@@ -620,6 +621,14 @@
 	uint32_t uniqueid;
 	char mailbox[1];
 };
+
+struct mwi_sub_task {
+	const char *mailbox;
+	const char *context;
+	uint32_t uniqueid;
+};
+
+static struct ast_taskprocessor *mwi_subscription_tps;
 
 static AST_RWLIST_HEAD_STATIC(mwi_subs, mwi_sub);
 
@@ -8715,22 +8724,14 @@
 	ast_free(mwi_sub);
 }
 
-static void mwi_unsub_event_cb(const struct ast_event *event, void *userdata)
-{
-	uint32_t uniqueid;
+static int handle_unsubscribe(void *datap)
+{
 	struct mwi_sub *mwi_sub;
-
-	if (ast_event_get_type(event) != AST_EVENT_UNSUB)
-		return;
-
-	if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
-		return;
-
-	uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
-
+	uint32_t *uniqueid = datap;
+	
 	AST_RWLIST_WRLOCK(&mwi_subs);
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&mwi_subs, mwi_sub, entry) {
-		if (mwi_sub->uniqueid == uniqueid) {
+		if (mwi_sub->uniqueid == *uniqueid) {
 			AST_LIST_REMOVE_CURRENT(entry);
 			break;
 		}
@@ -8740,48 +8741,80 @@
 
 	if (mwi_sub)
 		mwi_sub_destroy(mwi_sub);
-}
-
-static void mwi_sub_event_cb(const struct ast_event *event, void *userdata)
-{
-	const char *mailbox;
-	const char *context;
-	uint32_t uniqueid;
+
+	ast_free(uniqueid);	
+	return 0;
+}
+
+static int handle_subscribe(void *datap)
+{
 	unsigned int len;
 	struct mwi_sub *mwi_sub;
-
-	if (ast_event_get_type(event) != AST_EVENT_SUB)
-		return;
-
-	if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
-		return;
-
-	mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
-	context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);
-	uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
+	struct mwi_sub_task *p = datap;
 
 	len = sizeof(*mwi_sub);
-	if (!ast_strlen_zero(mailbox))
-		len += strlen(mailbox);
-
-	if (!ast_strlen_zero(context))
-		len += strlen(context) + 1; /* Allow for seperator */
+	if (!ast_strlen_zero(p->mailbox))
+		len += strlen(p->mailbox);
+
+	if (!ast_strlen_zero(p->context))
+		len += strlen(p->context) + 1; /* Allow for seperator */
 
 	if (!(mwi_sub = ast_calloc(1, len)))
-		return;
-
-	mwi_sub->uniqueid = uniqueid;
-	if (!ast_strlen_zero(mailbox))
-		strcpy(mwi_sub->mailbox, mailbox);
-
-	if (!ast_strlen_zero(context)) {
+		return -1;
+
+	mwi_sub->uniqueid = p->uniqueid;
+	if (!ast_strlen_zero(p->mailbox))
+		strcpy(mwi_sub->mailbox, p->mailbox);
+
+	if (!ast_strlen_zero(p->context)) {
 		strcat(mwi_sub->mailbox, "@");
-		strcat(mwi_sub->mailbox, context);
+		strcat(mwi_sub->mailbox, p->context);
 	}
 
 	AST_RWLIST_WRLOCK(&mwi_subs);
 	AST_RWLIST_INSERT_TAIL(&mwi_subs, mwi_sub, entry);
 	AST_RWLIST_UNLOCK(&mwi_subs);
+	ast_free(p);	
+	return 0;
+}
+
+static void mwi_unsub_event_cb(const struct ast_event *event, void *userdata)
+{
+	uint32_t u, *uniqueid = ast_calloc(1, sizeof(*uniqueid));
+	if (ast_event_get_type(event) != AST_EVENT_UNSUB)
+		return;
+
+	if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
+		return;
+
+	u = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
+	*uniqueid = u;
+	if (ast_taskprocessor_push(mwi_subscription_tps, handle_unsubscribe, uniqueid) < 0) {
+		ast_free(uniqueid);
+	}
+}
+
+static void mwi_sub_event_cb(const struct ast_event *event, void *userdata)
+{
+	struct mwi_sub_task *mwist;
+	
+	if (ast_event_get_type(event) != AST_EVENT_SUB)
+		return;
+
+	if (ast_event_get_ie_uint(event, AST_EVENT_IE_EVENTTYPE) != AST_EVENT_MWI)
+		return;
+
+	if ((mwist = ast_calloc(1, (sizeof(*mwist)))) == NULL) {
+		ast_log(LOG_ERROR, "could not allocate a mwi_sub_task\n");
+		return;
+	}
+	mwist->mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
+	mwist->context = ast_event_get_ie_str(event, AST_EVENT_IE_CONTEXT);
+	mwist->uniqueid = ast_event_get_ie_uint(event, AST_EVENT_IE_UNIQUEID);
+	
+	if (ast_taskprocessor_push(mwi_subscription_tps, handle_subscribe, mwist) < 0) {
+		ast_free(mwist);
+	}
 }
 
 static void start_poll_thread(void)
@@ -9604,6 +9637,7 @@
 	if (poll_thread != AST_PTHREADT_NULL)
 		stop_poll_thread();
 
+	mwi_subscription_tps = ast_taskprocessor_unreference(mwi_subscription_tps);
 	return res;
 }
 
@@ -9615,6 +9649,10 @@
 
 	/* compute the location of the voicemail spool directory */
 	snprintf(VM_SPOOL_DIR, sizeof(VM_SPOOL_DIR), "%s/voicemail/", ast_config_AST_SPOOL_DIR);
+	
+	if (!(mwi_subscription_tps = ast_taskprocessor_get("app_voicemail", 0))) {
+		ast_log(LOG_WARNING, "failed to reference mwi subscription taskprocessor.  MWI will not work\n");
+	}
 
 	if ((res = load_config(0)))
 		return res;

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.debian.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.debian.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.debian.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.debian.asterisk Mon May  5 14:51:57 2008
@@ -51,6 +51,14 @@
 
 case "$1" in
   start)
+	# Check if Asterisk is already running.  If it is, then bug out, because
+	# starting up Asterisk when Asterisk is already running is very bad.
+	VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+	if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+		echo "Asterisk is already running.  $0 will exit now."
+		exit 1
+	fi
+
 	log_begin_msg "Starting $DESC: $NAME"
         if [ $AST_USER ] ; then
                 ASTARGS="-U $AST_USER"

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.gentoo.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.gentoo.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.gentoo.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.gentoo.asterisk Mon May  5 14:51:57 2008
@@ -6,6 +6,14 @@
 }
 
 start() {
+	# Check if Asterisk is already running.  If it is, then bug out, because
+	# starting safe_asterisk when Asterisk is running is very bad.
+	VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+	if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+		echo "Asterisk is already running.  $0 will exit now."
+		exit 1
+	fi
+
 	ebegin "Starting Asterisk"
 	/usr/sbin/asterisk
 	eend $? "Failed to start Asterisk"

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.mandrake.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.mandrake.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.mandrake.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.mandrake.asterisk Mon May  5 14:51:57 2008
@@ -119,6 +119,14 @@
 
 case "$1" in
 	start)
+		# Check if Asterisk is already running.  If it is, then bug out, because
+		# starting Asterisk when Asterisk is already running is very bad.
+		VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+		if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+			echo "Asterisk is already running.  $0 will exit now."
+			exit 1
+		fi
+
 		gprintf "Starting asterisk: "
 		run_asterisk >/dev/null 2>&1 &
 		sleep 2	# Give it time to die

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.redhat.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.redhat.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.redhat.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.redhat.asterisk Mon May  5 14:51:57 2008
@@ -68,6 +68,14 @@
 RETVAL=0
 
 start() {
+	# Check if Asterisk is already running.  If it is, then bug out, because
+	# starting safe_asterisk when Asterisk is running is very bad.
+	VERSION=`${AST_SBIN}/asterisk -rx 'core show version'`
+	if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+		echo "Asterisk is already running."
+		exit 1
+	fi
+
 	# Start daemons.
 	echo -n $"Starting asterisk: "
         if [ -f $SAFE_ASTERISK ] ; then

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.slackware.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.slackware.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.slackware.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.slackware.asterisk Mon May  5 14:51:57 2008
@@ -10,6 +10,14 @@
 
 asterisk_start() {
    if [ -x /usr/sbin/asterisk ]; then
+      # Check if Asterisk is already running.  If it is, then bug out, because
+      # starting safe_asterisk when Asterisk is running is very bad.
+      VERSION=`/usr/sbin/asterisk -rx 'core show version'`
+      if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+         echo "Asterisk is already running.  $0 will exit now."
+         exit 1
+      fi
+
       echo "Starting Asterisk   /usr/sbin/asterisk"
       /usr/sbin/asterisk
    fi

Modified: team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.suse.asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.suse.asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.suse.asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/init.d/rc.suse.asterisk Mon May  5 14:51:57 2008
@@ -63,6 +63,15 @@
 
 start() {
 	# Start daemons.
+
+	# Check if Asterisk is already running.  If it is, then bug out, because
+	# starting Asterisk when Asterisk is already running is very bad.
+	VERSION=`/usr/sbin/asterisk -rx 'core show version'`
+	if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+		echo "Asterisk is already running.  $0 will exit now."
+		exit 1
+	fi
+
 	echo -n $"Starting asterisk: "
         if [ -f $SAFE_ASTERISK ] ; then
 		DAEMON=$SAFE_ASTERISK

Modified: team/seanbright/resolve-shadow-warnings/contrib/scripts/safe_asterisk
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/contrib/scripts/safe_asterisk?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/contrib/scripts/safe_asterisk (original)
+++ team/seanbright/resolve-shadow-warnings/contrib/scripts/safe_asterisk Mon May  5 14:51:57 2008
@@ -37,6 +37,14 @@
 	    echo "safe_asterisk[$$]: $1" >> "$LOGFILE"
 	fi
 }
+
+# Check if Asterisk is already running.  If it is, then bug out, because
+# starting safe_asterisk when Asterisk is running is very bad.
+VERSION=`${ASTSBINDIR}/asterisk -rx 'core show version'`
+if [ "${VERSION:0:8}" = "Asterisk" ]; then # otherwise "Unable t"
+	message "Asterisk is already running.  $0 will exit now."
+	exit 1
+fi
 
 # since we're going to change priority and open files limits, we need to be
 # root. if running asterisk as other users, pass that to asterisk on the command

Modified: team/seanbright/resolve-shadow-warnings/include/asterisk/_private.h
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/include/asterisk/_private.h?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/include/asterisk/_private.h (original)
+++ team/seanbright/resolve-shadow-warnings/include/asterisk/_private.h Mon May  5 14:51:57 2008
@@ -36,6 +36,7 @@
 void ast_autoservice_init(void);	/*!< Provided by autoservice.c */
 int ast_http_init(void);		/*!< Provided by http.c */
 int ast_http_reload(void);		/*!< Provided by http.c */
+int ast_tps_init(void); 		/*!< Provided by taskprocessor.c */
 
 /*!
  * \brief Reload asterisk modules.

Modified: team/seanbright/resolve-shadow-warnings/include/asterisk/compiler.h
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/include/asterisk/compiler.h?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/include/asterisk/compiler.h (original)
+++ team/seanbright/resolve-shadow-warnings/include/asterisk/compiler.h Mon May  5 14:51:57 2008
@@ -23,37 +23,37 @@
 #ifndef _ASTERISK_COMPILER_H
 #define _ASTERISK_COMPILER_H
 
-#if HAVE_ATTRIBUTE_always_inline
+#ifdef HAVE_ATTRIBUTE_always_inline
 #define force_inline __attribute__((always_inline)) inline
 #else
 #define force_inline inline
 #endif
 
-#if HAVE_ATTRIBUTE_pure
+#ifdef HAVE_ATTRIBUTE_pure
 #define attribute_pure __attribute__((pure))
 #else
 #define attribute_pure
 #endif
 
-#if HAVE_ATTRIBUTE_const
+#ifdef HAVE_ATTRIBUTE_const
 #define attribute_const __attribute__((const))
 #else
 #define attribute_const
 #endif
 
-#if HAVE_ATTRIBUTE_unused
+#ifdef HAVE_ATTRIBUTE_unused
 #define attribute_unused __attribute__((unused))
 #else
 #define attribute_unused
 #endif
 
-#if HAVE_ATTRIBUTE_malloc
+#ifdef HAVE_ATTRIBUTE_malloc
 #define attribute_malloc __attribute__((malloc))
 #else
 #define attribute_malloc
 #endif
 
-#if HAVE_ATTRIBUTE_sentinel
+#ifdef HAVE_ATTRIBUTE_sentinel
 #define attribute_sentinel __attribute__((sentinel))
 #else
 #define attribute_sentinel

Modified: team/seanbright/resolve-shadow-warnings/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/Makefile?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/Makefile (original)
+++ team/seanbright/resolve-shadow-warnings/main/Makefile Mon May  5 14:51:57 2008
@@ -30,7 +30,7 @@
 	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
 	strcompat.o threadstorage.o dial.o event.o adsistub.o audiohook.o \
 	astobj2.o hashtab.o global_datastores.o $(RESAMPLE_OBJS) version.o \
-	features.o
+	features.o taskprocessor.o
 
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static

Modified: team/seanbright/resolve-shadow-warnings/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/asterisk.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/asterisk.c (original)
+++ team/seanbright/resolve-shadow-warnings/main/asterisk.c Mon May  5 14:51:57 2008
@@ -2815,6 +2815,7 @@
 	ast_builtins_init();
 	ast_utils_init();
 	tdd_init();
+	ast_tps_init();
 
 	if (getenv("HOME")) 
 		snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));

Modified: team/seanbright/resolve-shadow-warnings/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/manager.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/manager.c (original)
+++ team/seanbright/resolve-shadow-warnings/main/manager.c Mon May  5 14:51:57 2008
@@ -1731,12 +1731,23 @@
 	return 0;
 }
 
+static char mandescr_status[] = 
+"Description: Lists channel status along with requested channel vars.\n"
+"Variables: (Names marked with * are required)\n"
+"	*Channel: Name of the channel to query for status\n"
+"	Variables: Comma ',' separated list of variables to include\n"
+"	ActionID: Optional ID for this transaction\n"
+"Will return the status information of each channel along with the\n"
+"value for the specified channel variables.\n";
+ 
 
 /*! \brief Manager "status" command to show channels */
 /* Needs documentation... */
 static int action_status(struct mansession *s, const struct message *m)
 {
 	const char *name = astman_get_header(m, "Channel");
+	const char *cvariables = astman_get_header(m, "Variables");
+	char *variables = ast_strdupa(S_OR(cvariables, ""));
 	struct ast_channel *c;
 	char bridge[256];
 	struct timeval now = ast_tvnow();
@@ -1745,6 +1756,10 @@
 	int all = ast_strlen_zero(name); /* set if we want all channels */
 	const char *id = astman_get_header(m, "ActionID");
 	char idText[256];
+	AST_DECLARE_APP_ARGS(vars,
+		AST_APP_ARG(name)[100];
+	);
+	struct ast_str *str = ast_str_create(1000);
 
 	if (!ast_strlen_zero(id))
 		snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
@@ -1762,8 +1777,31 @@
 	}
 	astman_send_ack(s, m, "Channel status will follow");
 
+	if (!ast_strlen_zero(cvariables)) {
+		AST_STANDARD_APP_ARGS(vars, variables);
+	}
+
 	/* if we look by name, we break after the first iteration */
 	while (c) {
+		if (!ast_strlen_zero(cvariables)) {
+			int i;
+			ast_str_reset(str);
+			for (i = 0; i < vars.argc; i++) {
+				char valbuf[512], *ret = NULL;
+
+				if (vars.name[i][strlen(vars.name[i]) - 1] == ')') {
+					if (ast_func_read(c, vars.name[i], valbuf, sizeof(valbuf)) < 0) {
+						valbuf[0] = '\0';
+					}
+					ret = valbuf;
+				} else {
+					pbx_retrieve_variable(c, vars.name[i], &ret, valbuf, sizeof(valbuf), NULL);
+				}
+
+				ast_str_append(&str, 0, "Variable: %s=%s\r\n", vars.name[i], ret);
+			}
+		}
+
 		channels++;
 		if (c->_bridge)
 			snprintf(bridge, sizeof(bridge), "BridgedChannel: %s\r\nBridgedUniqueid: %s\r\n", c->_bridge->name, c->_bridge->uniqueid);
@@ -1789,6 +1827,7 @@
 			"%s"
 			"Uniqueid: %s\r\n"
 			"%s"
+			"%s"
 			"\r\n",
 			c->name,
 			S_OR(c->cid.cid_num, ""),
@@ -1796,7 +1835,7 @@
 			c->accountcode,
 			c->_state,
 			ast_state2str(c->_state), c->context,
-			c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, idText);
+			c->exten, c->priority, (long)elapsed_seconds, bridge, c->uniqueid, str->str, idText);
 		} else {
 			astman_append(s,
 			"Event: Status\r\n"
@@ -1809,12 +1848,13 @@
 			"%s"
 			"Uniqueid: %s\r\n"
 			"%s"
+			"%s"
 			"\r\n",
 			c->name,
 			S_OR(c->cid.cid_num, "<unknown>"),
 			S_OR(c->cid.cid_name, "<unknown>"),
 			c->accountcode,
-			ast_state2str(c->_state), bridge, c->uniqueid, idText);
+			ast_state2str(c->_state), bridge, c->uniqueid, str->str, idText);
 		}
 		ast_channel_unlock(c);
 		if (!all)
@@ -1826,6 +1866,7 @@
 	"%s"
 	"Items: %d\r\n"
 	"\r\n", idText, channels);
+	ast_free(str);
 	return 0;
 }
 
@@ -3756,9 +3797,9 @@
 		ast_manager_register2("Login", 0, action_login, "Login Manager", NULL);
 		ast_manager_register2("Challenge", 0, action_challenge, "Generate Challenge for MD5 Auth", NULL);
 		ast_manager_register2("Hangup", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL, action_hangup, "Hangup Channel", mandescr_hangup);
-		ast_manager_register("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status, "Lists channel status" );
-		ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar );
-		ast_manager_register2("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar, "Gets a Channel Variable", mandescr_getvar );
+		ast_manager_register2("Status", EVENT_FLAG_SYSTEM | EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_status, "Lists channel status", mandescr_status);
+		ast_manager_register2("Setvar", EVENT_FLAG_CALL, action_setvar, "Set Channel Variable", mandescr_setvar);
+		ast_manager_register2("Getvar", EVENT_FLAG_CALL | EVENT_FLAG_REPORTING, action_getvar, "Gets a Channel Variable", mandescr_getvar);
 		ast_manager_register2("GetConfig", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfig, "Retrieve configuration", mandescr_getconfig);
 		ast_manager_register2("GetConfigJSON", EVENT_FLAG_SYSTEM | EVENT_FLAG_CONFIG, action_getconfigjson, "Retrieve configuration (JSON format)", mandescr_getconfigjson);
 		ast_manager_register2("UpdateConfig", EVENT_FLAG_CONFIG, action_updateconfig, "Update basic configuration", mandescr_updateconfig);

Modified: team/seanbright/resolve-shadow-warnings/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/resolve-shadow-warnings/main/pbx.c?view=diff&rev=115307&r1=115306&r2=115307
==============================================================================
--- team/seanbright/resolve-shadow-warnings/main/pbx.c (original)
+++ team/seanbright/resolve-shadow-warnings/main/pbx.c Mon May  5 14:51:57 2008
@@ -64,6 +64,7 @@
 #include "asterisk/hashtab.h"
 #include "asterisk/module.h"
 #include "asterisk/indications.h"
+#include "asterisk/taskprocessor.h"
 
 /*!
  * \note I M P O R T A N T :
@@ -122,6 +123,8 @@
 
 struct ast_context;
 struct ast_app;
+
+static struct ast_taskprocessor *device_state_tps;
 
 AST_THREADSTORAGE(switch_data);
 
@@ -266,24 +269,6 @@
 struct statechange {
 	AST_LIST_ENTRY(statechange) entry;
 	char dev[0];
-};
-
-/*!
- * \brief Data used by the device state thread
- */
-static struct {
-	/*! Set to 1 to stop the thread */
-	unsigned int stop:1;
-	/*! The device state monitoring thread */
-	pthread_t thread;
-	/*! Lock for the state change queue */
-	ast_mutex_t lock;
-	/*! Condition for the state change queue */
-	ast_cond_t cond;
-	/*! Queue of state changes */
-	AST_LIST_HEAD_NOLOCK(, statechange) state_change_q;
-} device_state = {
-	.thread = AST_PTHREADT_NULL,
 };
 
 struct pbx_exception {
@@ -3144,10 +3129,10 @@
 	return ast_extension_state2(e);    		/* Check all devices in the hint */
 }
 
-static void handle_statechange(const char *device)
+static int handle_statechange(void *datap)
 {
 	struct ast_hint *hint;
-
+	struct statechange *sc = datap;
 	AST_RWLIST_RDLOCK(&hints);
 
 	AST_RWLIST_TRAVERSE(&hints, hint, list) {
@@ -3159,7 +3144,7 @@
 
 		ast_copy_string(buf, ast_get_extension_app(hint->exten), sizeof(buf));
 		while ( (cur = strsep(&parse, "&")) ) {
-			if (!strcasecmp(cur, device))
+			if (!strcasecmp(cur, sc->dev))
 				break;
 		}
 		if (!cur)
@@ -3185,49 +3170,9 @@
 
 		hint->laststate = state;	/* record we saw the change */
 	}
-
 	AST_RWLIST_UNLOCK(&hints);
-}
-

[... 118 lines stripped ...]



More information about the asterisk-commits mailing list