mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +00:00
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/trunk@378322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
87 lines
2.5 KiB
C
87 lines
2.5 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2012, Terry Wilson
|
|
*
|
|
* Terry Wilson <twilson@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*
|
|
* Please follow coding guidelines
|
|
* http://svn.digium.com/view/asterisk/trunk/doc/CODING-GUIDELINES
|
|
*/
|
|
|
|
/*! \file
|
|
*
|
|
* \brief Confbridge state handling for the EMPTY state
|
|
*
|
|
* \author\verbatim Terry Wilson <twilson@digium.com> \endverbatim
|
|
*
|
|
* \ingroup applications
|
|
*/
|
|
|
|
/*** MODULEINFO
|
|
<support_level>core</support_level>
|
|
***/
|
|
|
|
#include "asterisk.h"
|
|
#include "asterisk/devicestate.h"
|
|
#include "include/confbridge.h"
|
|
#include "include/conf_state.h"
|
|
|
|
static void join_unmarked(struct conference_bridge_user *cbu);
|
|
static void join_waitmarked(struct conference_bridge_user *cbu);
|
|
static void join_marked(struct conference_bridge_user *cbu);
|
|
static void transition_to_empty(struct conference_bridge_user *cbu);
|
|
|
|
struct conference_state STATE_EMPTY = {
|
|
.name = "EMPTY",
|
|
.join_unmarked = join_unmarked,
|
|
.join_waitmarked = join_waitmarked,
|
|
.join_marked = join_marked,
|
|
.entry = transition_to_empty,
|
|
};
|
|
|
|
struct conference_state *CONF_STATE_EMPTY = &STATE_EMPTY;
|
|
|
|
static void join_unmarked(struct conference_bridge_user *cbu)
|
|
{
|
|
conf_add_user_active(cbu->conference_bridge, cbu);
|
|
conf_handle_first_join(cbu->conference_bridge);
|
|
conf_add_post_join_action(cbu, conf_handle_only_unmarked);
|
|
|
|
conf_change_state(cbu, CONF_STATE_SINGLE);
|
|
}
|
|
|
|
static void join_waitmarked(struct conference_bridge_user *cbu)
|
|
{
|
|
conf_default_join_waitmarked(cbu);
|
|
conf_handle_first_join(cbu->conference_bridge);
|
|
|
|
conf_change_state(cbu, CONF_STATE_INACTIVE);
|
|
}
|
|
|
|
static void join_marked(struct conference_bridge_user *cbu)
|
|
{
|
|
conf_add_user_marked(cbu->conference_bridge, cbu);
|
|
conf_handle_first_join(cbu->conference_bridge);
|
|
conf_add_post_join_action(cbu, conf_handle_first_marked_common);
|
|
|
|
conf_change_state(cbu, CONF_STATE_SINGLE_MARKED);
|
|
}
|
|
|
|
static void transition_to_empty(struct conference_bridge_user *cbu)
|
|
{
|
|
/* Set device state to "not in use" */
|
|
ast_devstate_changed(AST_DEVICE_NOT_INUSE, AST_DEVSTATE_CACHABLE, "confbridge:%s", cbu->conference_bridge->name);
|
|
conf_ended(cbu->conference_bridge);
|
|
}
|