Created
November 4, 2015 17:39
-
-
Save pelwell/1bd72ee37258b9851fb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From be3a54cb721546a7b1edf47f338c517fd2a904c3 Mon Sep 17 00:00:00 2001 | |
From: Phil Elwell <[email protected]> | |
Date: Wed, 4 Nov 2015 17:37:33 +0000 | |
Subject: [PATCH] vcilcs: Avoid a potential deadlock when very threaded | |
See: https://github.com/raspberrypi/firmware/issues/449 | |
--- | |
interface/vmcs_host/vcilcs.c | 20 +++++++++++++++----- | |
1 file changed, 15 insertions(+), 5 deletions(-) | |
diff --git a/interface/vmcs_host/vcilcs.c b/interface/vmcs_host/vcilcs.c | |
index e639592..b394637 100644 | |
--- a/interface/vmcs_host/vcilcs.c | |
+++ b/interface/vmcs_host/vcilcs.c | |
@@ -716,14 +716,24 @@ static int ilcs_execute_function_ex(ILCS_SERVICE_T *st, IL | |
_FUNCTION_T func, | |
// we'll pause until we can carry on and hope that's sufficient. | |
vcos_mutex_unlock(&st->wait_mtx); | |
- vcos_event_wait(&st->wait_event); | |
- | |
// if we're the ilcs thread, then the waiters might need | |
// us to handle their response, so try and clear those now | |
if(vcos_thread_current() == &st->thread) | |
- while(ilcs_process_message(st, 0)) | |
- if(st->kill_service >= CLOSED_CALLBACK) | |
- return -1; | |
+ { | |
+ while (vcos_event_try(&st->wait_event) != VCOS_SUCCESS) | |
+ { | |
+ while(ilcs_process_message(st, 0)) | |
+ if(st->kill_service >= CLOSED_CALLBACK) | |
+ return -1; | |
+ if (vcos_event_try(&st->wait_event) == VCOS_SUCCESS) | |
+ break; | |
+ vcos_sleep(1); | |
+ } | |
+ } | |
+ else | |
+ { | |
+ vcos_event_wait(&st->wait_event); | |
+ } | |
vcos_mutex_lock(&st->wait_mtx); | |
} | |
-- | |
1.9.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment