[svn-commits] branch oej/aum - r7388 in /team/oej/aum: configs/ include/asterisk/ res/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Dec 7 21:24:31 CST 2005


Author: oej
Date: Wed Dec  7 21:24:27 2005
New Revision: 7388

URL: http://svn.digium.com/view/asterisk?rev=7388&view=rev
Log:
Caching realtime users, adding configuration support for more options. (Not tested yet). New function in linkedlists.h: AST_LIST_REMOVE_TAIL

Modified:
    team/oej/aum/configs/aum.conf.sample
    team/oej/aum/include/asterisk/aum.h
    team/oej/aum/include/asterisk/linkedlists.h
    team/oej/aum/res/res_aum.c

Modified: team/oej/aum/configs/aum.conf.sample
URL: http://svn.digium.com/view/asterisk/team/oej/aum/configs/aum.conf.sample?rev=7388&r1=7387&r2=7388&view=diff
==============================================================================
--- team/oej/aum/configs/aum.conf.sample (original)
+++ team/oej/aum/configs/aum.conf.sample Wed Dec  7 21:24:27 2005
@@ -1,27 +1,47 @@
 ;AUM configuration file
+
 [general]
-test=test
+;debug=yes			; AUM debugging
 
+;------------ REALTIME
+;realtimecachelimit = 100	; Maximum number of users in realtime cache
+				; Default = 100
+
+;The groups section contain a list of all groups
+; We have to do this to pre-load groups
+; (Looking for another solution)
 [groups]
 group=edvina
 group=digium
+group=asteriskmanagers
 
+; Group definition
+; Groups are used as templates for users, not as objects in themselves
 [digium]
 type=group
 musicclass=digium-sales-pitch
+setvar=DIGIUMSTAFF=yes
 
 [edvina]
 type=group
 musicclass=edvina-slow
+deny=all
+permit=192.168.40.0/24
 
 [asteriskmanagers]
 type=group
-managerperm=system
+managerperm=system		; Manager permissions for these users
+setvar=SUPERUSER=400
 
-[admin]
+[admin]				; Admin user
+;Which groups does this user belong to?
 group=asteriskmanagers
 group=digium
+;Pin code for this user
 pincode=1235
+email=postmaster at mylittledomain.com
+firstname=Charlie
+lastname=Root
 
 [nancy]
 pincode=1234

Modified: team/oej/aum/include/asterisk/aum.h
URL: http://svn.digium.com/view/asterisk/team/oej/aum/include/asterisk/aum.h?rev=7388&r1=7387&r2=7388&view=diff
==============================================================================
--- team/oej/aum/include/asterisk/aum.h (original)
+++ team/oej/aum/include/asterisk/aum.h Wed Dec  7 21:24:27 2005
@@ -30,6 +30,13 @@
 
 #ifndef _ASTERISK_AUM_H
 #define _ASTERISK_AUM_H
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
 
 /*--------------------------- AUM STRING HANDLING -------------------------------- */
 /*! Character set definition for some strings */
@@ -116,6 +123,8 @@
 	AUM_CNF_MANAGERACCESS,		/*!< Manager access something */
 	AUM_CNF_SECRET,			/*!< Secret (password) */
 	AUM_CNF_PIN,			/*!< Pin code for authorization by DTMF */
+	AUM_CNF_CALLGROUP,		/*!< Calling group */
+	AUM_CNF_PICKUPGROUP,		/*!< Pickup group */
 	AUM_CNF_IAX2KEY,		/*!< Name of IAX key */
 	AUM_CNF_MUSICCLASS,		/*!< Default music class when this user puts someone on hold */
 	AUM_CNF_LDAPDN,			/*!< LDAP handle for this user */
@@ -220,6 +229,18 @@
 	AST_LIST_ENTRY(aum_group_member) list;	/*!< List mechanics */
 };
 
+/*! \brief Flags for aum_user flag field */
+enum aum_user_flags {
+	AUM_USER_FLAG_REALTIME = (1 << 0),	/*!< User loaded from realtime */
+	AUM_USER_FLAG_DISABLED = (1 << 1),	/*!< User disabled */
+};
+
+/*! \brief Flags for aum_group flag field */
+enum aum_group_flags {
+	AUM_GROUP_FLAG_REALTIME = (1 << 0),	/*!< Group loaded from realtime */
+	AUM_GROUP_FLAG_DISABLED = (1 << 1),	/*!< Group disabled */
+}
+
 
 /*! \brief Declaration of grouplist structure for inclusion in objects */
 AST_LIST_HEAD(aum_user_grouplist, aum_group_member);
@@ -235,10 +256,12 @@
 */
 struct aum_user {
 	ASTOBJ_COMPONENTS(struct aum_user);	/*!< Generic pointers - name being one */
+	unsigned int flags;		/*!< Flags for various stuff, see AUM_USER_FLAG_* */
 	char mailbox[AST_MAX_EXTENSION];	/*!< Default mailbox */
 	char default_exten[AST_MAX_EXTENSION];	/*!< Default extension for this user (for callbacks) */
 	char cid_num[256];		/*!< Default caller ID num (E.164 type) */
 	char cid_name[256];		/*!< Default caller ID name */
+	int calling_pres;		/*!< Default Caller ID presentation */
 	char accountcode[AST_MAX_ACCOUNT_CODE];	/*!< Default Account code */
 	char sip_username[256];		/*!< SIP user name (utf8) */
 	char musicclass[MAX_MUSICCLASS];	/*!< Default musicclass for this user */
@@ -246,35 +269,40 @@
 	char last_name[80];		/*!< Last name (ISO 8859-1) */
 	char title[20];			/*!< Title */
 	char language[MAX_LANGUAGE];	/*!< Default language */
-	struct aum_presencelist	presence;	/*! Presence states */
+	char iax2privatekey[20];	/*!< Private key for this user */
 	char zonetag[80];		/*!< Time zone */
 	char numuserid[80];		/*!< Numeric user ID for this user */
 	char pincode[80];		/*!< Numeric pincode for this user */
 	char secret[80];		/*!< Secret for this user */
 	char ldapdn[180];		/*!< LDAP DN */
 	char registrar[20];		/*!< Who added this object? */
+	ast_group_t callgroup;			/*!< Calling group for calls */
+	ast_group_t pickupgroup;		/*!< Pickup group */
 	struct ast_variable *chanvars;	/*!< Default channel variables */
+	struct aum_presencelist	presence;	/*! Presence states */
 	struct aum_user_contextlist contexts;	/*!< Linked list of contexts this user use */
 	struct aum_user_grouplist groups;	/*!< Linked list of groups we are members to */
 	struct aum_user_addrlist address;	/*!< Linked list of addresses of various types */
 	struct ast_ha	*acl;		/*!< Access control list for user */
 					/*!< The highest priority is used as primary group for setting default values */
 	int managerperm;		/*!< If sat, this user can log in to manager with these permissions */
-	int calling_pres;		/*!< Default Caller ID presentation */
 };
 
 /*! \brief the AUM group definition */
 struct aum_group {
-	ASTOBJ_COMPONENTS(struct aum_group);
+	ASTOBJ_COMPONENTS(struct aum_group);	/*! Generic pointers and name field */
+	unsigned int flags;			/*!< Flags for various stuff, see AUM_GROUP_FLAG_* */
 	char sipdomain[120];			/*!< Should be AST_MAX_DOMAIN something */
 	char incoming_did[AST_MAX_EXTENSION];	/*!< Main DID for this group */
 	char language[MAX_LANGUAGE];		/*!< Default language for group */
 	char musicclass[MAX_MUSICCLASS];	/*!< Default musicclass for this group */
+	ast_group_t callgroup;			/*!< Calling group for calls */
+	ast_group_t pickupgroup;		/*!< Pickup group */
 	int managerperm;			/*!< This group's permissions in manager */
 	struct aum_user_contextlist contexts;	/*!< Linked list of contexts this group use */
 	struct ast_variable *chanvars;
 	char *description;			/*!< Description */
-	struct aum_user_grouplist members;
+	struct aum_user_grouplist members;	/*!< Members list */
 	char language[MAX_LANGUAGE];	/*!< Default language */
 	char registrar[20];		/*!< Who added this object? */
 };

Modified: team/oej/aum/include/asterisk/linkedlists.h
URL: http://svn.digium.com/view/asterisk/team/oej/aum/include/asterisk/linkedlists.h?rev=7388&r1=7387&r2=7388&view=diff
==============================================================================
--- team/oej/aum/include/asterisk/linkedlists.h (original)
+++ team/oej/aum/include/asterisk/linkedlists.h Wed Dec  7 21:24:27 2005
@@ -414,6 +414,27 @@
 	})
 
 /*!
+  \brief Removes and returns the tail entry from a list.
+  \param head This is a pointer to the list head structure
+  \param field This is the name of the field (declared using AST_LIST_ENTRY())
+  used to link entries of this list together.
+
+  Removes the tail entry from the list, and returns a pointer to it.
+  This macro is safe to call on an empty list.
+ */
+#define AST_LIST_REMOVE_TAIL(head, field) ({				\
+		typeof((head)->first) cur = (head)->last;		\
+		if (cur) {						\
+			(head)->last = cur->field.prev;		\
+			(head)->last->field.next = NULL;				\
+			if ((head)->first == cur)			\
+				(head)->first = NULL;			\
+		}							\
+		cur;							\
+	})
+
+
+/*!
   \brief Removes a specific entry from a list.
   \param head This is a pointer to the list head structure
   \param elm This is a pointer to the entry to be removed.

Modified: team/oej/aum/res/res_aum.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum/res/res_aum.c?rev=7388&r1=7387&r2=7388&view=diff
==============================================================================
--- team/oej/aum/res/res_aum.c (original)
+++ team/oej/aum/res/res_aum.c Wed Dec  7 21:24:27 2005
@@ -163,6 +163,21 @@
 	- Current user status can be changed through dialplan functions,
 	  manager or IM channels/gateways (Jabber, SIP, other)
 	- We need to synch status levels with other IM (SIMPLE/Jabber/XMPP)
+
+	\par Realtime usage
+	AUM uses ARA - the realtime architecture - to load users and groups.
+	The realtime handles for AUM is
+	- \b aumusers	For users
+	- \b aumgroups  For the realtime groups
+	
+	AUM will cache realtime users in memory after we load them.
+	Every time a realtime user is accessed, it's moved to top of
+	the cache. When we reach the maximum number of cached users,
+	AUM mwill delete from the bottom of the cache while adding the
+	missing user to the top.
+
+	The AUM cache size will be configurable in the general
+	section of aum.conf
 
 	\par Things to do
 	- Implement all core AUM api functions from aum.h
@@ -249,6 +264,16 @@
 	ASTOBJ_CONTAINER_COMPONENTS(struct aum_user);
 } aum_userlist;
 
+/*! \brief the realtime user cache */
+static struct aum_usercache_struct {
+	AST_LIST_ENTRY(aum_usercache) list;
+	struct aum_user *user;
+};
+
+static int aum_usercache_count = 0;
+static int aum_usercache_max = 50;
+static AST_LIST_HEAD_STATIC(aum_usercache_struct, aum_usercache);
+
 /*! brief Different config options for address formats */
 static struct aum_address_config_struct aum_address_config[] = {
 	{AUM_ADDR_EMAIL, 	"email", 	"E-mail",	AUM_CNF_ADDR_EMAIL},
@@ -329,6 +354,8 @@
 		ast_cli(fd, "  Users - realtime:      %-10.10d\n", aum_real_users);
 	if (aum_real_groups_enabled)
 		ast_cli(fd, "  Groups - realtime:     %-10.10d\n", aum_real_groups);
+	if (aum_real_users_enabled)
+		ast_cli(fd, "  Realtime cache:        %d objects (%-10.10d kb) \n", aum_usercache_count, (aum_usercache_count * (sizeof(struct aum_user) + sizeof(struct aum_usercache_struct)) / 1000 ) );
 	ast_cli(fd, "\n\n");
 	
 	return RESULT_SUCCESS;
@@ -344,18 +371,21 @@
 static int cli_aum_show_users(int fd, int argc, char *argv[])
 {
 	int numusers = 0;
+	int numgroups = 0;
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
-	int numgroups = 0;
 
 	if (argc != 3)
 		return RESULT_SHOWUSAGE;
 	
 	ASTOBJ_CONTAINER_TRAVERSE(&aum_userlist, 1, {
 		ASTOBJ_RDLOCK(iterator);
-		ast_cli(fd, " %-20.20s \n", iterator->name);
-		numusers ++;
+		if (!ast_test_flag(iterator, AST_USER_FLAG_REALTIME)) {
+			ast_cli(fd, " %-20.20s: %-10.10s %-15.15s %-10.10s %s\n", iterator->name, iterator->first_name, iterator->last_name, iterator->numuserid, ast_test_flag(iterator, AUM_USER_FLAG_DISABLED) ? "* DISABLED *" : "");
+	if (ast_test_flag(user, AUM_USER_FLAG_DISABLED))
+			numusers ++;
+		}
 		ASTOBJ_UNLOCK(iterator);
 	} );
 	ast_cli(fd, "-- Number of users: %d\n", numusers);
@@ -387,6 +417,21 @@
 		return RESULT_SUCCESS;
 	}
 	ast_cli(fd, "* Userid:        %s\n", user->name);
+
+	if (ast_test_flag(user, AUM_USER_FLAG_REALTIME))
+		ast_cli(fd, " Usertype:        Realtime (cached)\n");
+	else
+		ast_cli(fd, " Usertype:        Static\n");
+
+	if (ast_test_flag(user, AUM_USER_FLAG_DISABLED))
+		ast_cli(fd, " Status:          Disabled\n");
+	else
+		ast_cli(fd, " Status:          Enabled\n");
+
+	if (!ast_strlen_zero(user->title))
+		ast_cli(fd, " Title:          %s\n", user->title);
+	if (!ast_strlen_zero(user->last_name))
+		ast_cli(fd, " Name:          %s %s\n", user->first_name, user->last_name);
 	
 	AST_LIST_TRAVERSE(&user->groups, member, list) {
 		ast_cli(fd, " Member of : %s\n", member->group->name);
@@ -399,6 +444,11 @@
 	AST_LIST_TRAVERSE(&user->contexts, context, list) {
 		ast_cli(fd, " %s Context : %s\n", context_type2str(context->type), context->context);
 	};
+	ast_cli(fd, " Numeric ID :    %s\n", user->numuserid);
+	ast_cli(fd, " Secret :        %s\n", !ast_strlen_zero(user->secret) ? "<set>" : "<not set>");
+	ast_cli(fd, " Music class:    %s\n", user->musicclass);
+	ast_cli(fd, " Language:       %s\n", user->language);
+	ast_cli(fd, " Mailbox:        %s\n", user->mailbox);
 	
 	return RESULT_SUCCESS;
 }
@@ -675,6 +725,8 @@
 	{ AUM_CNF_DENY,		"deny" 		,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_NUMID,	"numericid" 	,AUM_CONFOBJ_USER },
 	{ AUM_CNF_SIPDOMAIN,	"sipdomain" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
+	{ AUM_CNF_CALLGROUP,	"callgroup" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
+	{ AUM_CNF_PICKUPGROUP,	"pickupgroup" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_GROUPVAR,	"changroup" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_GROUPDESC,	"description" 	,AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_TYPE,		"type" 		,AUM_CONFOBJ_GENERAL },
@@ -832,6 +884,81 @@
 	return newcontext;
 }
 
+
+/*! \brief Release all cached realtime users */
+static void aum_rtcache_freeall(void) {
+	struct aum_usercache_struct *temp;
+
+	AST_LIST_LOCK(aum_usercache);
+
+	if (!AST_LIST_EMPTY(&aum_usercache) ) {
+		AST_LIST_LOCK(&aum_usercache);
+		while ((temp = AST_LIST_REMOVE_HEAD(&aum_usercache, list)))
+			aum_destroy_user(temp->user);
+			free(temp);
+		AST_LIST_UNLOCK(&aum_usercache);
+	}
+}
+
+/*! \brief Add realtime user to top of the cache 
+	If the cache is full, the user at the bottom of the cache is
+	simply removed from memory
+	\param user AUM user to add to the top 
+*/
+static void aum_rtcache_add(struct aum_user *user) {
+	struct aum_usercache_struct *temp;
+	struct aum_usercache_struct *aums;
+
+	aums = aum_allocate(sizeof(aum_usercache_struct);
+	if (!aums)
+		return;		/* Allocation error */
+	
+	aums->user = user;
+	
+	/* Check whether we need to clean up before adding to list */
+	if (aum_usercache_count == aum_usercache_max) {
+		/* Remove user from cache and delete */
+		AST_LIST_LOCK(&aum_usercache);
+		temp = AST_LIST_REMOVE_TAIL(&aum_usercache, list);
+		AST_LIST_UNLOCK(&aum_usercache);
+		aum_destroy_user(temp->user);
+		free(temp);
+		aum_usercache_count--;
+	}
+
+	/* Move it into the list */
+	AST_LIST_LOCK(&aum_usercache);
+	AST_LIST_INSERT_HEAD(&aum_usercache, aums, list);
+	AST_LIST_UNLOCK(&aum_usercache);
+	aum_usercache_count++;
+
+	return;
+}
+
+/*! \brief Add realtime user to top of the cache 
+	Called when a user object is accessed
+*/
+static void aum_rtcache_movetotop(struct aum_user *user) {
+	struct aum_usercache_struct *temp;
+	struct aum_usercache_struct *top_of_the_class = (struct aum_usercache_struct) NULL;
+
+	/* Find user in cache */
+	AST_LIST_TRAVERSE_SAFE_BEGIN(aum_usercache, temp, list) {
+		if (temp->user == user) {
+			top_of_the_class = temp;
+			/* Remove from current position in list */
+			AST_LIST_LOCK(aum_usercache);
+			AST_LIST_REMOVE_CURRENT();
+		}
+	}
+	/* Add her to top */
+	if (top_of_the_class) {
+		AST_LIST_INSERT_HEAD(aum_usercache, top_of_the_class, list);
+		AST_LIST_UNLOCK(aum_usercache);
+	}
+
+	/* Return */
+}
 
 /*! \brief Parse configuration file and build AUM in-memory user
 
@@ -905,6 +1032,7 @@
 		case AUM_CNF_DEFCONTEXT:
 		case AUM_CNF_SUBSCRIBECONTEXT:
 		case AUM_CNF_DISACONTEXT:
+			break;
 			context = build_context(AUM_CONTEXT_NONE, option, x->value);
 			if (context)
 				AST_LIST_INSERT_TAIL(&user->contexts, context, list);
@@ -912,23 +1040,38 @@
 				ast_log(LOG_ERROR, "Context %s not added for user %s\n", x->value, username);
 			break;
 		case AUM_CNF_DEFEXTEN:
+			ast_copy_string(&user->default_exten, x->value, sizeof(&user->default_exten);
 			break;
 		case AUM_CNF_CID:
+			ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
 			break;
 		case AUM_CNF_CALLERPRES:
+			user->calling_pres = ast_parse_caller_presentation(v->value);
+			if (user->callingpres == -1)
+				user->calling_pres = atoi(v->value);
+				
 			break;
 		case AUM_CNF_TIMEZONE:
 			break;
+		case AUM_CNF_CALLGROUP:
+			user->callgroup = ast_get_group(v->value);
+			break;
+		case AUM_CNF_PICKUPGROUP:
+			user->pickupgroup = ast_get_group(v->value);
+			break;
 		case AUM_CNF_ACCOUNTCODE:
+			ast_copy_string(&user->accountcode, x->value, sizeof(&user->accountcode);
 			break;
 		case AUM_CNF_MANAGERACCESS:
 			break;
 		case AUM_CNF_SECRET:
+			ast_copy_string(&user->secret, x->value, sizeof(&user->secret);
 			break;
 		case AUM_CNF_PIN:
 			ast_copy_string(user->pincode, x->value, sizeof(user->pincode));
 			break;
 		case AUM_CNF_IAX2KEY:
+			ast_copy_string(user->pincode, x->value, sizeof(user->pincode));
 			break;
 		case AUM_CNF_MUSICCLASS:
 			ast_copy_string(user->musicclass, x->value, sizeof(user->musicclass));
@@ -947,22 +1090,36 @@
 		case AUM_CNF_SOUNDNAME:
 			break;
 		case AUM_CNF_CHANVAR:
+			/* Set peer channel variable */
+			varname = ast_strdupa(v->value);
+			if (varname && (varval = strchr(varname,'='))) {
+				struct ast_variable *tmpvar;
+				*varval = '\0';
+				varval++;
+				if ((tmpvar = ast_variable_new(varname, varval))) {
+					tmpvar->next = user->chanvars;
+					user->chanvars = tmpvar;
+				}
+			}
 			break;
 		case AUM_CNF_GROUPVAR:	/* Channel group to set */
+			// chanvars GROUP
 			break;
 		case AUM_CNF_PERMIT:
-			break;
 		case AUM_CNF_DENY:
+			// ACL
+			user->acl = ast_append_ha(v->name, v->value, user->acl);
 			break;
 		case AUM_CNF_NUMID:
+			ast_copy_string(user->numuserid, x->value, sizeof(user->numuserid));
+			break;
+		case AUM_CNF_DEBUG:	/* GENERAL setting only */
+			break;
+		case AUM_CNF_GROUPDESC:	/* Only for groups */
+			break;
+		case AUM_CNF_TYPE:	/* NO op */
 			break;
 		case AUM_CNF_SIPDOMAIN:
-			break;
-		case AUM_CNF_DEBUG:	/* GENERAL setting only */
-			break;
-		case AUM_CNF_GROUPDESC:	/* Only for groups */
-			break;
-		case AUM_CNF_TYPE:	/* NO op */
 			break;
 		case AUM_CNF_NOT_FOUND:
 			ast_log(LOG_NOTICE, "Configuration label unknown in AUM configuration: %s\n", x->name);
@@ -978,6 +1135,9 @@
 		x = x->next;
 	}
 	ASTOBJ_CONTAINER_LINK(&aum_userlist, user);
+	if (realtime) 
+		aum_realtime_cacheadd(user);
+
 	aum_static_users++;
 	//ASTOBJ_UNMARK(user);
 	ast_log(LOG_VERBOSE, "-- == Finished building user: %s\n", username);
@@ -1058,6 +1218,7 @@
 	if (group) {
 		ASTOBJ_CONTAINER_LINK(&aum_grouplist, group);
 		aum_real_groups++;
+		ast_set_flag(group, AUM_GROUP_FLAG_REALTIME);
 	}
 	ast_variables_destroy(var);
 	return group;
@@ -1069,8 +1230,7 @@
 	\param field name to match on
 	\param value the value of the field
 	
- */
-
+*/
 static struct aum_user *aum_user_realtime_loadbyfield(char *field, char *value)
 	struct aum_user *user = (struct aum_user *) NULL;
 	struct ast_variable *var;
@@ -1084,6 +1244,7 @@
 	if (user) {
 		ASTOBJ_CONTAINER_LINK(&aum_userlist, user);
 		aum_real_users++;
+		ast_set_flag(user, AUM_USER_FLAG_REALTIME);
 	}
 	ast_variables_destroy(var);
 	return user;
@@ -1143,6 +1304,9 @@
 			AST_LIST_UNLOCK(&user->groups);
 		}
 	};
+
+	if (ast_test_flag(user, AST_USER_FLAG_REALTIME))
+		aum_rtcache_movetotop(struct aum_user *user);
 }
 
 /*! \brief Destroy AUM group object */
@@ -1165,6 +1329,10 @@
 		AST_LIST_UNLOCK(&group->members);
 	}
 
+	/* clear channel variables */
+	if (group->chanvars) 
+		ast_variables_destroy(group->chanvars);
+
 	/* Release the group itself */
 	aum_free(group);
 }
@@ -1205,7 +1373,12 @@
 		AST_LIST_UNLOCK(&user->contexts);
 	}
 
-		
+	/* clear channel variables */
+	if (user->chanvars)
+		ast_variables_destroy(user->chanvars);
+
+	/* Clear the ACL */		
+	ast_free_ha(user->acl);
 
 	/* Release the user itself */
 	aum_free(user);
@@ -1317,7 +1490,7 @@
 	ast_config_destroy(cfg);
 
 	/* Done, tell the manager */
-	//manager_event(EVENT_FLAG_SYSTEM, "ChannelReload", "Channel: SIP\r\nReloadReason: %s\r\nRegistry_Count: %d\r\nPeer_Count: %d\r\nUser_Count: %d\r\n\r\n", modulereloadreason2txt(reason), registry_count, peer_count, user_count);
+	manager_event(EVENT_FLAG_SYSTEM, "ModuleReload", "Module: res_aum.so\r\nReloadReason: %s\r\nAUMUserCount: %d\r\nAUMGroupCount: %d\r\n\r\n\r\n", modulereloadreason2txt(reason), aum_static_users, aum_static_groups);
 
 	return 0;
 }
@@ -1434,10 +1607,14 @@
 {
 	struct aum_user *res;
 
+	/* Search among static and cached realtime users */
 	res = ASTOBJ_CONTAINER_FIND(&aum_userlist, userid);	
 	if (!res && aum_real_users_enabled) {
 		res = aum_user_realtime_load(username);
-	};
+	} else if (res && ast_test_flag(user, AST_USER_FLAG_REALTIME))
+		/* Move user to top of cache */
+		aum_rtcache_movetotop(struct aum_user *user);
+	}
 	return res;
 }
 
@@ -1475,6 +1652,7 @@
 {
 	initialize_charset_conversion();
 	reload_config(MODULE__LOAD);
+	aum_rtcache_freeall();
 
 	aum_real_groups_enabled = ast_check_realtime("aumgroups");
 	aum_real_users_enabled = ast_check_realtime("aumgroups");
@@ -1491,6 +1669,7 @@
 	/* Unregister apps, functions, manager actions, switches */
 	ast_cli_unregister_multiple(my_clis, sizeof(my_clis)/ sizeof(my_clis[0]));
 	ast_custom_function_unregister(&aum_user_function);
+	aum_rtcache_freeall();
 
 	/* Deallocate iconv conversion descriptors */
 	iconv_close(ichandler_utf8_to_iso88591);



More information about the svn-commits mailing list