[svn-commits] bweschke: branch bweschke/eventq-sanity-checks r58818
- in /team/bweschke/eve...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sun Mar 11 21:03:28 MST 2007
Author: bweschke
Date: Sun Mar 11 23:03:27 2007
New Revision: 58818
URL: http://svn.digium.com/view/asterisk?view=rev&rev=58818
Log:
Start adding some timestamp based management to the AMI event queue.
Modified:
team/bweschke/eventq-sanity-checks/include/asterisk/manager.h
team/bweschke/eventq-sanity-checks/main/manager.c
Modified: team/bweschke/eventq-sanity-checks/include/asterisk/manager.h
URL: http://svn.digium.com/view/asterisk/team/bweschke/eventq-sanity-checks/include/asterisk/manager.h?view=diff&rev=58818&r1=58817&r2=58818
==============================================================================
--- team/bweschke/eventq-sanity-checks/include/asterisk/manager.h (original)
+++ team/bweschke/eventq-sanity-checks/include/asterisk/manager.h Sun Mar 11 23:03:27 2007
@@ -46,6 +46,8 @@
*/
#define DEFAULT_MANAGER_PORT 5038 /* Default port for Asterisk management via TCP */
+
+#define DEFAULT_MAX_EVENTAGE 60
#define EVENT_FLAG_SYSTEM (1 << 0) /* System events such as module load/unload */
#define EVENT_FLAG_CALL (1 << 1) /* Call event, such as state change, etc */
Modified: team/bweschke/eventq-sanity-checks/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/eventq-sanity-checks/main/manager.c?view=diff&rev=58818&r1=58817&r2=58818
==============================================================================
--- team/bweschke/eventq-sanity-checks/main/manager.c (original)
+++ team/bweschke/eventq-sanity-checks/main/manager.c Sun Mar 11 23:03:27 2007
@@ -88,6 +88,7 @@
struct eventqent {
int usecount;
int category;
+ time_t timeposted;
struct eventqent *next;
char eventdata[1];
};
@@ -98,6 +99,7 @@
static int displayconnects = 1;
static int timestampevents;
static int httptimeout = 60;
+static int maxeventage = DEFAULT_MAX_EVENTAGE;
static pthread_t t;
static int block_sockets;
@@ -166,6 +168,8 @@
int displaysystemname; /*!< Add system name to manager responses and events */
/* Queued events that we've not had the ability to send yet */
struct eventqent *eventq;
+ /* Last time events were processed */
+ time_t lasteventrun;
/* Timeout for ast_carefulwrite() */
int writetimeout;
AST_LIST_ENTRY(mansession) list;
@@ -1928,8 +1932,19 @@
{
struct eventqent *eqe;
int ret = 0;
+ time_t currentt = 0;
ast_mutex_lock(&s->__lock);
if (s->fd > -1) {
+ time(¤tt);
+ if ((currentt - s->lasteventrun) > (maxeventage * 1000)) {
+ if (option_debug > 2)
+ ast_log(LOG_DEBUG, "Resetting the event pointer for this manager session.\n");
+ s->eventq = master_eventq;
+ while (s->eventq->next && (s->eventq->timeposted < (currentt - (maxeventage * 1000)))) {
+ eqe = s->eventq->next;
+ s->eventq = eqe;
+ }
+ }
if (!s->eventq)
s->eventq = master_eventq;
while(s->eventq->next) {
@@ -2252,6 +2267,7 @@
ast_mutex_init(&s->__lock);
s->fd = as;
s->send_events = -1;
+ s->lasteventrun = 0;
AST_LIST_LOCK(&sessions);
AST_LIST_INSERT_HEAD(&sessions, s, list);
/* Find the last place in the master event queue and hook ourselves
@@ -2279,6 +2295,7 @@
tmp->next = NULL;
tmp->category = category;
strcpy(tmp->eventdata, str);
+ time(&tmp->timeposted);
if (master_eventq) {
prev = master_eventq;
@@ -2716,6 +2733,13 @@
portno = DEFAULT_MANAGER_PORT;
}
}
+
+ if ((val = ast_variable_retrieve(cfg, "general", "maxeventage"))) {
+ if (sscanf(val, "%d", &maxeventage) != 1) {
+ ast_log(LOG_WARNING, "Invalid max event age '%s'\n", val);
+ maxeventage = DEFAULT_MAX_EVENTAGE;
+ }
+ }
if ((val = ast_variable_retrieve(cfg, "general", "displayconnects")))
displayconnects = ast_true(val);
More information about the svn-commits
mailing list