]> git.ozlabs.org Git - ccan/blobdiff - tools/tools.c
tdb: fix lock-tracking test code after gradual lock changes.
[ccan] / tools / tools.c
index 8ce193cd226bd0905f7a6738c4f70eda4057fe1c..eacfbf9c8d353ac89bb7e782b19d379e0aefd1a1 100644 (file)
@@ -63,10 +63,8 @@ static void killme(int sig)
        kill(-getpid(), SIGKILL);
 }
 
-static char *run_with_timeout(const void *ctx,
-                             const char *cmd,
-                             bool *ok,
-                             unsigned *timeout_ms)
+char *run_with_timeout(const void *ctx, const char *cmd,
+                      bool *ok, unsigned *timeout_ms)
 {
        pid_t pid;
        int p[2];
@@ -174,7 +172,7 @@ static int unlink_all(char *dir)
        return 0;
 }
 
-char *temp_file(const void *ctx, const char *extension)
+char *temp_dir(const void *ctx)
 {
        /* For first call, create dir. */
        while (!tmpdir) {
@@ -194,8 +192,13 @@ char *temp_file(const void *ctx, const char *extension)
                }
                talloc_set_destructor(tmpdir, unlink_all);
        }
+       return tmpdir;
+}
 
-       return talloc_asprintf(ctx, "%s/%u%s", tmpdir, count++, extension);
+char *temp_file(const void *ctx, const char *extension)
+{
+       return talloc_asprintf(ctx, "%s/%u%s",
+                              temp_dir(ctx), count++, extension);
 }
 
 char *maybe_temp_file(const void *ctx, const char *extension, bool keep,