[asterisk-commits] mmichelson: branch group/manager2 r112555 - in /team/group/manager2: apps/ ma...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Apr 2 16:13:58 CDT 2008
Author: mmichelson
Date: Wed Apr 2 16:13:57 2008
New Revision: 112555
URL: http://svn.digium.com/view/asterisk?view=rev&rev=112555
Log:
Merged revisions 112469 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r112469 | mmichelson | 2008-04-02 12:36:49 -0500 (Wed, 02 Apr 2008) | 21 lines
Merged revisions 112468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r112468 | mmichelson | 2008-04-02 12:36:04 -0500 (Wed, 02 Apr 2008) | 13 lines
Fix a race condition in the manager. It is possible that a new manager event
could be appended during a brief time when the manager is not waiting for input.
If an event comes during this period, we need to set an indicator that there is an
event pending so that the manager doesn't attempt to wait forever for an event that
already happened.
(closes issue #12354)
Reported by: bamby
Patches:
manager_race_condition.diff uploaded by bamby (license 430)
(comments added by me)
........
................
Modified:
team/group/manager2/apps/app_queue.c
team/group/manager2/main/event.c
team/group/manager2/res/res_manager2.c
Modified: team/group/manager2/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/apps/app_queue.c?view=diff&rev=112555&r1=112554&r2=112555
==============================================================================
--- team/group/manager2/apps/app_queue.c (original)
+++ team/group/manager2/apps/app_queue.c Wed Apr 2 16:13:57 2008
@@ -2065,7 +2065,7 @@
}
/*temporarily comment this out since we're not using it but may need it for later */
/*! \brief convert "\n" to "\nVariable: " ready for manager to use */
-static void vars2manager(struct ast_channel *chan, struct ast_event *event)
+static void vars2manager(struct ast_channel *chan, struct ast_event **event)
{
struct ast_str *buf = ast_str_alloca(2048);
@@ -2075,7 +2075,7 @@
while ((var = strsep(&vars, "\n"))) {
if (!ast_strlen_zero(var)) {
- ast_event_append_ie_str(&event, AST_EVENT_IE_CHANVAR, var);
+ ast_event_append_ie_str(event, AST_EVENT_IE_CHANVAR, var);
}
}
}
@@ -2217,7 +2217,7 @@
AST_EVENT_IE_END);
if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
- vars2manager(qe->chan, event);
+ vars2manager(qe->chan, &event);
}
ast_event_queue(event);
@@ -3005,7 +3005,7 @@
AST_EVENT_IE_END);
if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
- vars2manager(qe->chan, event);
+ vars2manager(qe->chan, &event);
}
ast_event_queue(event);
@@ -3348,7 +3348,7 @@
AST_EVENT_IE_END);
if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
- vars2manager(qe->chan, event);
+ vars2manager(qe->chan, &event);
}
ast_event_queue(event);
@@ -3639,7 +3639,7 @@
AST_EVENT_IE_END);
if (qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES) {
- vars2manager(qe->chan, event);
+ vars2manager(qe->chan, &event);
}
ast_event_queue(event);
Modified: team/group/manager2/main/event.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/main/event.c?view=diff&rev=112555&r1=112554&r2=112555
==============================================================================
--- team/group/manager2/main/event.c (original)
+++ team/group/manager2/main/event.c Wed Apr 2 16:13:57 2008
@@ -119,54 +119,64 @@
static AST_RWLIST_HEAD(ast_event_ref_list, ast_event_ref) ast_event_cache[AST_EVENT_TOTAL];
struct ast_event_ie_map {
+ enum ast_event_ie_type ie;
enum ast_event_ie_pltype pltype;
const char * name; /*!< The name is used for debugging and manager purposes currently */
} info_map[] = { /*NOTE: it is INSANELY IMPORTANT that these are in the same order as the above enum. My GOD I CANNOT STRESS THIS ENOUGH!!! */
- {AST_EVENT_IE_PLTYPE_STR, "RUBBERDUCK"}, /*!< Placeholder for nonexistent IE 0 */
- {AST_EVENT_IE_PLTYPE_UINT, "NewMessages"}, /*!< AST_EVENT_IE_NEWMSGS 1 */
- {AST_EVENT_IE_PLTYPE_UINT, "OldMessages"}, /*!< AST_EVENT_IE_OLDMSGS 2 */
- {AST_EVENT_IE_PLTYPE_STR, "Mailbox"}, /*!< AST_EVENT_IE_MAILBOX 3 */
- {AST_EVENT_IE_PLTYPE_UINT, "EventUniqueID"}, /*!< AST_EVENT_IE_UNIQUEIED 4 */
- {AST_EVENT_IE_PLTYPE_UINT, "EventType"}, /*!< AST_EVENT_IE_EVENTTYPE 5 */
- {AST_EVENT_IE_PLTYPE_UINT, "Exists"}, /*!< AST_EVENT_IE_EXISTS 6 */
- {AST_EVENT_IE_PLTYPE_STR, "Device"}, /*!< AST_EVENT_IE_DEVICE 7 */
- {AST_EVENT_IE_PLTYPE_UINT, "State"}, /*!< AST_EVENT_IE_STATE 8 */
- {AST_EVENT_IE_PLTYPE_STR, "Context"}, /*!< AST_EVENT_IE_CONTEXT 9 */
- {AST_EVENT_IE_PLTYPE_STR, "QueueName"}, /*!< AST_EVENT_IE_QUEUE_NAME 10 */
- {AST_EVENT_IE_PLTYPE_STR, "MemberName"}, /*!< AST_EVENT_IE_QUEUE_MEMBERNAME 11 */
- {AST_EVENT_IE_PLTYPE_UINT, "Penalty"}, /*!< AST_EVENT_IE_QUEUE_PENALTY 12 */
- {AST_EVENT_IE_PLTYPE_UINT, "Calls"}, /*!< AST_EVENT_IE_QUEUE_CALLS 13 */
- {AST_EVENT_IE_PLTYPE_UINT, "LastCall"}, /*!< AST_EVENT_IE_QUEUE_LASTCALL 14 */
- {AST_EVENT_IE_PLTYPE_UINT, "Paused"}, /*!< AST_EVENT_IE_QUEUE_PAUSED 15 */
- {AST_EVENT_IE_PLTYPE_STR, "SourceChannel"}, /*!< AST_EVENT_IE SOURCE_CHANNEL 16 */
- {AST_EVENT_IE_PLTYPE_STR, "CallerIDNumber"}, /*!< AST_EVENT_IE_CALLERIDNUMBER 17 */
- {AST_EVENT_IE_PLTYPE_STR, "CallerIDName"}, /*!< AST_EVENT_IE_CALLERIDNAME 18 */
- {AST_EVENT_IE_PLTYPE_UINT, "Position"}, /*!< AST_EVENT_IE_QUEUE_POSITION 19 */
- {AST_EVENT_IE_PLTYPE_UINT, "Count"}, /*!< AST_EVENT_IE_QUEUE_COUNT 20 */
- {AST_EVENT_IE_PLTYPE_STR, "SourceUniqueID"}, /*!< AST_EVENT_IE_SOURCE_UNIQUEID 21 */
- {AST_EVENT_IE_PLTYPE_STR, "Membership"}, /*!< AST_EVENT_IE_QUEUE_MEMBERSHIP 22 */
- {AST_EVENT_IE_PLTYPE_STR, "DestinationChannel"}, /*!< AST_EVENT_IE_DESTINATION_CHANNEL 23 */
- {AST_EVENT_IE_PLTYPE_STR, "Extension"}, /*!< AST_EVENT_IE_EXTENSION 24 */
- {AST_EVENT_IE_PLTYPE_UINT, "Priority"}, /*!< AST_EVENT_IE_PRIORITY 25 */
- {AST_EVENT_IE_PLTYPE_UINT, "OriginalPosition"}, /*!< AST_EVENT_IE_QUEUE_ORIGINAL_POSITION 26 */
- {AST_EVENT_IE_PLTYPE_UINT, "HoldTime"}, /*!< AST_EVENT_IE_QUEUE_HOLDTIME 27 */
- {AST_EVENT_IE_PLTYPE_UINT, "TalkTime"}, /*!< AST_EVENT_IE_QUEUE_TALKTIME 28 */
- {AST_EVENT_IE_PLTYPE_STR, "Reason"}, /*!< AST_EVENT_IE_QUEUE_REASON 29 */
- {AST_EVENT_IE_PLTYPE_UINT, "RingTime"}, /*!< AST_EVENT_IE_QUEUE_RINGTIME 30 */
- {AST_EVENT_IE_PLTYPE_STR, "DestinationUniqueID"}, /*!< AST_EVENT_IE_DESTINATION_UNIQUEID 31 */
- {AST_EVENT_IE_PLTYPE_STR, "Variable"}, /*!< AST_EVENT_IE_CHANVAR 32 */
- {AST_EVENT_IE_PLTYPE_UINT, "FileDescriptor"}, /*!< AST_EVENT_IE_FD 33 */
- {AST_EVENT_IE_PLTYPE_STR, "Username"}, /*!< AST_EVENT_IE_USERNAME 34 */
+ {0, AST_EVENT_IE_PLTYPE_STR, "RUBBERDUCK"}, /*!< Placeholder for nonexistent IE 0 */
+ {AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, "NewMessages"}, /*!< AST_EVENT_IE_NEWMSGS 1 */
+ {AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, "OldMessages"}, /*!< AST_EVENT_IE_OLDMSGS 2 */
+ {AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, "Mailbox"}, /*!< AST_EVENT_IE_MAILBOX 3 */
+ {AST_EVENT_IE_UNIQUEID, AST_EVENT_IE_PLTYPE_UINT, "EventUniqueID"}, /*!< AST_EVENT_IE_UNIQUEIED 4 */
+ {AST_EVENT_IE_EVENTTYPE, AST_EVENT_IE_PLTYPE_UINT, "EventType"}, /*!< AST_EVENT_IE_EVENTTYPE 5 */
+ {AST_EVENT_IE_EXISTS, AST_EVENT_IE_PLTYPE_UINT, "Exists"}, /*!< AST_EVENT_IE_EXISTS 6 */
+ {AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, "Device"}, /*!< AST_EVENT_IE_DEVICE 7 */
+ {AST_EVENT_IE_STATE, AST_EVENT_IE_PLTYPE_UINT, "State"}, /*!< AST_EVENT_IE_STATE 8 */
+ {AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, "Context"}, /*!< AST_EVENT_IE_CONTEXT 9 */
+ {AST_EVENT_IE_QUEUE_NAME, AST_EVENT_IE_PLTYPE_STR, "QueueName"}, /*!< AST_EVENT_IE_QUEUE_NAME 10 */
+ {AST_EVENT_IE_QUEUE_MEMBERNAME, AST_EVENT_IE_PLTYPE_STR, "MemberName"}, /*!< AST_EVENT_IE_QUEUE_MEMBERNAME 11 */
+ {AST_EVENT_IE_QUEUE_PENALTY, AST_EVENT_IE_PLTYPE_UINT, "Penalty"}, /*!< AST_EVENT_IE_QUEUE_PENALTY 12 */
+ {AST_EVENT_IE_QUEUE_CALLS, AST_EVENT_IE_PLTYPE_UINT, "Calls"}, /*!< AST_EVENT_IE_QUEUE_CALLS 13 */
+ {AST_EVENT_IE_QUEUE_LASTCALL, AST_EVENT_IE_PLTYPE_UINT, "LastCall"}, /*!< AST_EVENT_IE_QUEUE_LASTCALL 14 */
+ {AST_EVENT_IE_QUEUE_PAUSED, AST_EVENT_IE_PLTYPE_UINT, "Paused"}, /*!< AST_EVENT_IE_QUEUE_PAUSED 15 */
+ {AST_EVENT_IE_SOURCE_CHANNEL, AST_EVENT_IE_PLTYPE_STR, "SourceChannel"}, /*!< AST_EVENT_IE SOURCE_CHANNEL 16 */
+ {AST_EVENT_IE_CALLERIDNUM, AST_EVENT_IE_PLTYPE_STR, "CallerIDNumber"}, /*!< AST_EVENT_IE_CALLERIDNUMBER 17 */
+ {AST_EVENT_IE_CALLERIDNAME, AST_EVENT_IE_PLTYPE_STR, "CallerIDName"}, /*!< AST_EVENT_IE_CALLERIDNAME 18 */
+ {AST_EVENT_IE_QUEUE_POSITION, AST_EVENT_IE_PLTYPE_UINT, "Position"}, /*!< AST_EVENT_IE_QUEUE_POSITION 19 */
+ {AST_EVENT_IE_QUEUE_COUNT, AST_EVENT_IE_PLTYPE_UINT, "Count"}, /*!< AST_EVENT_IE_QUEUE_COUNT 20 */
+ {AST_EVENT_IE_SOURCE_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, "SourceUniqueID"}, /*!< AST_EVENT_IE_SOURCE_UNIQUEID 21 */
+ {AST_EVENT_IE_QUEUE_MEMBERSHIP, AST_EVENT_IE_PLTYPE_STR, "Membership"}, /*!< AST_EVENT_IE_QUEUE_MEMBERSHIP 22 */
+ {AST_EVENT_IE_DESTINATION_CHANNEL, AST_EVENT_IE_PLTYPE_STR, "DestinationChannel"}, /*!< AST_EVENT_IE_DESTINATION_CHANNEL 23 */
+ {AST_EVENT_IE_EXTENSION, AST_EVENT_IE_PLTYPE_STR, "Extension"}, /*!< AST_EVENT_IE_EXTENSION 24 */
+ {AST_EVENT_IE_PRIORITY, AST_EVENT_IE_PLTYPE_UINT, "Priority"}, /*!< AST_EVENT_IE_PRIORITY 25 */
+ {AST_EVENT_IE_QUEUE_ORIGINAL_POSITION, AST_EVENT_IE_PLTYPE_UINT, "OriginalPosition"}, /*!< AST_EVENT_IE_QUEUE_ORIGINAL_POSITION 26 */
+ {AST_EVENT_IE_QUEUE_HOLDTIME, AST_EVENT_IE_PLTYPE_UINT, "HoldTime"}, /*!< AST_EVENT_IE_QUEUE_HOLDTIME 27 */
+ {AST_EVENT_IE_QUEUE_TALKTIME, AST_EVENT_IE_PLTYPE_UINT, "TalkTime"}, /*!< AST_EVENT_IE_QUEUE_TALKTIME 28 */
+ {AST_EVENT_IE_QUEUE_REASON, AST_EVENT_IE_PLTYPE_STR, "Reason"}, /*!< AST_EVENT_IE_QUEUE_REASON 29 */
+ {AST_EVENT_IE_QUEUE_RINGTIME, AST_EVENT_IE_PLTYPE_UINT, "RingTime"}, /*!< AST_EVENT_IE_QUEUE_RINGTIME 30 */
+ {AST_EVENT_IE_DESTINATION_UNIQUEID, AST_EVENT_IE_PLTYPE_STR, "DestinationUniqueID"}, /*!< AST_EVENT_IE_DESTINATION_UNIQUEID 31 */
+ {AST_EVENT_IE_CHANVAR, AST_EVENT_IE_PLTYPE_STR, "Variable"}, /*!< AST_EVENT_IE_CHANVAR 32 */
+ {AST_EVENT_IE_FD, AST_EVENT_IE_PLTYPE_UINT, "FileDescriptor"}, /*!< AST_EVENT_IE_FD 33 */
+ {AST_EVENT_IE_USERNAME, AST_EVENT_IE_PLTYPE_STR, "Username"}, /*!< AST_EVENT_IE_USERNAME 34 */
};
enum ast_event_ie_pltype ast_event_ie_get_pltype(enum ast_event_ie_type ie)
{
- return info_map[ie].pltype;
+ if (ie > 0 && ie < AST_EVENT_IE_END &&
+ info_map[ie].ie == ie) {
+ return info_map[ie].pltype;
+ }
+ return -1;
}
const char * ast_event_ie_get_name(enum ast_event_ie_type ie)
{
- return info_map[ie].name;
+ if (ie > 0 && ie < AST_EVENT_IE_END &&
+ info_map[ie].ie == ie) {
+ return info_map[ie].name;
+ }
+
+ return NULL;
}
static void ast_event_ie_val_destroy(struct ast_event_ie_val *ie_val)
Modified: team/group/manager2/res/res_manager2.c
URL: http://svn.digium.com/view/asterisk/team/group/manager2/res/res_manager2.c?view=diff&rev=112555&r1=112554&r2=112555
==============================================================================
--- team/group/manager2/res/res_manager2.c (original)
+++ team/group/manager2/res/res_manager2.c Wed Apr 2 16:13:57 2008
@@ -90,9 +90,9 @@
if (ie_type == AST_EVENT_IE_END)
break;
if (ast_event_ie_get_pltype(ie_type) == AST_EVENT_IE_PLTYPE_STR)
- ast_str_append(&buf, 0, "%s: %s\r\n", ast_event_ie_get_name(ie_type), ast_event_iterator_get_ie_str(&iter));
+ ast_str_append(&buf, 0, "%s: %s\r\n", S_OR(ast_event_ie_get_name(ie_type), ""), ast_event_iterator_get_ie_str(&iter));
else if (ast_event_ie_get_pltype(ie_type) == AST_EVENT_IE_PLTYPE_UINT)
- ast_str_append(&buf, 0, "%s: %u\r\n", ast_event_ie_get_name(ie_type), ast_event_iterator_get_ie_uint(&iter));
+ ast_str_append(&buf, 0, "%s: %u\r\n", S_OR(ast_event_ie_get_name(ie_type), ""), ast_event_iterator_get_ie_uint(&iter));
}
ast_str_append(&buf, 0, "%s", "\r\n");
More information about the asterisk-commits
mailing list