[svn-commits] mvanbaak: branch group/res_clialiases r150732 - in /team/group/res_clialiases...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Oct 17 16:56:14 CDT 2008


Author: mvanbaak
Date: Fri Oct 17 16:56:14 2008
New Revision: 150732

URL: http://svn.digium.com/view/asterisk?view=rev&rev=150732
Log:
- no need to use RW locked lists in the ast_register_atstarted functions
- change names from ast_register_atstarted to ast_register_atstart
- remove trailing whitespaces
- add braces where needed according to whitespases

Thanks to russell and seanbright for their review of this
patch on the new-yet-in-beta-like-all-google-stuf reviewboard ;)

Modified:
    team/group/res_clialiases/include/asterisk.h
    team/group/res_clialiases/main/asterisk.c
    team/group/res_clialiases/res/res_clialiases.c

Modified: team/group/res_clialiases/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/include/asterisk.h?view=diff&rev=150732&r1=150731&r2=150732
==============================================================================
--- team/group/res_clialiases/include/asterisk.h (original)
+++ team/group/res_clialiases/include/asterisk.h Fri Oct 17 16:56:14 2008
@@ -66,14 +66,17 @@
  *
  * \retval 0 on success.
  * \retval -1 on error.
- */
-int ast_register_atstarted(void (*func)(void));
-
-/*!   
+ *
+ * This function is called after all modules are loaded and the core initialization
+ * is done. It's run just before the core logs 'Asterisk Ready' on the console.
+ */
+int ast_register_atstart(void (*func)(void));
+
+/*!
  * \brief Unregister a function registered with ast_register_atstarted().
- * \param func The callback function to unregister.   
- */
-void ast_unregister_atstarted(void (*func)(void));
+ * \param func The callback function to unregister.
+ */
+void ast_unregister_atstart(void (*func)(void));
 
 #if !defined(LOW_MEMORY)
 /*!

Modified: team/group/res_clialiases/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/main/asterisk.c?view=diff&rev=150732&r1=150731&r2=150732
==============================================================================
--- team/group/res_clialiases/main/asterisk.c (original)
+++ team/group/res_clialiases/main/asterisk.c Fri Oct 17 16:56:14 2008
@@ -184,12 +184,12 @@
 
 static AST_RWLIST_HEAD_STATIC(atexits, ast_atexit);
 
-struct ast_atstarted {
+struct ast_atstart {
 	void (*func)(void);
-	AST_RWLIST_ENTRY(ast_atstarted) list;
+	AST_LIST_ENTRY(ast_atstart) list;
 };
 
-static AST_RWLIST_HEAD_STATIC(atstarteds, ast_atstarted);
+static AST_LIST_HEAD_STATIC(atstarts, ast_atstart);
 
 struct timeval ast_startuptime;
 struct timeval ast_lastreloadtime;
@@ -811,40 +811,42 @@
 		free(ae);
 }
 
-int ast_register_atstarted(void (*func)(void))
-{
-	struct ast_atstarted *ae;
-
-	if (!(ae = ast_calloc(1, sizeof(*ae))))
+int ast_register_atstart(void (*func)(void))
+{
+	struct ast_atstart *ae;
+
+	if (!(ae = ast_calloc(1, sizeof(*ae)))) {
 		return -1;
+	}
 
 	ae->func = func;
 
-	ast_unregister_atstarted(func);	
-
-	AST_RWLIST_WRLOCK(&atstarteds);
-	AST_RWLIST_INSERT_HEAD(&atstarteds, ae, list);
-	AST_RWLIST_UNLOCK(&atstarteds);
+	ast_unregister_atstart(func);
+
+	AST_LIST_LOCK(&atstarts);
+	AST_LIST_INSERT_HEAD(&atstarts, ae, list);
+	AST_LIST_UNLOCK(&atstarts);
 
 	return 0;
 }
 
-void ast_unregister_atstarted(void (*func)(void))
-{
-	struct ast_atstarted *ae = NULL;
-
-	AST_RWLIST_WRLOCK(&atstarteds);
-	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&atstarteds, ae, list) {
+void ast_unregister_atstart(void (*func)(void))
+{
+	struct ast_atstart *ae = NULL;
+
+	AST_LIST_LOCK(&atstarts);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&atstarts, ae, list) {
 		if (ae->func == func) {
-			AST_RWLIST_REMOVE_CURRENT(list);
-			break;
-		}
-	}
-	AST_RWLIST_TRAVERSE_SAFE_END;
-	AST_RWLIST_UNLOCK(&atstarteds);
-
-	if (ae)
-		free(ae);
+			AST_LIST_REMOVE_CURRENT(list);
+			break;
+		}
+	}
+	AST_LIST_TRAVERSE_SAFE_END;
+	AST_LIST_UNLOCK(&atstarts);
+
+	if (ae) {
+		ast_free(ae);
+	}
 }
 
 /* Sending commands from consoles back to the daemon requires a terminating NULL */
@@ -1369,15 +1371,16 @@
 	AST_RWLIST_UNLOCK(&atexits);
 }
 
-static void ast_run_atstarteds(void)
-{
-	struct ast_atstarted *ae;
-	AST_RWLIST_RDLOCK(&atstarteds);
-	AST_RWLIST_TRAVERSE(&atstarteds, ae, list) {
-		if (ae->func) 
+static void ast_run_atstarts(void)
+{
+	struct ast_atstart *ae;
+	AST_LIST_LOCK(&atstarts);
+	AST_LIST_TRAVERSE(&atstarts, ae, list) {
+		if (ae->func) {
 			ae->func();
-	}
-	AST_RWLIST_UNLOCK(&atstarteds);
+		}
+	}
+	AST_LIST_UNLOCK(&atstarts);
 }
 
 static void quit_handler(int num, int niceness, int safeshutdown, int restart)
@@ -3389,7 +3392,7 @@
 	dnsmgr_start_refresh();
 
 	/* run commands for post startup */
-	ast_run_atstarteds();
+	ast_run_atstarts();
 
 	/* We might have the option of showing a console, but for now just
 	   do nothing... */

Modified: team/group/res_clialiases/res/res_clialiases.c
URL: http://svn.digium.com/view/asterisk/team/group/res_clialiases/res/res_clialiases.c?view=diff&rev=150732&r1=150731&r2=150732
==============================================================================
--- team/group/res_clialiases/res/res_clialiases.c (original)
+++ team/group/res_clialiases/res/res_clialiases.c Fri Oct 17 16:56:14 2008
@@ -282,7 +282,7 @@
 	load_config(0);
 
 	ast_cli_register_multiple(cli_alias, sizeof(cli_alias) / sizeof(struct ast_cli_entry));
-	ast_register_atstarted(clialiases_atloaded);
+	ast_register_atstart(clialiases_atloaded);
 
 	return AST_MODULE_LOAD_SUCCESS;
 }




More information about the svn-commits mailing list