[asterisk-commits] seanbright: branch seanbright/NoLossCDR-Redux r104065 - in /team/seanbright/N...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Feb 23 13:46:37 CST 2008


Author: seanbright
Date: Sat Feb 23 13:46:36 2008
New Revision: 104065

URL: http://svn.digium.com/view/asterisk?view=rev&rev=104065
Log:
Add a new argument to ast_cdr_register that allows the caller to pass a function
pointer to a cleanup routine to be called when the sink is unregistered later.
Also updated all the CDR modules to pass NULL for that argument for now.

Not entirely sure why res_config_sqlite is registering a CDR handler (there is
also a cdr_sqlite module) but we'll figure that out later.

Modified:
    team/seanbright/NoLossCDR-Redux/cdr/cdr_adaptive_odbc.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_csv.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_custom.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_manager.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_odbc.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_pgsql.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_radius.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite3_custom.c
    team/seanbright/NoLossCDR-Redux/cdr/cdr_tds.c
    team/seanbright/NoLossCDR-Redux/include/asterisk/cdr.h
    team/seanbright/NoLossCDR-Redux/main/cdr.c
    team/seanbright/NoLossCDR-Redux/res/res_config_sqlite.c

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_adaptive_odbc.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_adaptive_odbc.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_adaptive_odbc.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_adaptive_odbc.c Sat Feb 23 13:46:36 2008
@@ -630,7 +630,7 @@
 	ast_cdr_unregister(name);
 	usleep(1);
 	if (AST_RWLIST_WRLOCK(&odbc_tables)) {
-		ast_cdr_register(name, ast_module_info->description, odbc_log);
+		ast_cdr_register(name, ast_module_info->description, odbc_log, NULL);
 		ast_log(LOG_ERROR, "Unable to lock column list.  Unload failed.\n");
 		return -1;
 	}
@@ -649,7 +649,7 @@
 
 	load_config();
 	AST_RWLIST_UNLOCK(&odbc_tables);
-	ast_cdr_register(name, ast_module_info->description, odbc_log);
+	ast_cdr_register(name, ast_module_info->description, odbc_log, NULL);
 	return 0;
 }
 

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_csv.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_csv.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_csv.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_csv.c Sat Feb 23 13:46:36 2008
@@ -326,7 +326,7 @@
 	if(!load_config(0))
 		return AST_MODULE_LOAD_DECLINE;
 
-	if ((res = ast_cdr_register(name, ast_module_info->description, csv_log)))
+	if ((res = ast_cdr_register(name, ast_module_info->description, csv_log, NULL)))
 		ast_log(LOG_ERROR, "Unable to register CSV CDR handling\n");
 
 	return res;

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_custom.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_custom.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_custom.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_custom.c Sat Feb 23 13:46:36 2008
@@ -146,7 +146,7 @@
 	int res = 0;
 
 	if (!load_config(0)) {
-		res = ast_cdr_register(name, ast_module_info->description, custom_log);
+		res = ast_cdr_register(name, ast_module_info->description, custom_log, NULL);
 		if (res)
 			ast_log(LOG_ERROR, "Unable to register custom CDR handling\n");
 		if (mf)

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_manager.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_manager.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_manager.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_manager.c Sat Feb 23 13:46:36 2008
@@ -109,7 +109,7 @@
 	if (enablecdr && !newenablecdr)
 		ast_cdr_unregister(name);
 	else if (!enablecdr && newenablecdr)
-		ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
+		ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log, NULL);
 	enablecdr = newenablecdr;
 
 	return 1;

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_odbc.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_odbc.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_odbc.c Sat Feb 23 13:46:36 2008
@@ -220,7 +220,7 @@
 		ast_verb(3, "cdr_odbc: dsn is %s\n", dsn);
 		ast_verb(3, "cdr_odbc: table is %s\n", table);
 
-		res = ast_cdr_register(name, ast_module_info->description, odbc_log);
+		res = ast_cdr_register(name, ast_module_info->description, odbc_log, NULL);
 		if (res) {
 			ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
 		}

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_pgsql.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_pgsql.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_pgsql.c Sat Feb 23 13:46:36 2008
@@ -315,7 +315,7 @@
 
 	ast_config_destroy(cfg);
 
-	return ast_cdr_register(name, ast_module_info->description, pgsql_log);
+	return ast_cdr_register(name, ast_module_info->description, pgsql_log, NULL);
 }
 
 static int load_module(void)

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_radius.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_radius.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_radius.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_radius.c Sat Feb 23 13:46:36 2008
@@ -253,7 +253,7 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	
-	res = ast_cdr_register(name, desc, radius_log);
+	res = ast_cdr_register(name, desc, radius_log, NULL);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite.c Sat Feb 23 13:46:36 2008
@@ -198,7 +198,7 @@
 		/* TODO: here we should probably create an index */
 	}
 	
-	res = ast_cdr_register(name, ast_module_info->description, sqlite_log);
+	res = ast_cdr_register(name, ast_module_info->description, sqlite_log, NULL);
 	if (res) {
 		ast_log(LOG_ERROR, "Unable to register SQLite CDR handling\n");
 		return -1;

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite3_custom.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite3_custom.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite3_custom.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_sqlite3_custom.c Sat Feb 23 13:46:36 2008
@@ -307,7 +307,7 @@
 	char *sql;
 
 	if (!load_config(0)) {
-		res = ast_cdr_register(name, desc, sqlite3_log);
+		res = ast_cdr_register(name, desc, sqlite3_log, NULL);
 		if (res) {
 			ast_log(LOG_ERROR, "Unable to register custom SQLite3 CDR handling\n");
 			free_config();

Modified: team/seanbright/NoLossCDR-Redux/cdr/cdr_tds.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/cdr/cdr_tds.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/cdr/cdr_tds.c (original)
+++ team/seanbright/NoLossCDR-Redux/cdr/cdr_tds.c Sat Feb 23 13:46:36 2008
@@ -515,7 +515,7 @@
 {
 	if (!tds_load_module(0))
 		return AST_MODULE_LOAD_DECLINE;
-	ast_cdr_register(name, ast_module_info->description, tds_log);
+	ast_cdr_register(name, ast_module_info->description, tds_log, NULL);
 	return AST_MODULE_LOAD_SUCCESS;
 }
 

Modified: team/seanbright/NoLossCDR-Redux/include/asterisk/cdr.h
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/include/asterisk/cdr.h?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/include/asterisk/cdr.h (original)
+++ team/seanbright/NoLossCDR-Redux/include/asterisk/cdr.h Sat Feb 23 13:46:36 2008
@@ -168,7 +168,7 @@
  * \retval 0 on success.
  * \retval -1 on error
  */
-int ast_cdr_register(const char *name, const char *desc, ast_cdr_backend_func backend_func);
+int ast_cdr_register(const char *name, const char *desc, ast_cdr_backend_func backend_func, ast_cdr_backend_cleanup_func cleanup_func);
 
 /*! 
  * \brief Unregister a CDR handling engine 

Modified: team/seanbright/NoLossCDR-Redux/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/main/cdr.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/main/cdr.c (original)
+++ team/seanbright/NoLossCDR-Redux/main/cdr.c Sat Feb 23 13:46:36 2008
@@ -122,7 +122,7 @@
 /*! Register a CDR driver. Each registered CDR driver generates a CDR 
 	\return 0 on success, -1 on failure 
 */
-int ast_cdr_register(const char *name, const char *desc, ast_cdr_backend_func backend_func)
+int ast_cdr_register(const char *name, const char *desc, ast_cdr_backend_func backend_func, ast_cdr_backend_cleanup_func cleanup_func)
 {
 	struct ast_cdr_backend *backend = NULL;
 
@@ -149,7 +149,7 @@
 	}
 
 	backend->write_cdr = backend_func;
-	backend->cleanup = NULL;
+	backend->cleanup = cleanup_func;
 
 	ast_copy_string(backend->name, name, sizeof(backend->name));
 	ast_copy_string(backend->desc, desc, sizeof(backend->desc));
@@ -193,6 +193,9 @@
 			struct ast_cdr_backend_sink *sink = NULL;
 			AST_LIST_TRAVERSE_SAFE_BEGIN(&backend->sinks, sink, list) {
 				AST_RWLIST_REMOVE_CURRENT(list);
+				/* If this backend provides a cleanup routine, call it for this sink */
+				if (backend->cleanup)
+					backend->cleanup(sink->configuration);
 				ast_verb(2, "Unregistered sink '%s' for CDR backend '%s'\n", sink->name, backend->name);
 				ast_free(sink);
 			}

Modified: team/seanbright/NoLossCDR-Redux/res/res_config_sqlite.c
URL: http://svn.digium.com/view/asterisk/team/seanbright/NoLossCDR-Redux/res/res_config_sqlite.c?view=diff&rev=104065&r1=104064&r2=104065
==============================================================================
--- team/seanbright/NoLossCDR-Redux/res/res_config_sqlite.c (original)
+++ team/seanbright/NoLossCDR-Redux/res/res_config_sqlite.c Sat Feb 23 13:46:36 2008
@@ -1506,7 +1506,7 @@
 			}
 		}
 
-		error = ast_cdr_register(RES_CONFIG_SQLITE_NAME, RES_CONFIG_SQLITE_DESCRIPTION, cdr_handler);
+		error = ast_cdr_register(RES_CONFIG_SQLITE_NAME, RES_CONFIG_SQLITE_DESCRIPTION, cdr_handler, NULL);
 
 		if (error) {
 			unload_module();




More information about the asterisk-commits mailing list