mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
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
This commit is contained in:
@@ -124,10 +124,12 @@ AST_THREADSTORAGE(manager_event_buf);
|
|||||||
AST_THREADSTORAGE(astman_append_buf);
|
AST_THREADSTORAGE(astman_append_buf);
|
||||||
#define ASTMAN_APPEND_BUF_INITSIZE 256
|
#define ASTMAN_APPEND_BUF_INITSIZE 256
|
||||||
|
|
||||||
/*! \brief Descriptor for an AMI session, either a regular one
|
/*!
|
||||||
* or one over http.
|
* Descriptor for a manager session, either on the AMI socket or over HTTP.
|
||||||
* For AMI sessions, the entry is created upon a connect, and destroyed
|
* AMI session have managerid == 0; the entry is created upon a connect,
|
||||||
* with the socket.
|
* 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 {
|
struct mansession {
|
||||||
pthread_t ms_t; /*!< Execution thread, basically useless */
|
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;
|
s->authenticated = 1;
|
||||||
if (option_verbose > 1) {
|
if (option_verbose > 1) {
|
||||||
if (displayconnects) {
|
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");
|
astman_send_ack(s, m, "Authentication accepted");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -2427,7 +2429,11 @@ static char *contenttype[] = {
|
|||||||
[FORMAT_XML] = "xml",
|
[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)
|
static struct mansession *find_session(unsigned long ident)
|
||||||
{
|
{
|
||||||
struct mansession *s;
|
struct mansession *s;
|
||||||
@@ -2438,7 +2444,7 @@ static struct mansession *find_session(unsigned long ident)
|
|||||||
AST_LIST_LOCK(&sessions);
|
AST_LIST_LOCK(&sessions);
|
||||||
AST_LIST_TRAVERSE(&sessions, s, list) {
|
AST_LIST_TRAVERSE(&sessions, s, list) {
|
||||||
ast_mutex_lock(&s->__lock);
|
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);
|
ast_atomic_fetchadd_int(&s->inuse, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2640,7 +2646,7 @@ static char *generic_http_callback(enum output_format format,
|
|||||||
char **title, int *contentlength)
|
char **title, int *contentlength)
|
||||||
{
|
{
|
||||||
struct mansession *s = NULL;
|
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];
|
char workspace[1024];
|
||||||
size_t len = sizeof(workspace);
|
size_t len = sizeof(workspace);
|
||||||
int blastaway = 0;
|
int blastaway = 0;
|
||||||
|
Reference in New Issue
Block a user