pthread_mutex_init(&ucwlib_master_mutex, NULL);
}
+static int
+ucwlib_tid(void)
+{
+ static tid_counter;
+
+ ucwlib_lock();
+ int tid = ++tid_counter;
+ ucwlib_unlock();
+ return tid;
+}
+
struct ucwlib_context *
ucwlib_thread_context(void)
{
if (!c)
{
c = xmalloc_zero(sizeof(*c));
+ c->thread_id = ucwlib_tid();
pthread_setspecific(ucwlib_context_key, c);
}
return c;
{
ucwlib_lock();
ucwlib_unlock();
- ucwlib_thread_context();
+ log(L_INFO, "tid=%d", ucwlib_thread_context()->thread_id);
return 0;
}
/* This structure holds per-thread data */
struct ucwlib_context {
+ int thread_id; // Thread ID (either kernel tid or a counter)
int temp_counter; // Counter for fb-temp.c
struct asio_queue *io_queue; // Async I/O queue for fb-direct.c
sh_sighandler_t *signal_handlers; // Signal handlers for sighandler.c