]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fb-temp.c
CGI: make_out_args() handles undefs correctly.
[libucw.git] / lib / fb-temp.c
index aa1689c4f4259fd1618c7d7bd4b67790cf5a4319..65398c154eb7ef447d675f746f6c8a738126d9c5 100644 (file)
 #include "lib/fastbuf.h"
 #include "lib/threads.h"
 
+#include <stdio.h>
 #include <unistd.h>
 #include <sys/fcntl.h>
 
-static byte *temp_prefix = "/tmp/temp";
+static char *temp_prefix = "/tmp/temp";
 
 static struct cf_section temp_config = {
   CF_ITEMS {
@@ -30,26 +31,21 @@ static void CONSTRUCTOR temp_global_init(void)
 }
 
 void
-temp_file_name(byte *buf)
+temp_file_name(char *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 *
 bopen_tmp(uns buflen)
 {
-  byte buf[TEMP_FILE_NAME_LEN];
+  char buf[TEMP_FILE_NAME_LEN];
   struct fastbuf *f;
 
   temp_file_name(buf);