Ok... So if I correctly understand, I can in a external module made in C (like for exemple a Pext) call a non thread-safe function without make a Mutex lock ?
Correct.
If so... I just say wow !
and maybe the following code in src/modules/Msql/msqlmod.c is not really needed :
THREADS_ALLOW(); MSQL_LOCK(); status=msqlReloadAcls(socket); MSQL_UNLOCK(); THREADS_DISALLOW();
It is. What happens here is:
1) Pike interpreter lock is released 2) msql lock is locked. 3) execution 4) release msql lock 5) try to regain interpreter lock
The msql lock, and similar locks in other modules, are used to avoid multiple calls using the same object instance, or in some cases, limit it to one call globally in the process. Why? Although not strictly needed (i.e remove both locks and it'd work perfectly fine), it's benefitial since Pike, during the possibly long query, can go on with other stuff. If you don't release the interpreter log, a 10 minute long database query would lock up ALL threads in the process, instead of only the calling thread and other threads wanting to use the same msql object.
/ David Hedbor
Previous text:
2003-06-17 23:53: Subject: Re: Pike localtime(), threads safe and low level localtime() / localtime_r() ?
Le mardi, 17 jun 2003, à 23:40 Europe/Paris, David Hedbor @ Pike developers forum a écrit :
Thank you for this usefull information..
But is seems that is valid only in the core of Pike, since src/modules/Msql/*.c has such options THREADS_ALLOW and its friends THREADS_DISALLOW
/Xavier
I don't quite understand what you mean with this. What I said is always true in any C-method called from Pike, regardless if it's in a "core" method or a method in a dynamically loaded module.
Ok... So if I correctly understand, I can in a external module made in C (like for exemple a Pext) call a non thread-safe function without make a Mutex lock ?
If so... I just say wow !
and maybe the following code in src/modules/Msql/msqlmod.c is not really needed :
THREADS_ALLOW(); MSQL_LOCK(); status=msqlReloadAcls(socket); MSQL_UNLOCK(); THREADS_DISALLOW();
/Xavier
/ Brevbäraren