[x264-devel] [PATCH] Only init mutexes if threads are being used
Ramiro Polla
ramiro at lisha.ufsc.br
Sun Apr 27 14:36:32 CEST 2008
Hello,
Loren Merritt wrote:
> On Thu, 24 Apr 2008, Ramiro Polla wrote:
>
>> Attached patch makes x264 only init mutexes if threads are being used. That
>> makes all pthread_ calls depend on threads being actually used at run-time.
>> Another commit is needed for the indentation afterwards.
>>
>> A problem that can arise is from programs that use static pthreads-win32 but
>> do not call the initialization code it requires. Currently, it would always
>> initialize the mutexes (even if they're not used), and crash the program that
>> did not properly initialize pthreads-win32, even if no threads were asked for
>> at run-time. With attached patch, if a program forgets to properly initialize
>> pthreads-win32, the user can still get away from the crash with not using
>> threads at run-time.
>
> If pthreads-win32 can be fixed to not require initialization, do that
> instead. If the authors of pthreads-win32 choose not to do that, then
> whatever reason they give might also convince me to accept this patch.
I'm working on pthreads-win32 to find a way to auto(de)init. The authors
say you're supposed to use the shared library, and don't give much
attention to the static library.
But I think this patch should be applied anyways. Currently you are
initializing a mutex and a cond that you never use for single-threaded
encoding.
Ramiro Polla
More information about the x264-devel
mailing list