[asterisk-commits] mjordan: branch mjordan/12-cdr-parking r399774 - in /team/mjordan/12-cdr-park...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Sep 25 09:00:08 CDT 2013


Author: mjordan
Date: Wed Sep 25 09:00:06 2013
New Revision: 399774

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399774
Log:
Prevent CDR module unloading when records are in flight

I wonder what this will do to the failing tests.

Modified:
    team/mjordan/12-cdr-parking/cdr/cdr_adaptive_odbc.c
    team/mjordan/12-cdr-parking/cdr/cdr_csv.c
    team/mjordan/12-cdr-parking/cdr/cdr_custom.c
    team/mjordan/12-cdr-parking/cdr/cdr_manager.c
    team/mjordan/12-cdr-parking/cdr/cdr_odbc.c
    team/mjordan/12-cdr-parking/cdr/cdr_pgsql.c
    team/mjordan/12-cdr-parking/cdr/cdr_radius.c
    team/mjordan/12-cdr-parking/cdr/cdr_sqlite.c
    team/mjordan/12-cdr-parking/cdr/cdr_sqlite3_custom.c
    team/mjordan/12-cdr-parking/cdr/cdr_syslog.c
    team/mjordan/12-cdr-parking/cdr/cdr_tds.c
    team/mjordan/12-cdr-parking/include/asterisk/cdr.h
    team/mjordan/12-cdr-parking/main/cdr.c

Modified: team/mjordan/12-cdr-parking/cdr/cdr_adaptive_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_adaptive_odbc.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_adaptive_odbc.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_adaptive_odbc.c Wed Sep 25 09:00:06 2013
@@ -759,7 +759,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	if (AST_RWLIST_WRLOCK(&odbc_tables)) {
 		ast_cdr_register(name, ast_module_info->description, odbc_log);
 		ast_log(LOG_ERROR, "Unable to lock column list.  Unload failed.\n");

Modified: team/mjordan/12-cdr-parking/cdr/cdr_csv.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_csv.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_csv.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_csv.c Wed Sep 25 09:00:06 2013
@@ -315,7 +315,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	loaded = 0;
 	return 0;
 }

Modified: team/mjordan/12-cdr-parking/cdr/cdr_custom.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_custom.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_custom.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_custom.c Wed Sep 25 09:00:06 2013
@@ -184,7 +184,9 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
 
 	if (AST_RWLIST_WRLOCK(&sinks)) {
 		ast_cdr_register(name, ast_module_info->description, custom_log);

Modified: team/mjordan/12-cdr-parking/cdr/cdr_manager.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_manager.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_manager.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_manager.c Wed Sep 25 09:00:06 2013
@@ -210,7 +210,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	if (customfields)
 		ast_free(customfields);
 

Modified: team/mjordan/12-cdr-parking/cdr/cdr_odbc.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_odbc.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_odbc.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_odbc.c Wed Sep 25 09:00:06 2013
@@ -283,7 +283,9 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
 
 	if (dsn) {
 		ast_verb(11, "cdr_odbc: free dsn\n");

Modified: team/mjordan/12-cdr-parking/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_pgsql.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_pgsql.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_pgsql.c Wed Sep 25 09:00:06 2013
@@ -436,7 +436,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	ast_cli_unregister_multiple(cdr_pgsql_status_cli, ARRAY_LEN(cdr_pgsql_status_cli));
 
 	PQfinish(conn);

Modified: team/mjordan/12-cdr-parking/cdr/cdr_radius.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_radius.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_radius.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_radius.c Wed Sep 25 09:00:06 2013
@@ -230,7 +230,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	if (rh) {
 		rc_destroy(rh);
 		rh = NULL;

Modified: team/mjordan/12-cdr-parking/cdr/cdr_sqlite.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_sqlite.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_sqlite.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_sqlite.c Wed Sep 25 09:00:06 2013
@@ -191,7 +191,10 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	if (db) {
 		sqlite_close(db);
 	}

Modified: team/mjordan/12-cdr-parking/cdr/cdr_sqlite3_custom.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_sqlite3_custom.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_sqlite3_custom.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_sqlite3_custom.c Wed Sep 25 09:00:06 2013
@@ -289,7 +289,9 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
 
 	free_config(0);
 

Modified: team/mjordan/12-cdr-parking/cdr/cdr_syslog.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_syslog.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_syslog.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_syslog.c Wed Sep 25 09:00:06 2013
@@ -235,7 +235,9 @@
 
 static int unload_module(void)
 {
-	ast_cdr_unregister(name);
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
 
 	if (AST_RWLIST_WRLOCK(&sinks)) {
 		ast_cdr_register(name, ast_module_info->description, syslog_log);

Modified: team/mjordan/12-cdr-parking/cdr/cdr_tds.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/cdr/cdr_tds.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/cdr/cdr_tds.c (original)
+++ team/mjordan/12-cdr-parking/cdr/cdr_tds.c Wed Sep 25 09:00:06 2013
@@ -443,6 +443,10 @@
 
 static int tds_unload_module(void)
 {
+	if (ast_cdr_unregister(name)) {
+		return -1;
+	}
+
 	if (settings) {
 		ast_mutex_lock(&tds_lock);
 		mssql_disconnect();
@@ -451,8 +455,6 @@
 		ast_string_field_free_memory(settings);
 		ast_free(settings);
 	}
-
-	ast_cdr_unregister(name);
 
 	dbexit();
 

Modified: team/mjordan/12-cdr-parking/include/asterisk/cdr.h
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/include/asterisk/cdr.h?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/include/asterisk/cdr.h (original)
+++ team/mjordan/12-cdr-parking/include/asterisk/cdr.h Wed Sep 25 09:00:06 2013
@@ -503,8 +503,11 @@
  * \brief Unregister a CDR handling engine
  * \param name name of CDR handler to unregister
  * Unregisters a CDR by it's name
- */
-void ast_cdr_unregister(const char *name);
+ *
+ * \retval 0 The backend unregistered successfully
+ * \retval 1 The backend could not be unregistered at this time
+ */
+int ast_cdr_unregister(const char *name);
 
 /*!
  * \brief Disposition to a string

Modified: team/mjordan/12-cdr-parking/main/cdr.c
URL: http://svnview.digium.com/svn/asterisk/team/mjordan/12-cdr-parking/main/cdr.c?view=diff&rev=399774&r1=399773&r2=399774
==============================================================================
--- team/mjordan/12-cdr-parking/main/cdr.c (original)
+++ team/mjordan/12-cdr-parking/main/cdr.c Wed Sep 25 09:00:06 2013
@@ -2603,9 +2603,20 @@
 	return 0;
 }
 
-void ast_cdr_unregister(const char *name)
+int ast_cdr_unregister(const char *name)
 {
 	struct cdr_beitem *i = NULL;
+	int active_count;
+
+	ao2_lock(active_cdrs_by_channel);
+	active_count = ao2_container_count(active_cdrs_by_channel);
+	ao2_unlock(active_cdrs_by_channel);
+
+	if (active_count != 0) {
+		ast_log(AST_LOG_WARNING, "Unable to unregister CDR backend %s; %d CDRs are still active\n",
+			name, active_count);
+		return 1;
+	}
 
 	AST_RWLIST_WRLOCK(&be_list);
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&be_list, i, list) {
@@ -2621,6 +2632,7 @@
 		ast_verb(2, "Unregistered '%s' CDR backend\n", name);
 		ast_free(i);
 	}
+	return 0;
 }
 
 struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)




More information about the asterisk-commits mailing list