[asterisk-commits] oej: branch oej/manager-check-trunk r342764 - /team/oej/manager-check-trunk/m...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Oct 31 09:23:21 CDT 2011
Author: oej
Date: Mon Oct 31 09:23:14 2011
New Revision: 342764
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=342764
Log:
Trying to convert to ao2 callback
Modified:
team/oej/manager-check-trunk/main/manager.c
Modified: team/oej/manager-check-trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/oej/manager-check-trunk/main/manager.c?view=diff&rev=342764&r1=342763&r2=342764
==============================================================================
--- team/oej/manager-check-trunk/main/manager.c (original)
+++ team/oej/manager-check-trunk/main/manager.c Mon Oct 31 09:23:14 2011
@@ -6504,24 +6504,17 @@
};
/*! \brief Get number of logged in sessions for a login name */
-static int get_manager_sessions(const char *login)
-{
- int no_sessions = 0;
- struct mansession_session *session;
- struct ao2_iterator i;
-
- i = ao2_iterator_init(sessions, 0);
- while ((session = ao2_iterator_next(&i))) {
- ao2_lock(session);
- if (strcasecmp(session->username, login) == 0) {
- no_sessions++;
- }
- ao2_unlock(session);
- unref_mansession(session);
- }
- ao2_iterator_destroy(&i);
-
- return no_sessions;
+static int get_manager_sessions_cb(void *obj, void *arg, void *data, int flags)
+{
+ struct mansession_session *session = obj;
+ const char *login = arg;
+ int *no_sessions = data;
+
+ if (strcasecmp(session->username, login) == 0) {
+ *no_sessions++;
+ }
+
+ return 0;
}
@@ -6553,7 +6546,9 @@
AST_RWLIST_UNLOCK(&users);
if (!strcasecmp(args.param, "sessions")) {
- snprintf(buf, len, "%d", get_manager_sessions(data));
+ int no_sessions = 0;
+ ao2_callback_data(sessions, 0, get_manager_sessions_cb, /*login name*/ data, &no_sessions);
+ snprintf(buf, len, "%d", no_sessions);
} else {
ast_log(LOG_ERROR, "Invalid arguments provided to function AMI_CLIENT: %s\n", args.param);
return -1;
More information about the asterisk-commits
mailing list