On 6/20/06, Jim Spring <[EMAIL PROTECTED]> wrote:

        2.  Iterate over the slots in the module specifically
            using the "slots" and "slotCount" entries within
            the SECMODModule data structure.

I suggest you imitate the Mozilla code to lock the default
module list lock when you iterate over the slots in the module:
http://lxr.mozilla.org/security/source/security/manager/ssl/src/nsPKCS11Slot.cpp#379

392   /* applications which allow new slot creation (which Firefox now does
393    * since it uses the WaitForSlotEvent call) need to hold the
394    * ModuleList Read lock to prevent the slot array from changing out
395    * from under it. */
396   SECMODListLock *lock = SECMOD_GetDefaultModuleListLock();
397   SECMOD_GetReadLock(lock);
398   for (i=0; i<mModule->slotCount; i++) {
399     if (mModule->slots[i]) {
400       nsCOMPtr<nsIPKCS11Slot> slot = new nsPKCS11Slot(mModule->slots[i]);
401       array->AppendElement(slot);
402     }
403   }
404   SECMOD_ReleaseReadLock(lock);

NSS also locks this lock (as either a reader or a
writer) when it iterates over the slots on the module. See
http://lxr.mozilla.org/security/source/security/nss/lib/pk11wrap/pk11util.c
for examples.

AYR
_______________________________________________
dev-tech-crypto mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to