[asterisk-commits] tilghman: branch 1.4 r96575 - /branches/1.4/main/devicestate.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri Jan 4 17:03:40 CST 2008
Author: tilghman
Date: Fri Jan 4 17:03:40 2008
New Revision: 96575
URL: http://svn.digium.com/view/asterisk?view=rev&rev=96575
Log:
Fix the problem of notification of a device state change to a device with a '-'
in the name. Could probably do with a better fix in trunk, but this bug has
been open way too long without a better solution.
Reported by: stevedavies
Patch by: tilghman
(Closes issue #9668)
Modified:
branches/1.4/main/devicestate.c
Modified: branches/1.4/main/devicestate.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/devicestate.c?view=diff&rev=96575&r1=96574&r2=96575
==============================================================================
--- branches/1.4/main/devicestate.c (original)
+++ branches/1.4/main/devicestate.c Fri Jan 4 17:03:40 2008
@@ -294,7 +294,7 @@
ast_hint_state_changed(device);
}
-static int __ast_device_state_changed_literal(char *buf)
+static int __ast_device_state_changed_literal(char *buf, int norecurse)
{
char *device;
struct state_change *change;
@@ -304,10 +304,6 @@
ast_log(LOG_DEBUG, "Notification of state change to be queued on device/channel %s\n", buf);
device = buf;
-
- tmp = strrchr(device, '-');
- if (tmp)
- *tmp = '\0';
if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
/* we could not allocate a change struct, or */
@@ -324,6 +320,18 @@
AST_LIST_UNLOCK(&state_changes);
}
+ /* The problem with this API is that a device may be called with the unique
+ * identifier appended or not, but it's separated from the channel name
+ * with a '-', which is also a legitimate character in a channel name. So,
+ * we have to force both names to get their names checked for state changes
+ * to ensure that the right one gets notified. Not a huge performance hit,
+ * but it might could be fixed by an enterprising programmer in trunk.
+ */
+ if (!norecurse && (tmp = strrchr(device, '-'))) {
+ *tmp = '\0';
+ __ast_device_state_changed_literal(tmp, 1);
+ }
+
return 1;
}
@@ -331,7 +339,7 @@
{
char *buf;
buf = ast_strdupa(dev);
- return __ast_device_state_changed_literal(buf);
+ return __ast_device_state_changed_literal(buf, 0);
}
/*! \brief Accept change notification, add it to change queue */
@@ -343,7 +351,7 @@
va_start(ap, fmt);
vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
- return __ast_device_state_changed_literal(buf);
+ return __ast_device_state_changed_literal(buf, 0);
}
/*! \brief Go through the dev state change queue and update changes in the dev state thread */
More information about the asterisk-commits
mailing list