[FFmpeg-devel] default lock mechanism in libavcodec/utils.c
michaelni at gmx.at
Thu Feb 20 17:10:08 CET 2014
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 over
> > there by some guideline, I have not implemented that idea because if i
> > 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, it
> should use pthread_once() to synchronize this initialization.
> (Does this bizarre lock manager stuff even synchronize initialization?
> 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 on
> > 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
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: Digital signature
More information about the ffmpeg-devel