[Spice-devel] [spice-gtk] Fix IN_MAIN_CONTEXT when using coroutine=gthread
Marc-André Lureau
mlureau at redhat.com
Fri Nov 15 08:56:03 PST 2013
----- Original Message -----
> On Fri, Nov 15, 2013 at 10:45:42AM -0500, Marc-André Lureau wrote:
> >
> >
> > ----- Original Message -----
> > > On Fri, Nov 15, 2013 at 04:05:55PM +0100, Christophe Fergeau wrote:
> > > > However, this is an
> > > > implementation detail of the ucontext coroutine implementation, in the
> > > > gthread implementation, coroutine_self()->caller will be non-NULL even
> > > > in
> > > > the main context.
> > > NB: Maybe the actual bug is that coroutine_self()->caller in non-NULL for
> > > the main context in the gthread backend, but I'm not familiar enough with
> > > the coroutine code to know that.
> >
> > I don't see when coroutine_self()->caller could be non-null in main
> > coroutine, even with gthread backend.
>
> This is coroutine_swap() from coroutine_gthread.c
> void *coroutine_swap(struct coroutine *from, struct coroutine *to, void *arg)
> {
> from->runnable = FALSE;
>
> from is non-NULL here
>
>
> to->runnable = TRUE;
>
> 'to' becomes the coroutine with 'runnable' set to TRUE
>
>
> to->data = arg;
> to->caller = from;
>
> we set to->caller to something non-NULL
Oh ok, even if "to" is the main coroutine, that make sense. It does the same with other coroutines, I wonder why we didn't hit that before when the macro was added.
ack for your patch, comparing to the static "leader" seems the correct thing to do.
More information about the Spice-devel
mailing list