[vlc-devel] [PATCH 1/3] Qt: Run mainloop on the main thread on OSX

Juho Vähä-Herttua juhovh at iki.fi
Mon Aug 2 10:34:36 CEST 2010


On 2.8.2010, at 10.19, Rémi Denis-Courmont wrote:
> On Mon, 2 Aug 2010 01:09:02 +0300, Juho Vähä-Herttua <juhovh at iki.fi>
> wrote:
>> The change you made prevents vlc_kill from being called, because
>> libvlc_SetExitHandler of qt4.cpp or alternatively libvlc_InternalWait of
>> interface.c overrides the exit handler.
> 
> The change I made fixes a race between the playlist and the interfaces
> calling libvlc_Quit() and the main thread calling sigwait(). Without this,
> libvlc_Quit() may be called before the handler is registered. Then SIGTERM
> is not raised, and sigwait() hangs.

In case libvlc_Quit() is called before the handler is registered, there's the code in libvlc_SetExitHandler thread-safely inside a mutex that checks for "exit->killed" and calls the new exit handler directly in case the libvlc_Quit() got called before libvlc_SetExitHandler(). I don't see any possible case where it could hang in sigwait(), except the one you just committed. In short the race condition that was already handled nicely and fixing it broke some other recently discussed code without giving any suggestions for a further fix...thanks.

So how to proceed in case where libvlc_SetExitHandler is first overridden and then libvlc_Quit() is called during libvlc_add_intf(). One option I could think of is to make the caller of libvlc_SetExitHandler() always responsible for calling the last exit handler, but it's hard to do without any race conditions. Other option would be to check manually if the interface is killed after returning from libvlc_add_intf() and then call SIGTERM manually, but that's basically exactly what the libvlc_SetExitHandler was doing before.

I'm open to discussion, but I would still like a proper fix or no fix at all, since from my point of view things worked fine before. (except for a race condition that however doesn't cause any harm whatsoever)


Juho

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4215 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20100802/625db899/attachment.bin>


More information about the vlc-devel mailing list