diff options
author | Luigi Rizzo <rizzo@icir.org> | 2006-11-28 09:27:37 +0000 |
---|---|---|
committer | Luigi Rizzo <rizzo@icir.org> | 2006-11-28 09:27:37 +0000 |
commit | d1dcb0de2a81b942995774e38651248f084b5599 (patch) | |
tree | d71f46cdcea3b092203a08a218f1fd3b9d68789f /main | |
parent | da80478d9467192dd8e22ef8b57bae381ce0d39e (diff) |
always use managerid to determine whether this is an AMI or HTTP session,
and document it.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@48077 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main')
-rw-r--r-- | main/manager.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/main/manager.c b/main/manager.c index 61b72c9cf..4b0f87e45 100644 --- a/main/manager.c +++ b/main/manager.c @@ -124,10 +124,12 @@ AST_THREADSTORAGE(manager_event_buf); AST_THREADSTORAGE(astman_append_buf); #define ASTMAN_APPEND_BUF_INITSIZE 256 -/*! \brief Descriptor for an AMI session, either a regular one - * or one over http. - * For AMI sessions, the entry is created upon a connect, and destroyed - * with the socket. +/*! + * Descriptor for a manager session, either on the AMI socket or over HTTP. + * AMI session have managerid == 0; the entry is created upon a connect, + * and destroyed with the socket. + * HTTP sessions have managerid != 0, the value is used as a search key + * to lookup sessions (using the mansession_id cookie). */ struct mansession { pthread_t ms_t; /*!< Execution thread, basically useless */ @@ -1246,10 +1248,10 @@ static int action_login(struct mansession *s, struct message *m) s->authenticated = 1; 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)); + ast_verbose(VERBOSE_PREFIX_2 "%sManager '%s' logged on from %s\n", (s->managerid ? "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)); + ast_log(LOG_EVENT, "%sManager '%s' logged on from %s\n", (s->managerid ? "HTTP " : ""), s->username, ast_inet_ntoa(s->sin.sin_addr)); astman_send_ack(s, m, "Authentication accepted"); return 0; } @@ -2427,7 +2429,11 @@ static char *contenttype[] = { [FORMAT_XML] = "xml", }; -/* locate an http session in the list using the cookie as a key */ +/*! + * locate an http session in the list. The search key (ident) is + * the value of the mansession_id cookie (0 is not valid and means + * a session on the AMI socket). + */ static struct mansession *find_session(unsigned long ident) { struct mansession *s; @@ -2438,7 +2444,7 @@ static struct mansession *find_session(unsigned long ident) AST_LIST_LOCK(&sessions); AST_LIST_TRAVERSE(&sessions, s, list) { ast_mutex_lock(&s->__lock); - if (s->sessiontimeout && (s->managerid == ident) && !s->needdestroy) { + if (s->managerid == ident && !s->needdestroy) { ast_atomic_fetchadd_int(&s->inuse, 1); break; } @@ -2640,7 +2646,7 @@ static char *generic_http_callback(enum output_format format, char **title, int *contentlength) { struct mansession *s = NULL; - unsigned long ident = 0; + unsigned long ident = 0; /* invalid, so find_session will fail if not set through the cookie */ char workspace[1024]; size_t len = sizeof(workspace); int blastaway = 0; |