mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-28 08:20:59 -04:00
[db] Add thread name/id to db wait unlock
This commit is contained in:
parent
5fec4bbe34
commit
5acf9dd336
6
src/db.c
6
src/db.c
@ -102,6 +102,7 @@ enum fixup_type {
|
||||
};
|
||||
|
||||
struct db_unlock {
|
||||
char thread_name_tid[32];
|
||||
int proceed;
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t lck;
|
||||
@ -1446,6 +1447,7 @@ unlock_notify_cb(void **args, int nargs)
|
||||
{
|
||||
u = (struct db_unlock *)args[i];
|
||||
|
||||
DPRINTF(E_DBG, L_DB, "Notify DB unlock, thread: %s\n", u->thread_name_tid);
|
||||
CHECK_ERR(L_DB, pthread_mutex_lock(&u->lck));
|
||||
|
||||
u->proceed = 1;
|
||||
@ -1461,6 +1463,8 @@ db_wait_unlock(void)
|
||||
struct db_unlock u;
|
||||
int ret;
|
||||
|
||||
thread_getnametid(u.thread_name_tid, sizeof(u.thread_name_tid));
|
||||
|
||||
u.proceed = 0;
|
||||
CHECK_ERR(L_DB, mutex_init(&u.lck));
|
||||
CHECK_ERR(L_DB, pthread_cond_init(&u.cond, NULL));
|
||||
@ -1477,7 +1481,7 @@ db_wait_unlock(void)
|
||||
}
|
||||
|
||||
CHECK_ERR(L_DB, pthread_mutex_unlock(&u.lck));
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_ERR(L_DB, pthread_cond_destroy(&u.cond));
|
||||
CHECK_ERR(L_DB, pthread_mutex_destroy(&u.lck));
|
||||
|
@ -985,9 +985,7 @@ request_async_cb(void *arg)
|
||||
{
|
||||
struct httpd_request *hreq = *(struct httpd_request **)arg;
|
||||
|
||||
#ifdef HAVE_GETTID
|
||||
DPRINTF(E_DBG, hreq->module->logdomain, "%s request '%s' in worker thread %d\n", hreq->module->name, hreq->uri, (int)gettid());
|
||||
#endif
|
||||
DPRINTF(E_DBG, hreq->module->logdomain, "%s request '%s'\n", hreq->module->name, hreq->uri);
|
||||
|
||||
// Some handlers require an evbase to schedule events
|
||||
hreq->evbase = worker_evbase_get();
|
||||
|
@ -148,7 +148,7 @@ logger_write_with_label(int severity, int domain, const char *content)
|
||||
if (ret == 0)
|
||||
stamp[0] = '\0';
|
||||
|
||||
logger_write("[%s] [%5s] [%-20s] %8s: %s", stamp, severities[severity], thread_nametid, labels[domain], content);
|
||||
logger_write("[%s] [%5s] [%16s] %8s: %s", stamp, severities[severity], thread_nametid, labels[domain], content);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1820,7 +1820,7 @@ thread_getnametid(char *buf, size_t len)
|
||||
pthread_t p = pthread_self();
|
||||
|
||||
thread_getname(p, thread_name, sizeof(thread_name));
|
||||
tid = thread_gettid();
|
||||
tid = thread_gettid() % 10000;
|
||||
snprintf(buf, len, "%s (%d)", thread_name, tid);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user