[FFmpeg-devel] default lock mechanism in libavcodec/utils.c
anshul.ffmpeg at gmail.com
Thu Feb 20 17:24:20 CET 2014
Michael Niedermayer <michaelni at gmx.at> wrote:
>On Thu, Feb 20, 2014 at 09:31:14AM +0100, wm4 wrote:
>> On Thu, 20 Feb 2014 13:27:28 +0530
>> anshul <anshul.ffmpeg at gmail.com> wrote:
>> > There was an another idea of michael that using reference count,
>> > Reimar Döffinger if you want reference count then you can help me
>> > there by some guideline, I have not implemented that idea because
>> > miss an reference count then that bug would take more time
>> > to solve.
>> Reference counting? This is just awful. How are you going to
>> synchronize initialization and reference counting if you have no lock
>> that you could use?
>> Let me repeat: global library initialization functions are broken by
>> design, and global library uninitialization functions are even more
>> broken. If a library has static data that must be initialized once,
>> should use pthread_once() to synchronize this initialization.
>> (Does this bizarre lock manager stuff even synchronize
>> I think it does after recent changes, but it's still a very bad
>> emulation of pthread_once().)
>the lock manager stuff isnt safe no, it not only doesnt sync it cannot
>be safe by design.
>just consider an app that sets a lock manager while a lib, lets say
>libgstreamer inited libavcodec previously with another lock manager
>there are multiple races in this case, a locked state could be lost,
>> By the way, it seems this function can be used to implement
>> pthread_once on windows:
>> But it seems it's not supported on XP, and I'm not sure how to do it
>> > just now i am following below idea:
>> > some code that gets called on exit or
>> > lib unloading by the OS.
>> Using atexit()? Might work...
>consider a lib that registers a cleanup function with atexit()
>which accesses libavcodec
I think patch that I sended can be considered, if it does not help the program which dont know who are the library that use libavcodec. But it would help to programs that knows which Library are using libavcodec.
I am looking for an elegant solution, so that every library and program benefit fron it, but till than I think that patch would work
Sent from my Android device with K-9 Mail. Please excuse my brevity.
More information about the ffmpeg-devel