use ast_atomic_fetchadd_int for incrementing resultcount
authorRussell Bryant <russell@russellbryant.com>
Tue, 21 Aug 2007 21:58:29 +0000 (21:58 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 21 Aug 2007 21:58:29 +0000 (21:58 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@80226 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_odbc.c

index ee80fcc..f9272fe 100644 (file)
@@ -94,7 +94,6 @@ struct odbc_datastore {
 AST_LIST_HEAD_STATIC(queries, acf_odbc_query);
 
 static int resultcount = 0;
-AST_MUTEX_DEFINE_STATIC(resultlock);
 
 static void odbc_datastore_free(void *data)
 {
@@ -448,9 +447,7 @@ end_acf_read:
        if (resultset) {
                int uid;
                struct ast_datastore *odbc_store;
-               ast_mutex_lock(&resultlock);
-               uid = ++resultcount;
-               ast_mutex_unlock(&resultlock);
+               uid = ast_atomic_fetchadd_int(&resultcount, +1) + 1;
                snprintf(buf, len, "%d", uid);
                odbc_store = ast_channel_datastore_alloc(&odbc_info, buf);
                if (!odbc_store) {