[svn-commits] bweschke: branch bweschke/eventq-sanity-checks r59032 - /team/bweschke/eventq...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Mar 16 14:59:55 MST 2007


Author: bweschke
Date: Fri Mar 16 16:59:53 2007
New Revision: 59032

URL: http://svn.digium.com/view/asterisk?view=rev&rev=59032
Log:
 Start cleaning stuff up to get it ready to go back in.


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=59032&r1=59031&r2=59032
==============================================================================
--- team/bweschke/eventq-sanity-checks/main/manager.c (original)
+++ team/bweschke/eventq-sanity-checks/main/manager.c Fri Mar 16 16:59:53 2007
@@ -69,6 +69,11 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/linkedlists.h"
 
+enum manager_type {
+	STD_MANAGER = 0,
+	HTTP_MANAGER = 1,
+};
+
 struct fast_originate_helper {
 	char tech[AST_MAX_EXTENSION];
 	char data[AST_MAX_EXTENSION];
@@ -147,7 +152,9 @@
 	pthread_t waiting_thread;
 	/*! Unique manager identifer */
 	unsigned long managerid;
-	/*! Session timeout if HTTP */
+	/*! Type of manage session */
+	enum manager_type mtype;
+	/*! Session timeout */
 	time_t sessiontimeout;
 	/*! Output from manager interface */
 	struct ast_dynamic_str *outputstr;
@@ -574,7 +581,7 @@
 	for (s = master_eventq; s; s = s->next) {
 		ast_cli(fd, "Usecount: %d\n",s->usecount);
 		ast_cli(fd, "Category: %d\n", s->category);
-		ast_cli(fd, "Timestamp: %d\n", s->timeposted);
+		ast_cli(fd, "Timestamp: %ld\n", s->timeposted);
 		ast_cli(fd, "Event:\n%s", s->eventdata);
 	}
 	AST_LIST_UNLOCK(&sessions);
@@ -2025,11 +2032,11 @@
 				if (option_verbose > 1) {
 					if (displayconnects) {
 						ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", 
-							(s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
+							(s->mtype ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
 					}
 				}
 				ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", 
-					(s->sessiontimeout ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
+					(s->mtype ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr));
 				astman_send_ack(s, m, "Authentication accepted");
 			}
 		} else if (!strcasecmp(action, "Logoff")) {
@@ -2201,7 +2208,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/TCP Manager '%s' timed out from %s\n",
+					ast_verbose(VERBOSE_PREFIX_2 "Manager '%s' timed out from %s\n",
 						s->username, ast_inet_ntoa(s->sin.sin_addr));
 				}
 				free_session(s);
@@ -2214,7 +2221,7 @@
 		/* Purge master event queue of old, unused events, but make sure we
 		   always keep at least one in the queue */
 		prev = master_eventq;
-		while (prev->next && (!prev->usecount || prev->timeposted < (now - maxeventage))) {
+		while (prev->next && (!prev->usecount || prev->timeposted < (now - (maxeventage+10)))) {
 			eqe = prev;
 			prev = prev->next;
 			free(eqe);
@@ -2267,6 +2274,7 @@
 		ast_mutex_init(&s->__lock);
 		s->fd = as;
 		s->send_events = -1;
+		s->mtype = STD_MANAGER;
 		s->sessiontimeout = now + maxeventage;
 		AST_LIST_LOCK(&sessions);
 		AST_LIST_INSERT_HEAD(&sessions, s, list);
@@ -2505,6 +2513,7 @@
 			goto generic_callback_out;
 		}
 		memcpy(&s->sin, requestor, sizeof(s->sin));
+		s->mtype = HTTP_MANAGER;
 		s->fd = -1;
 		s->waiting_thread = AST_PTHREADT_NULL;
 		s->send_events = 0;



More information about the svn-commits mailing list