]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-temp.c
Don't forget to increase run counter.
[libucw.git] / lib / fb-temp.c
index aa1689c4f4259fd1618c7d7bd4b67790cf5a4319..4bcced6c4ecd56c5d3bac1064845807a09cd5917 100644 (file)
@@ -12,6 +12,7 @@
 #include "lib/fastbuf.h"
 #include "lib/threads.h"
 
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/fcntl.h>
 
@@ -32,18 +33,13 @@ static void CONSTRUCTOR temp_global_init(void)
 void
 temp_file_name(byte *buf)
 {
-  int cnt = ++ucwlib_thread_context()->temp_counter;
+  struct ucwlib_context *ctx = ucwlib_thread_context();
+  int cnt = ++ctx->temp_counter;
   int pid = getpid();
-#if 0
-  /* FIXME: This is Linux-specific and not declared anywhere :( */
-  int tid = gettid();
-#else
-  int tid = pid;
-#endif
-  if (pid == tid)
+  if (ctx->thread_id == pid)
     sprintf(buf, "%s%d-%d", temp_prefix, pid, cnt);
   else
-    sprintf(buf, "%s%d-%d-%d", temp_prefix, pid, tid, cnt);
+    sprintf(buf, "%s%d-%d-%d", temp_prefix, pid, ctx->thread_id, cnt);
 }
 
 struct fastbuf *