On Wed, Jul 16, 2014 at 03:56:52PM +0200, Lukas Slebodnik wrote:
On (16/07/14 14:02), Sumit Bose wrote:
>On Wed, Jul 16, 2014 at 11:32:53AM +0200, Lukas Slebodnik wrote:
>> ehlo,
>>
>> attached patches fix problems with mmap cache in client code.
>> The 1st patch is at least 5th version, because I found few problems in my
>> previous versions myself. I hope you will not find anything else :-)
>>
>> Patches change client code. It will be good to have at least 2 ACKs.
>
>Currently we use sss_nss_lock() and sss_nss_unlock() to protect
>sss_nss_make_request() in multi-threaded clients (there is sss_pam_lock()
>and sss_pam_lock() for pam_sss as well). I wonder if a new pair like
>sss_mc_init_lock() sss_mc_init_unlock() might help to protect
>sss_nss_mc_get_ctx() as well?
>
New version with sss_nss_{lock,unlock} is attached.
I didn't want call lock each invocation of sss_nss_mc_get_ctx,
because it should be fast memory cache and locking is useless with already
initialised structure. You can also compare attached patch with first version
Any comments are welcomed.
Function sss_nss_mc_get_ctx was split into two parts for simplification
of locking and unlocking. The locking is used only in new static function
sss_nss_mc_init_ctx. This function will not be called very often therefore the
same mutex is used as in other nss functions.
Testing was already described in 1st mail.
You just need different diff to see logging without locking.
--- a/src/sss_client/nss_mc_common.c
+++ b/src/sss_client/nss_mc_common.c
@@ -113,7 +113,7 @@ static errno_t sss_nss_mc_init_ctx(const char *name,
int ret;
fprintf(stderr, "before nss lock\n");
- sss_nss_lock();
+ //sss_nss_lock();
fprintf(stderr, "after nss lock\n");
/* check if ctx is initialised by previous thread. */
if (ctx->initialized) {
@@ -183,7 +183,7 @@ done:
memset(ctx, 0, sizeof(struct sss_cli_mc_ctx));
}
free(file);
- sss_nss_unlock();
+ //sss_nss_unlock();
fprintf(stderr, "after nss unlock\n");
return ret;
LS
ACK to 0001 and 0002.
bye,
Sumit