mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-22 17:35:59 +03:00
Simplify worker loop
Do not reacquire mutex several times without a real reason. Code readability is also better.
This commit is contained in:
parent
b39f294d02
commit
e65626090b
@ -1,5 +1,6 @@
|
||||
Version 2.02.89 -
|
||||
==================================
|
||||
Simplify code for lvm worker thread in clvmd.
|
||||
Use pthread_barrier to synchronize clvmd threads at startup.
|
||||
Limit clvmd's thread size to 128KiB.
|
||||
Reduce default preallocated stack size to 64KiB.
|
||||
|
@ -1988,6 +1988,7 @@ static void *lvm_thread_fn(void *arg)
|
||||
struct dm_list *cmdl, *tmp;
|
||||
sigset_t ss;
|
||||
struct lvm_startup_params *lvm_params = arg;
|
||||
struct lvm_thread_cmd *cmd;
|
||||
|
||||
DEBUGLOG("LVM thread function started\n");
|
||||
|
||||
@ -2005,18 +2006,15 @@ static void *lvm_thread_fn(void *arg)
|
||||
DEBUGLOG("Sub thread ready for work.\n");
|
||||
|
||||
/* Now wait for some actual work */
|
||||
pthread_mutex_lock(&lvm_thread_mutex);
|
||||
|
||||
while (!quit) {
|
||||
DEBUGLOG("LVM thread waiting for work\n");
|
||||
|
||||
pthread_mutex_lock(&lvm_thread_mutex);
|
||||
if (dm_list_empty(&lvm_cmd_head))
|
||||
if (dm_list_empty(&lvm_cmd_head)) {
|
||||
DEBUGLOG("LVM thread waiting for work\n");
|
||||
pthread_cond_wait(&lvm_thread_cond, &lvm_thread_mutex);
|
||||
|
||||
dm_list_iterate_safe(cmdl, tmp, &lvm_cmd_head) {
|
||||
struct lvm_thread_cmd *cmd;
|
||||
|
||||
cmd =
|
||||
dm_list_struct_base(cmdl, struct lvm_thread_cmd, list);
|
||||
} else {
|
||||
cmd = dm_list_item(dm_list_first(&lvm_cmd_head),
|
||||
struct lvm_thread_cmd);
|
||||
dm_list_del(&cmd->list);
|
||||
pthread_mutex_unlock(&lvm_thread_mutex);
|
||||
|
||||
@ -2026,9 +2024,10 @@ static void *lvm_thread_fn(void *arg)
|
||||
|
||||
pthread_mutex_lock(&lvm_thread_mutex);
|
||||
}
|
||||
pthread_mutex_unlock(&lvm_thread_mutex);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lvm_thread_mutex);
|
||||
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user