ddebug: use an atomic increment when numbering files
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 22 Oct 2017 15:38:58 +0000 (17:38 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 9 Nov 2017 13:01:03 +0000 (14:01 +0100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/ddebug/dd_util.h

index cfc0fb0ccce0f5d7b14c22caae553131b972895d..bdfb7cc91638346cfdd07675f5f6d905d9fed1ef 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "c99_alloca.h"
 #include "os/os_process.h"
+#include "util/u_atomic.h"
 #include "util/u_debug.h"
 
 /* name of the directory in home */
@@ -56,7 +57,8 @@ dd_get_debug_filename_and_mkdir(char *buf, size_t buflen, bool verbose)
    if (mkdir(dir, 0774) && errno != EEXIST)
       fprintf(stderr, "dd: can't create a directory (%i)\n", errno);
 
-   snprintf(buf, buflen, "%s/%s_%u_%08u", dir, proc_name, getpid(), index++);
+   snprintf(buf, buflen, "%s/%s_%u_%08u", dir, proc_name, getpid(),
+            p_atomic_inc_return(&index) - 1);
 
    if (verbose)
       fprintf(stderr, "dd: dumping to file %s\n", buf);