[Spice-devel] [PATCH spice-gtk 11/13] coroutine: reference object when signaling

Christophe Fergeau cfergeau at redhat.com
Wed Nov 12 09:27:00 PST 2014


On Wed, Nov 12, 2014 at 12:10:26PM -0500, Marc-André Lureau wrote:
> 
> 
> ----- Original Message -----
> > Hey,
> > 
> > On Sun, Nov 09, 2014 at 05:31:43PM +0100, Marc-André Lureau wrote:
> > > Before the signal is acutally emitted, the channel may be
> > 
> > 'actually'
> > 
> > > released. Similarly to g_signal_emit, take a reference before yielding
> > > to main context.
> > 
> > I would drop the "similarly to g_signal_emit" as your purpose is most
> > likely different. The ref is needed here as the signal emission is
> > async, so code can run before the signal emission, but g_signal_emit is
> > synchronous.
> > 
> > I assume the scenario you want to protect against is
> > - (coroutine context)g_coroutine_signal_emit is called
> >   - the signal emission is scheduled in an idle with g_idle_add
> >   - coroutine_yield() is called
> > - (main context)code runs which drops the last ref on the channel
> > - (main context)idle runs and tries to emit the signal
> > 
> > 
> > Patch looks good if this is the correct scenario.
> 
> Yes, I maintain "similarly", because we want to maintain object alive
> during g_coroutine_signal_emit(). I think it is thus appropriate here.

g_signal_emit and g_coroutine_signal_emit want to keep the object alive
for very different reasons, so I would not say "similarly". The only
similarity (apart from the name) is that both use g_object_ref() to
ensure the object does not die during some work they do, there are
probably a lot of functions doing that.
Feel free to add the scenario to the log for future readers.


Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141112/d0eea256/attachment-0001.sig>


More information about the Spice-devel mailing list