use atomic instructions to update the inuse counters
authorLuigi Rizzo <rizzo@icir.org>
Thu, 16 Nov 2006 14:41:28 +0000 (14:41 +0000)
committerLuigi Rizzo <rizzo@icir.org>
Thu, 16 Nov 2006 14:41:28 +0000 (14:41 +0000)
for CLI entriesC. The lock is not protecting this field.

I wonder if the field should be declared 'volatile' as well.

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

main/cli.c

index 2dc6afa..c5fe8b3 100644 (file)
@@ -1640,7 +1640,7 @@ int ast_cli_command(int fd, const char *s)
                AST_LIST_LOCK(&helpers);
                e = find_cli(args + 1, 0);
                if (e)
-                       e->inuse++;
+                       ast_atomic_fetchadd_int(&e->inuse, 1);
                AST_LIST_UNLOCK(&helpers);
                if (e) {
                        int res;