mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 05:41:37 +00:00
[LibOS] Move helper threads' status checking after lock acquisition
This commit is contained in:
committed by
Dmitrii Kuvaiskii
parent
6866bdb2c6
commit
f71bd2ca84
@@ -849,8 +849,13 @@ static int create_ipc_helper(void) {
|
||||
* problematic for the thread itself to release its own resources e.g. stack).
|
||||
*/
|
||||
struct shim_thread* terminate_ipc_helper(void) {
|
||||
if (ipc_helper_state != HELPER_ALIVE)
|
||||
/* First check if thread is alive. */
|
||||
lock(&ipc_helper_lock);
|
||||
if (ipc_helper_state != HELPER_ALIVE) {
|
||||
unlock(&ipc_helper_lock);
|
||||
return NULL;
|
||||
}
|
||||
unlock(&ipc_helper_lock);
|
||||
|
||||
/* NOTE: Graphene doesn't have an abstraction of a queue of pending signals
|
||||
* between communicating processes (instead all communication is done over
|
||||
@@ -867,6 +872,11 @@ struct shim_thread* terminate_ipc_helper(void) {
|
||||
DkThreadDelayExecution(500);
|
||||
|
||||
lock(&ipc_helper_lock);
|
||||
if (ipc_helper_state != HELPER_ALIVE) {
|
||||
unlock(&ipc_helper_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct shim_thread* ret = ipc_helper_thread;
|
||||
if (ret)
|
||||
get_thread(ret);
|
||||
|
||||
@@ -114,8 +114,10 @@ int64_t install_async_event(PAL_HANDLE object, uint64_t time,
|
||||
|
||||
if (async_helper_state == HELPER_NOTALIVE) {
|
||||
int ret = create_async_helper();
|
||||
if (ret < 0)
|
||||
if (ret < 0) {
|
||||
unlock(&async_helper_lock);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
unlock(&async_helper_lock);
|
||||
@@ -306,10 +308,13 @@ static int create_async_helper(void) {
|
||||
* problematic for the thread itself to release its own resources e.g. stack).
|
||||
*/
|
||||
struct shim_thread* terminate_async_helper(void) {
|
||||
if (async_helper_state != HELPER_ALIVE)
|
||||
return NULL;
|
||||
|
||||
lock(&async_helper_lock);
|
||||
|
||||
if (async_helper_state != HELPER_ALIVE) {
|
||||
unlock(&async_helper_lock);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct shim_thread* ret = async_helper_thread;
|
||||
if (ret)
|
||||
get_thread(ret);
|
||||
|
||||
Reference in New Issue
Block a user