* [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit
@ 2016-01-13 20:47 Richard Röjfors
2016-01-13 21:09 ` Otavio Salvador
0 siblings, 1 reply; 4+ messages in thread
From: Richard Röjfors @ 2016-01-13 20:47 UTC (permalink / raw)
To: meta-freescale@yoctoproject.org
The way the worker thread was shut down was a bit racy.
Make sure to set the flag indicating the thread to stop spinning
before waking up the thread.
Signed-off-by: Richard Röjfors <richard@puffinpack.se>
---
src/gal2d-renderer.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
index 7ebbf98..d2a29ff 100644
--- a/src/gal2d-renderer.c
+++ b/src/gal2d-renderer.c
@@ -495,21 +495,21 @@ static void *gal2d_output_worker(void *arg)
{
struct weston_output *output = (struct weston_output *)arg;
struct gal2d_output_state *go = get_output_state(output);
+ int go_on = 1;
- while(1)
+ while(go_on)
{
- if(gcoOS_WaitSignal(gcvNULL, go->signal, gcvINFINITE) == gcvSTATUS_OK )
+ int ok = gcoOS_WaitSignal(gcvNULL, go->signal, gcvINFINITE) == gcvSTATUS_OK;
+
+ pthread_mutex_lock(&go->workerMutex);
+ go_on = go->exitWorker == 0;
+ pthread_mutex_unlock(&go->workerMutex);
+
+ if (ok && go_on)
{
gal2d_flip_surface(output);
gcoOS_Signal(gcvNULL,go->busySignal, gcvTRUE);
}
- pthread_mutex_lock(&go->workerMutex);
- if(go->exitWorker == 1)
- {
- pthread_mutex_unlock(&go->workerMutex);
- break;
- }
- pthread_mutex_unlock(&go->workerMutex);
}
return 0;
}
@@ -1169,10 +1169,10 @@ gal2d_renderer_output_destroy(struct weston_output *output)
}
else
{
- gcoOS_Signal(gcvNULL,go->signal, gcvTRUE);
pthread_mutex_lock(&go->workerMutex);
go->exitWorker = 1;
pthread_mutex_unlock(&go->workerMutex);
+ gcoOS_Signal(gcvNULL,go->signal, gcvTRUE);
pthread_join(go->workerId, NULL);
}
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit
2016-01-13 20:47 [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit Richard Röjfors
@ 2016-01-13 21:09 ` Otavio Salvador
2016-01-14 8:17 ` Richard Röjfors
0 siblings, 1 reply; 4+ messages in thread
From: Otavio Salvador @ 2016-01-13 21:09 UTC (permalink / raw)
To: Richard Röjfors; +Cc: meta-freescale@yoctoproject.org
On Wed, Jan 13, 2016 at 6:47 PM, Richard Röjfors
<richard.rojfors@gmail.com> wrote:
> The way the worker thread was shut down was a bit racy.
> Make sure to set the flag indicating the thread to stop spinning
> before waking up the thread.
>
> Signed-off-by: Richard Röjfors <richard@puffinpack.se>
The patch is good and well commented; please include this on the
weston recipe and please also add the Upstream-Status: Pending field
on this so NXP can pick it for their next release.
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit
2016-01-13 21:09 ` Otavio Salvador
@ 2016-01-14 8:17 ` Richard Röjfors
2016-01-18 16:27 ` Richard Röjfors
0 siblings, 1 reply; 4+ messages in thread
From: Richard Röjfors @ 2016-01-14 8:17 UTC (permalink / raw)
To: Otavio Salvador; +Cc: meta-freescale@yoctoproject.org
On Wed, Jan 13, 2016 at 10:09 PM, Otavio Salvador
<otavio.salvador@ossystems.com.br> wrote:
>
> On Wed, Jan 13, 2016 at 6:47 PM, Richard Röjfors
> <richard.rojfors@gmail.com> wrote:
> > The way the worker thread was shut down was a bit racy.
> > Make sure to set the flag indicating the thread to stop spinning
> > before waking up the thread.
> >
> > Signed-off-by: Richard Röjfors <richard@puffinpack.se>
>
> The patch is good and well commented; please include this on the
> weston recipe and please also add the Upstream-Status: Pending field
> on this so NXP can pick it for their next release.
Will do!
--Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit
2016-01-14 8:17 ` Richard Röjfors
@ 2016-01-18 16:27 ` Richard Röjfors
0 siblings, 0 replies; 4+ messages in thread
From: Richard Röjfors @ 2016-01-18 16:27 UTC (permalink / raw)
To: Otavio Salvador; +Cc: meta-freescale@yoctoproject.org
On Thu, Jan 14, 2016 at 9:17 AM, Richard Röjfors
<richard.rojfors@gmail.com> wrote:
> On Wed, Jan 13, 2016 at 10:09 PM, Otavio Salvador
> <otavio.salvador@ossystems.com.br> wrote:
>>
>> On Wed, Jan 13, 2016 at 6:47 PM, Richard Röjfors
>> <richard.rojfors@gmail.com> wrote:
>> > The way the worker thread was shut down was a bit racy.
>> > Make sure to set the flag indicating the thread to stop spinning
>> > before waking up the thread.
>> >
>> > Signed-off-by: Richard Röjfors <richard@puffinpack.se>
>>
>> The patch is good and well commented; please include this on the
>> weston recipe and please also add the Upstream-Status: Pending field
>> on this so NXP can pick it for their next release.
>
>
> Will do!
I've sent it in a separate mail. Please let me know if the formatting
isn't as you expect.
Thanks,
--Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-18 16:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-13 20:47 [meta-fsl-arm][PATCH] gal2d-renderer: Avoid deadlock on exit Richard Röjfors
2016-01-13 21:09 ` Otavio Salvador
2016-01-14 8:17 ` Richard Röjfors
2016-01-18 16:27 ` Richard Röjfors
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.