[svn-commits] bweschke: branch bweschke/eventq-sanity-checks r58840
- /team/bweschke/eventq...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Mar 12 14:22:14 MST 2007
Author: bweschke
Date: Mon Mar 12 16:22:13 2007
New Revision: 58840
URL: http://svn.digium.com/view/asterisk?view=rev&rev=58840
Log:
Simplify this logic, alot.
Modified:
team/bweschke/eventq-sanity-checks/main/manager.c
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=58840&r1=58839&r2=58840
==============================================================================
--- team/bweschke/eventq-sanity-checks/main/manager.c (original)
+++ team/bweschke/eventq-sanity-checks/main/manager.c Mon Mar 12 16:22:13 2007
@@ -1936,11 +1936,6 @@
ast_mutex_lock(&s->__lock);
if (s->fd > -1) {
time(¤tt);
- if ((currentt - s->lasteventrun) > (currentt - (maxeventage * 1000))) {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Resetting the event pointer for this manager session.\n");
- s->eventq = master_eventq;
- }
if (!s->eventq)
s->eventq = master_eventq;
while(s->eventq->next) {
@@ -1955,6 +1950,7 @@
}
s->lasteventrun = currentt;
}
+ s->sessiontimeout = currentt + maxeventage;
ast_mutex_unlock(&s->__lock);
return ret;
}
@@ -2181,7 +2177,7 @@
int as;
struct sockaddr_in sin;
socklen_t sinlen;
- struct eventqent *eqe;
+ struct eventqent *eqe, *prev;
struct mansession *s;
struct protoent *p;
int arg = 1;
@@ -2204,7 +2200,7 @@
if (s->sessiontimeout && (now > s->sessiontimeout) && !s->inuse) {
AST_LIST_REMOVE_CURRENT(&sessions, list);
if (s->authenticated && (option_verbose > 1) && displayconnects) {
- ast_verbose(VERBOSE_PREFIX_2 "HTTP Manager '%s' timed out from %s\n",
+ ast_verbose(VERBOSE_PREFIX_2 "HTTP/TCP Manager '%s' timed out from %s\n",
s->username, ast_inet_ntoa(s->sin.sin_addr));
}
free_session(s);
@@ -2212,22 +2208,21 @@
}
}
AST_LIST_TRAVERSE_SAFE_END
+ /* Go through the list of events and prepare any older than max age
+ for purge */
+ prev = master_eventq;
+ while (prev->next) {
+ prev = prev->next;
+ if (prev->timeposted < (now - maxeventage))
+ while (!ast_atomic_dec_and_test(&prev->usecount));
+ }
/* Purge master event queue of old, unused events, but make sure we
always keep at least one in the queue */
eqe = master_eventq;
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "Expire time is %d\n", master_eventq->timeposted);
- while (master_eventq->next) {
- if (!master_eventq->usecount || master_eventq->timeposted < (now - (maxeventage * 1000))) {
- if (master_eventq->timeposted < (now - (maxeventage * 1000)) && option_debug > 2)
- ast_log(LOG_DEBUG, "Event is beyond max event age. Purging it.\n");
- eqe = master_eventq;
- master_eventq = master_eventq->next;
- free(eqe);
- } else {
- if (option_debug > 2)
- ast_log(LOG_DEBUG, "NOT Removing. usecount is %d and timeposted is %d\n",master_eventq->usecount, master_eventq->timeposted);
- }
+ while (master_eventq->next && !master_eventq->usecount) {
+ eqe = master_eventq;
+ master_eventq = master_eventq->next;
+ free(eqe);
}
if (option_debug > 2)
ast_log(LOG_DEBUG, "Num sessions after cleanup: %d\n", num_sessions);
@@ -2273,7 +2268,7 @@
ast_mutex_init(&s->__lock);
s->fd = as;
s->send_events = -1;
- s->lasteventrun = 0;
+ s->sessiontimeout = now + maxeventage;
AST_LIST_LOCK(&sessions);
AST_LIST_INSERT_HEAD(&sessions, s, list);
/* Find the last place in the master event queue and hook ourselves
More information about the svn-commits
mailing list