mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 00:41:02 +00:00
Merged revisions 378322 via svnmerge from
file:///srv/subversion/repos/asterisk/trunk ................ r378322 | mjordan | 2013-01-02 12:11:59 -0600 (Wed, 02 Jan 2013) | 33 lines Prevent exhaustion of system resources through exploitation of event cache Asterisk maintains an internal cache for devices in the event subsystem. The device state cache holds the state of each device known to Asterisk, such that consumers of device state information can query for the last known state for a particular device, even if it is not part of an active call. The concept of a device in Asterisk can include entities that do not have a physical representation. One way that this occurred was when anonymous calls are allowed in Asterisk. A device was automatically created and stored in the cache for each anonymous call that occurred; this was possible in the SIP and IAX2 channel drivers and through channel drivers that utilized the res_jabber/res_xmpp resource modules (Gtalk, Jingle, and Motif). These devices are never removed from the system, allowing anonymous calls to potentially exhaust a system's resources. This patch changes the event cache subsystem and device state management to no longer cache devices that are not associated with a physical entity. (issue ASTERISK-20175) Reported by: Russell Bryant, Leif Madsen, Joshua Colp Tested by: kmoore patches: event-cachability-3.diff uploaded by jcolp (license 5000) ........ Merged revisions 378303 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 378320 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 378321 from http://svn.asterisk.org/svn/asterisk/branches/11 ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@378329 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1043,7 +1043,7 @@ int conf_add_post_join_action(struct conference_bridge_user *cbu, int (*func)(st
|
||||
|
||||
void conf_handle_first_join(struct conference_bridge *conference_bridge)
|
||||
{
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "confbridge:%s", conference_bridge->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", conference_bridge->name);
|
||||
}
|
||||
|
||||
void conf_handle_second_active(struct conference_bridge *conference_bridge)
|
||||
|
@@ -2706,7 +2706,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, struc
|
||||
|
||||
/* This device changed state now - if this is the first user */
|
||||
if (conf->users == 1)
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "meetme:%s", conf->confno);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno);
|
||||
|
||||
ast_mutex_unlock(&conf->playlock);
|
||||
|
||||
@@ -4097,7 +4097,7 @@ bailoutandtrynormal:
|
||||
|
||||
/* Change any states */
|
||||
if (!conf->users) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "meetme:%s", conf->confno);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, (conf->isdynamic ? AST_DEVSTATE_NOT_CACHABLE : AST_DEVSTATE_CACHABLE), "meetme:%s", conf->confno);
|
||||
}
|
||||
|
||||
/* This flag is meant to kill a conference with only one participant remaining. */
|
||||
@@ -5592,8 +5592,8 @@ static void sla_change_trunk_state(const struct sla_trunk *trunk, enum sla_trunk
|
||||
|| trunk_ref == exclude)
|
||||
continue;
|
||||
trunk_ref->state = state;
|
||||
ast_devstate_changed(sla_state_to_devstate(state),
|
||||
"SLA:%s_%s", station->name, trunk->name);
|
||||
ast_devstate_changed(sla_state_to_devstate(state), AST_DEVSTATE_CACHABLE,
|
||||
"SLA:%s_%s", station->name, trunk->name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -6091,8 +6091,8 @@ static void sla_handle_hold_event(struct sla_event *event)
|
||||
{
|
||||
ast_atomic_fetchadd_int((int *) &event->trunk_ref->trunk->hold_stations, 1);
|
||||
event->trunk_ref->state = SLA_TRUNK_STATE_ONHOLD_BYME;
|
||||
ast_devstate_changed(AST_DEVICE_ONHOLD, "SLA:%s_%s",
|
||||
event->station->name, event->trunk_ref->trunk->name);
|
||||
ast_devstate_changed(AST_DEVICE_ONHOLD, AST_DEVSTATE_CACHABLE, "SLA:%s_%s",
|
||||
event->station->name, event->trunk_ref->trunk->name);
|
||||
sla_change_trunk_state(event->trunk_ref->trunk, SLA_TRUNK_STATE_ONHOLD,
|
||||
INACTIVE_TRUNK_REFS, event->trunk_ref);
|
||||
|
||||
@@ -6601,8 +6601,8 @@ static int sla_station_exec(struct ast_channel *chan, const char *data)
|
||||
sla_change_trunk_state(trunk_ref->trunk, SLA_TRUNK_STATE_UP, ALL_TRUNK_REFS, NULL);
|
||||
else {
|
||||
trunk_ref->state = SLA_TRUNK_STATE_UP;
|
||||
ast_devstate_changed(AST_DEVICE_INUSE,
|
||||
"SLA:%s_%s", station->name, trunk_ref->trunk->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE,
|
||||
"SLA:%s_%s", station->name, trunk_ref->trunk->name);
|
||||
}
|
||||
} else if (trunk_ref->state == SLA_TRUNK_STATE_RINGING) {
|
||||
struct sla_ringing_trunk *ringing_trunk;
|
||||
|
@@ -1791,9 +1791,9 @@ static int handle_statechange(void *datap)
|
||||
if (found_member) {
|
||||
found = 1;
|
||||
if (avail) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
} else {
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2083,7 +2083,7 @@ static void init_queue(struct call_queue *q)
|
||||
* AST_DEVICE_INUSE indicates no members are available.
|
||||
* AST_DEVICE_NOT_INUSE indicates a member is available.
|
||||
*/
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
static void clear_queue(struct call_queue *q)
|
||||
@@ -2963,7 +2963,7 @@ static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *
|
||||
ast_copy_string(qe->context, q->context, sizeof(qe->context));
|
||||
q->count++;
|
||||
if (q->count == 1) {
|
||||
ast_devstate_changed(AST_DEVICE_RINGING, "Queue:%s", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_RINGING, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name);
|
||||
}
|
||||
|
||||
res = 0;
|
||||
@@ -3271,7 +3271,7 @@ static void leave_queue(struct queue_ent *qe)
|
||||
char posstr[20];
|
||||
q->count--;
|
||||
if (!q->count) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s", q->name);
|
||||
}
|
||||
|
||||
/* Take us out of the queue */
|
||||
@@ -3538,7 +3538,7 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
|
||||
if (newstate != tmp->member->status) {
|
||||
ast_log(LOG_WARNING, "Found a channel matching iterface %s while status was %s changed to %s\n",
|
||||
tmp->member->interface, ast_devstate2str(tmp->member->status), ast_devstate2str(newstate));
|
||||
ast_devstate_changed_literal(newstate, tmp->member->interface);
|
||||
ast_devstate_changed_literal(newstate, AST_DEVSTATE_CACHABLE, tmp->member->interface);
|
||||
}
|
||||
}
|
||||
if ((tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) {
|
||||
@@ -6027,7 +6027,7 @@ static int remove_from_queue(const char *queuename, const char *interface)
|
||||
}
|
||||
|
||||
if (!num_available_members(q)) {
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
res = RES_OKAY;
|
||||
@@ -6104,7 +6104,7 @@ static int add_to_queue(const char *queuename, const char *interface, const char
|
||||
new_member->status, new_member->paused);
|
||||
|
||||
if (is_member_available(new_member)) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
ao2_ref(new_member, -1);
|
||||
@@ -6175,9 +6175,9 @@ static int set_member_paused(const char *queuename, const char *interface, const
|
||||
}
|
||||
|
||||
if (is_member_available(mem)) {
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
} else if (!num_available_members(q)) {
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, "Queue:%s_avail", q->name);
|
||||
ast_devstate_changed(AST_DEVICE_INUSE, AST_DEVSTATE_CACHABLE, "Queue:%s_avail", q->name);
|
||||
}
|
||||
|
||||
ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, ""));
|
||||
|
@@ -81,6 +81,6 @@ static void join_marked(struct conference_bridge_user *cbu)
|
||||
static void transition_to_empty(struct conference_bridge_user *cbu)
|
||||
{
|
||||
/* Set device state to "not in use" */
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, "confbridge:%s", cbu->conference_bridge->name);
|
||||
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", cbu->conference_bridge->name);
|
||||
conf_ended(cbu->conference_bridge);
|
||||
}
|
||||
|
Reference in New Issue
Block a user