mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
reduce some if/else complexity
This commit is contained in:
parent
528329f199
commit
d5ec3c8889
@ -1295,14 +1295,15 @@ static void _cleanup_unused_threads(void)
|
|||||||
_lock_mutex();
|
_lock_mutex();
|
||||||
while ((l = list_first(&_thread_registry_unused))) {
|
while ((l = list_first(&_thread_registry_unused))) {
|
||||||
thread = list_item(l, struct thread_status);
|
thread = list_item(l, struct thread_status);
|
||||||
if (thread->processing) {
|
if (thread->processing)
|
||||||
goto out; /* cleanup on the next round */
|
break; /* cleanup on the next round */
|
||||||
}
|
|
||||||
|
|
||||||
if (thread->status == DM_THREAD_RUNNING) {
|
if (thread->status == DM_THREAD_RUNNING) {
|
||||||
thread->status = DM_THREAD_SHUTDOWN;
|
thread->status = DM_THREAD_SHUTDOWN;
|
||||||
goto out;
|
break;
|
||||||
} else if (thread->status == DM_THREAD_SHUTDOWN) {
|
}
|
||||||
|
|
||||||
|
if (thread->status == DM_THREAD_SHUTDOWN) {
|
||||||
if (!thread->events) {
|
if (!thread->events) {
|
||||||
/* turn codes negative -- should we be returning this? */
|
/* turn codes negative -- should we be returning this? */
|
||||||
ret = _terminate_thread(thread);
|
ret = _terminate_thread(thread);
|
||||||
@ -1315,22 +1316,26 @@ static void _cleanup_unused_threads(void)
|
|||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
stack;
|
stack;
|
||||||
}
|
}
|
||||||
goto out;
|
break;
|
||||||
} else {
|
}
|
||||||
list_del(l);
|
|
||||||
syslog(LOG_ERR,
|
list_del(l);
|
||||||
"thread can't be on unused list unless !thread->events");
|
syslog(LOG_ERR,
|
||||||
thread->status = DM_THREAD_RUNNING;
|
"thread can't be on unused list unless !thread->events");
|
||||||
LINK_THREAD(thread);
|
thread->status = DM_THREAD_RUNNING;
|
||||||
}
|
LINK_THREAD(thread);
|
||||||
} else if (thread->status == DM_THREAD_DONE) {
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (thread->status == DM_THREAD_DONE) {
|
||||||
list_del(l);
|
list_del(l);
|
||||||
pthread_join(thread->thread, NULL);
|
pthread_join(thread->thread, NULL);
|
||||||
_lib_put(thread->dso_data);
|
_lib_put(thread->dso_data);
|
||||||
_free_thread_status(thread);
|
_free_thread_status(thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out:
|
|
||||||
_unlock_mutex();
|
_unlock_mutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user