From: Martin Mares Date: Sat, 9 Dec 2006 20:57:04 +0000 (+0100) Subject: Converted the fb-temp module to use threads.h. X-Git-Tag: holmes-import~506^2~13^2~205 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=7fe965a79e531deeedc3bd8b978edf198e780105;p=libucw.git Converted the fb-temp module to use threads.h. --- diff --git a/lib/fb-temp.c b/lib/fb-temp.c index ed7623ff..aa1689c4 100644 --- a/lib/fb-temp.c +++ b/lib/fb-temp.c @@ -10,6 +10,7 @@ #include "lib/lib.h" #include "lib/conf.h" #include "lib/fastbuf.h" +#include "lib/threads.h" #include #include @@ -28,25 +29,10 @@ static void CONSTRUCTOR temp_global_init(void) cf_declare_section("Tempfiles", &temp_config, 0); } -#ifdef CONFIG_UCW_THREADS -#include - -static pthread_key_t temp_counter_key; - -static void CONSTRUCTOR -temp_key_init(void) -{ - if (pthread_key_create(&temp_counter_key, NULL) < 0) - die("Cannot create fbdir_queue_key: %m"); -} - void temp_file_name(byte *buf) { - int cnt = (int) pthread_getspecific(temp_counter_key); - cnt++; - pthread_setspecific(temp_counter_key, (void *) cnt); - + int cnt = ++ucwlib_thread_context()->temp_counter; int pid = getpid(); #if 0 /* FIXME: This is Linux-specific and not declared anywhere :( */ @@ -60,17 +46,6 @@ temp_file_name(byte *buf) sprintf(buf, "%s%d-%d-%d", temp_prefix, pid, tid, cnt); } -#else - -void -temp_file_name(byte *buf) -{ - static int cnt; - sprintf(buf, "%s%d-%d", temp_prefix, (int)getpid(), cnt++); -} - -#endif - struct fastbuf * bopen_tmp(uns buflen) {