Remove unnecessary usleep() from a couple of module unload callbacks.
authorRussell Bryant <russell@russellbryant.com>
Sat, 20 Jun 2009 14:09:40 +0000 (14:09 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sat, 20 Jun 2009 14:09:40 +0000 (14:09 +0000)
In passing, also tweak cdr_unregister() to hold the list lock a bit less time.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@202109 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr/cdr_adaptive_odbc.c
cdr/cdr_pgsql.c
main/cdr.c

index 205c207..1d31991 100644 (file)
@@ -663,7 +663,6 @@ early_release:
 static int unload_module(void)
 {
        ast_cdr_unregister(name);
-       usleep(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");
index 5e8e486..75fb0f8 100644 (file)
@@ -331,10 +331,9 @@ static int pgsql_log(struct ast_cdr *cdr)
 static int unload_module(void)
 {
        struct columns *current;
+
        ast_cdr_unregister(name);
 
-       /* Give all threads time to finish */
-       usleep(1);
        PQfinish(conn);
 
        if (pghostname)
index 3f7b9ae..610c2ab 100644 (file)
@@ -148,13 +148,16 @@ void ast_cdr_unregister(const char *name)
        AST_RWLIST_TRAVERSE_SAFE_BEGIN(&be_list, i, list) {
                if (!strcasecmp(name, i->name)) {
                        AST_RWLIST_REMOVE_CURRENT(list);
-                       ast_verb(2, "Unregistered '%s' CDR backend\n", name);
-                       ast_free(i);
                        break;
                }
        }
        AST_RWLIST_TRAVERSE_SAFE_END;
        AST_RWLIST_UNLOCK(&be_list);
+
+       if (i) {
+               ast_verb(2, "Unregistered '%s' CDR backend\n", name);
+               ast_free(i);
+       }
 }
 
 int ast_cdr_isset_unanswered(void)