/* This invokes the "default" AuthCert handler in libssl. ** The only reason to use this one is that it prints out info as it goes. */ static SECStatus mySSLAuthCertificate(void *arg, PRFileDesc *fd, PRBool checkSig, PRBool isServer) { SECStatus rv; CERTCertificate * peerCert; const SECItemArray *csa; if (MakeCertOK>=2) { return SECSuccess; } peerCert = SSL_PeerCertificate(fd); PRINTF("strsclnt: Subject: %s\nstrsclnt: Issuer : %s\n", peerCert->subjectName, peerCert->issuerName); csa = SSL_PeerStapledOCSPResponses(fd); if (csa) { PRINTF("Received %d Cert Status items (OCSP stapled data)\n", csa->len); } /* invoke the "default" AuthCert handler. */ rv = SSL_AuthCertificate(arg, fd, checkSig, isServer); PR_ATOMIC_INCREMENT(&certsTested); if (rv == SECSuccess) { fputs("strsclnt: -- SSL: Server Certificate Validated.\n", stderr); } CERT_DestroyCertificate(peerCert); /* error, if any, will be displayed by the Bad Cert Handler. */ return rv; }
SECStatus sslMutex_Lock(sslMutex *pMutex) { PRInt32 newValue; if (PR_FALSE == pMutex->isMultiProcess) { return single_process_sslMutex_Lock(pMutex); } if (pMutex->u.pipeStr.mPipes[2] != SSL_MUTEX_MAGIC) { PORT_SetError(PR_INVALID_ARGUMENT_ERROR); return SECFailure; } newValue = PR_ATOMIC_INCREMENT(&pMutex->u.pipeStr.nWaiters); /* Do Memory Barrier here. */ if (newValue > 1) { int cc; char c; do { cc = read(pMutex->u.pipeStr.mPipes[0], &c, 1); } while (cc < 0 && errno == EINTR); if (cc != 1) { if (cc < 0) nss_MD_unix_map_default_error(errno); else PORT_SetError(PR_UNKNOWN_ERROR); return SECFailure; } } return SECSuccess; }
void nsStringBuffer::AddRef() { PR_ATOMIC_INCREMENT(&mRefCount); STRING_STAT_INCREMENT(Share); NS_LOG_ADDREF(this, mRefCount, "nsStringBuffer", sizeof(*this)); }
nsSystemPrincipal::AddRef() { NS_PRECONDITION(PRInt32(refcount) >= 0, "illegal refcnt"); nsrefcnt count = PR_ATOMIC_INCREMENT(&refcount); NS_LOG_ADDREF(this, count, "nsSystemPrincipal", sizeof(*this)); return count; }
int32_t gfxMemorySharedReadLock::ReadLock() { NS_ASSERT_OWNINGTHREAD(gfxMemorySharedReadLock); return PR_ATOMIC_INCREMENT(&mReadCount); }
PR_IMPLEMENT(PRStatus) PR_NewThreadPrivateIndex( PRUintn *newIndex, PRThreadPrivateDTOR dtor) { PRStatus rv; PRInt32 index; if (!_pr_initialized) _PR_ImplicitInitialization(); PR_ASSERT(NULL != newIndex); PR_ASSERT(NULL != _pr_tpd_destructors); index = PR_ATOMIC_INCREMENT(&_pr_tpd_highwater) - 1; /* allocate index */ if (_PR_TPD_LIMIT <= index) { PR_SetError(PR_TPD_RANGE_ERROR, 0); rv = PR_FAILURE; /* that's just wrong */ } else { _pr_tpd_destructors[index] = dtor; /* record destructor @index */ *newIndex = (PRUintn)index; /* copy into client's location */ rv = PR_SUCCESS; /* that's okay */ } return rv; }
NSS_IMPLEMENT NSSToken * nssToken_AddRef ( NSSToken *tok ) { PR_ATOMIC_INCREMENT(&tok->base.refCount); return tok; }
NSS_IMPLEMENT NSSSlot * nssSlot_AddRef ( NSSSlot *slot ) { PR_ATOMIC_INCREMENT(&slot->base.refCount); return slot; }
int32_t gfxShmSharedReadLock::ReadLock() { NS_ASSERT_OWNINGTHREAD(gfxShmSharedReadLock); if (!mAllocSuccess) { return 0; } ShmReadLockInfo* info = GetShmReadLockInfoPtr(); return PR_ATOMIC_INCREMENT(&info->readCount); }
PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PRMonitor *mon) { pthread_t self = pthread_self(); PRIntn rv; PRBool notifyEntryWaiter = PR_FALSE; PRIntn notifyTimes = 0; PR_ASSERT(mon != NULL); rv = pthread_mutex_lock(&mon->lock); PR_ASSERT(0 == rv); /* the entries should be > 0 and we'd better be the owner */ PR_ASSERT(mon->entryCount > 0); PR_ASSERT(pthread_equal(mon->owner, self)); if (mon->entryCount == 0 || !pthread_equal(mon->owner, self)) { rv = pthread_mutex_unlock(&mon->lock); PR_ASSERT(0 == rv); return PR_FAILURE; } mon->entryCount -= 1; /* reduce by one */ if (mon->entryCount == 0) { /* and if it transitioned to zero - notify an entry waiter */ /* make the owner unknown */ _PT_PTHREAD_INVALIDATE_THR_HANDLE(mon->owner); notifyEntryWaiter = PR_TRUE; notifyTimes = mon->notifyTimes; mon->notifyTimes = 0; /* We will access the members of 'mon' after unlocking mon->lock. * Add a reference. */ PR_ATOMIC_INCREMENT(&mon->refCount); } rv = pthread_mutex_unlock(&mon->lock); PR_ASSERT(0 == rv); if (notifyEntryWaiter) { if (notifyTimes) pt_PostNotifiesFromMonitor(&mon->waitCV, notifyTimes); rv = pthread_cond_signal(&mon->entryCV); PR_ASSERT(0 == rv); /* We are done accessing the members of 'mon'. Release the * reference. */ PR_DestroyMonitor(mon); } return PR_SUCCESS; } /* PR_ExitMonitor */
/* * FUNCTION: PKIX_PL_Object_IncRef (see comments in pkix_pl_system.h) */ PKIX_Error * PKIX_PL_Object_IncRef( PKIX_PL_Object *object, void *plContext) { PKIX_PL_Object *objectHeader = NULL; PKIX_PL_NssContext *context = NULL; PKIX_Int32 refCount = 0; PKIX_ENTER(OBJECT, "PKIX_PL_Object_IncRef"); PKIX_NULLCHECK_ONE(object); if (plContext){ /* * PKIX_PL_NssContext is not a complete PKIX Type, it doesn't * have a header therefore we cannot verify its type before * casting. */ context = (PKIX_PL_NssContext *) plContext; if (context->arena != NULL) { goto cleanup; } } if (object == (PKIX_PL_Object*)PKIX_ALLOC_ERROR()) { goto cleanup; } /* Shift pointer from user data to object header */ PKIX_CHECK(pkix_pl_Object_GetHeader(object, &objectHeader, plContext), PKIX_RECEIVEDCORRUPTEDOBJECTARGUMENT); /* This object should never have zero references */ refCount = PR_ATOMIC_INCREMENT(&objectHeader->references); if (refCount <= 1) { PKIX_THROW(FATAL, PKIX_OBJECTWITHNONPOSITIVEREFERENCES); } cleanup: PKIX_RETURN(OBJECT); }
XPCWrappedNativeProto::XPCWrappedNativeProto(XPCWrappedNativeScope* Scope, nsIClassInfo* ClassInfo, PRUint32 ClassInfoFlags, XPCNativeSet* Set, QITableEntry* offsets) : mScope(Scope), mJSProtoObject(nsnull), mClassInfo(ClassInfo), mClassInfoFlags(ClassInfoFlags), mSet(Set), mSecurityInfo(nsnull), mScriptableInfo(nsnull), mOffsets(offsets) { // This native object lives as long as its associated JSObject - killed // by finalization of the JSObject (or explicitly if Init fails). MOZ_COUNT_CTOR(XPCWrappedNativeProto); #ifdef DEBUG PR_ATOMIC_INCREMENT(&gDEBUG_LiveProtoCount); #endif }
/* * Notifies just get posted to the protecting mutex. The * actual notification is done when the lock is released so that * MP systems don't contend for a lock that they can't have. */ static void pt_PostNotifyToCvar(PRCondVar *cvar, PRBool broadcast) { PRIntn index = 0; _PT_Notified *notified = &cvar->lock->notified; PR_ASSERT(PR_TRUE == cvar->lock->locked); PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self())); PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex)); while (1) { for (index = 0; index < notified->length; ++index) { if (notified->cv[index].cv == cvar) { if (broadcast) notified->cv[index].times = -1; else if (-1 != notified->cv[index].times) notified->cv[index].times += 1; return; /* we're finished */ } } /* if not full, enter new CV in this array */ if (notified->length < PT_CV_NOTIFIED_LENGTH) break; /* if there's no link, create an empty array and link it */ if (NULL == notified->link) notified->link = PR_NEWZAP(_PT_Notified); notified = notified->link; } /* A brand new entry in the array */ (void)PR_ATOMIC_INCREMENT(&cvar->notify_pending); notified->cv[index].times = (broadcast) ? -1 : 1; notified->cv[index].cv = cvar; notified->length += 1; } /* pt_PostNotifyToCvar */
STDMETHODIMP_(ULONG) CMapiImp::AddRef() { return PR_ATOMIC_INCREMENT(&m_cRef); }
int main(int argc, char **argv) { PRInt32 rv, oldval, test, result = 0; PRFileDesc *output = PR_GetSpecialFD(PR_StandardOutput); /***********************/ /* Test the functions. */ /***********************/ oldval = test = -2; rv = PR_AtomicIncrement(&test); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_AtomicIncrement(%d) == %d: %s\n", oldval, rv, (rv == -1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicIncrement(&test); result = result | ((rv == 0) ? 0 : 1); PR_fprintf( output, "PR_AtomicIncrement(%d) == %d: %s\n", oldval, rv, (rv == 0) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicIncrement(&test); result = result | ((rv == 1) ? 0 : 1); PR_fprintf( output, "PR_AtomicIncrement(%d) == %d: %s\n", oldval, rv, (rv == 1) ? "PASSED" : "FAILED"); oldval = test = -2; rv = PR_AtomicAdd(&test,1); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_AtomicAdd(%d,%d) == %d: %s\n", oldval, 1, rv, (rv == -1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicAdd(&test, 4); result = result | ((rv == 3) ? 0 : 1); PR_fprintf( output, "PR_AtomicAdd(%d,%d) == %d: %s\n", oldval, 4, rv, (rv == 3) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicAdd(&test, -6); result = result | ((rv == -3) ? 0 : 1); PR_fprintf( output, "PR_AtomicAdd(%d,%d) == %d: %s\n", oldval, -6, rv, (rv == -3) ? "PASSED" : "FAILED"); oldval = test = 2; rv = PR_AtomicDecrement(&test); result = result | ((rv == 1) ? 0 : 1); PR_fprintf( output, "PR_AtomicDecrement(%d) == %d: %s\n", oldval, rv, (rv == 1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicDecrement(&test); result = result | ((rv == 0) ? 0 : 1); PR_fprintf( output, "PR_AtomicDecrement(%d) == %d: %s\n", oldval, rv, (rv == 0) ? "PASSED" : "FAILED"); oldval = test; rv = PR_AtomicDecrement(&test); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_AtomicDecrement(%d) == %d: %s\n", oldval, rv, (rv == -1) ? "PASSED" : "FAILED"); /* set to a different value */ oldval = test = -2; rv = PR_AtomicSet(&test, 2); result = result | (((rv == -2) && (test == 2)) ? 0 : 1); PR_fprintf( output, "PR_AtomicSet(%d, %d) == %d: %s\n", oldval, 2, rv, ((rv == -2) && (test == 2)) ? "PASSED" : "FAILED"); /* set to the same value */ oldval = test = -2; rv = PR_AtomicSet(&test, -2); result = result | (((rv == -2) && (test == -2)) ? 0 : 1); PR_fprintf( output, "PR_AtomicSet(%d, %d) == %d: %s\n", oldval, -2, rv, ((rv == -2) && (test == -2)) ? "PASSED" : "FAILED"); /***********************/ /* Test the macros. */ /***********************/ oldval = test = -2; rv = PR_ATOMIC_INCREMENT(&test); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_INCREMENT(%d) == %d: %s\n", oldval, rv, (rv == -1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_INCREMENT(&test); result = result | ((rv == 0) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_INCREMENT(%d) == %d: %s\n", oldval, rv, (rv == 0) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_INCREMENT(&test); result = result | ((rv == 1) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_INCREMENT(%d) == %d: %s\n", oldval, rv, (rv == 1) ? "PASSED" : "FAILED"); oldval = test = -2; rv = PR_ATOMIC_ADD(&test,1); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_ADD(%d,%d) == %d: %s\n", oldval, 1, rv, (rv == -1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_ADD(&test, 4); result = result | ((rv == 3) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_ADD(%d,%d) == %d: %s\n", oldval, 4, rv, (rv == 3) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_ADD(&test, -6); result = result | ((rv == -3) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_ADD(%d,%d) == %d: %s\n", oldval, -6, rv, (rv == -3) ? "PASSED" : "FAILED"); oldval = test = 2; rv = PR_ATOMIC_DECREMENT(&test); result = result | ((rv == 1) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_DECREMENT(%d) == %d: %s\n", oldval, rv, (rv == 1) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_DECREMENT(&test); result = result | ((rv == 0) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_DECREMENT(%d) == %d: %s\n", oldval, rv, (rv == 0) ? "PASSED" : "FAILED"); oldval = test; rv = PR_ATOMIC_DECREMENT(&test); result = result | ((rv == -1) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_DECREMENT(%d) == %d: %s\n", oldval, rv, (rv == -1) ? "PASSED" : "FAILED"); /* set to a different value */ oldval = test = -2; rv = PR_ATOMIC_SET(&test, 2); result = result | (((rv == -2) && (test == 2)) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_SET(%d, %d) == %d: %s\n", oldval, 2, rv, ((rv == -2) && (test == 2)) ? "PASSED" : "FAILED"); /* set to the same value */ oldval = test = -2; rv = PR_ATOMIC_SET(&test, -2); result = result | (((rv == -2) && (test == -2)) ? 0 : 1); PR_fprintf( output, "PR_ATOMIC_SET(%d, %d) == %d: %s\n", oldval, -2, rv, ((rv == -2) && (test == -2)) ? "PASSED" : "FAILED"); PR_fprintf( output, "Atomic operations test %s\n", (result == 0) ? "PASSED" : "FAILED"); return result; } /* main */
/* * FUNCTION: PKIX_PL_Object_Alloc (see comments in pkix_pl_system.h) */ PKIX_Error * PKIX_PL_Object_Alloc( PKIX_TYPENUM objType, PKIX_UInt32 size, PKIX_PL_Object **pObject, void *plContext) { PKIX_PL_Object *object = NULL; pkix_ClassTable_Entry *ctEntry = NULL; PKIX_ENTER(OBJECT, "PKIX_PL_Object_Alloc"); PKIX_NULLCHECK_ONE(pObject); /* * We need to ensure that user-defined types have been registered. * All system types have already been registered by PKIX_PL_Initialize. */ if (objType >= PKIX_NUMTYPES) { /* i.e. if this is a user-defined type */ #ifdef PKIX_USER_OBJECT_TYPE PKIX_Boolean typeRegistered; PKIX_OBJECT_DEBUG("\tCalling PR_Lock).\n"); PR_Lock(classTableLock); pkixErrorResult = pkix_pl_PrimHashTable_Lookup (classTable, (void *)&objType, objType, NULL, (void **)&ctEntry, plContext); PKIX_OBJECT_DEBUG("\tCalling PR_Unlock).\n"); PR_Unlock(classTableLock); if (pkixErrorResult){ PKIX_ERROR_FATAL(PKIX_COULDNOTLOOKUPINHASHTABLE); } typeRegistered = (ctEntry != NULL); if (!typeRegistered) { PKIX_ERROR_FATAL(PKIX_UNKNOWNTYPEARGUMENT); } #else PORT_Assert (0); pkixErrorCode = PKIX_UNKNOWNOBJECTTYPE; pkixErrorClass = PKIX_FATAL_ERROR; goto cleanup; #endif /* PKIX_USER_OBJECT_TYPE */ } else { ctEntry = &systemClasses[objType]; } PORT_Assert(size == ctEntry->typeObjectSize); /* Allocate space for the object header and the requested size */ #ifdef PKIX_OBJECT_LEAK_TEST PKIX_CHECK(PKIX_PL_Calloc (1, ((PKIX_UInt32)sizeof (PKIX_PL_Object))+size, (void **)&object, plContext), PKIX_MALLOCFAILED); #else PKIX_CHECK(PKIX_PL_Malloc (((PKIX_UInt32)sizeof (PKIX_PL_Object))+size, (void **)&object, plContext), PKIX_MALLOCFAILED); #endif /* PKIX_OBJECT_LEAK_TEST */ /* Initialize all object fields */ object->magicHeader = PKIX_MAGIC_HEADER; object->type = objType; object->references = 1; /* Default to a single reference */ object->stringRep = NULL; object->hashcode = 0; object->hashcodeCached = 0; /* Cannot use PKIX_PL_Mutex because it depends on Object */ /* Using NSPR Locks instead */ PKIX_OBJECT_DEBUG("\tCalling PR_NewLock).\n"); object->lock = PR_NewLock(); if (object->lock == NULL) { PKIX_ERROR_ALLOC_ERROR(); } PKIX_OBJECT_DEBUG("\tShifting object pointer).\n"); /* Return a pointer to the user data. Need to offset by object size */ *pObject = object + 1; object = NULL; /* Atomically increment object counter */ PR_ATOMIC_INCREMENT(&ctEntry->objCounter); cleanup: PKIX_FREE(object); PKIX_RETURN(OBJECT); }
nsScriptableUnicodeConverter::nsScriptableUnicodeConverter() : mIsInternal(false) { PR_ATOMIC_INCREMENT(&gInstanceCount); }
/* * load a new module into our address space and initialize it. */ SECStatus secmod_LoadPKCS11Module(SECMODModule *mod, SECMODModule **oldModule) { PRLibrary *library = NULL; CK_C_GetFunctionList entry = NULL; CK_INFO info; CK_ULONG slotCount = 0; SECStatus rv; PRBool alreadyLoaded = PR_FALSE; char *disableUnload = NULL; if (mod->loaded) return SECSuccess; /* internal modules get loaded from their internal list */ if (mod->internal && (mod->dllName == NULL)) { #ifdef NSS_TEST_BUILD entry = (CK_C_GetFunctionList)NSC_GetFunctionList; #else /* * Loads softoken as a dynamic library, * even though the rest of NSS assumes this as the "internal" module. */ if (!softokenLib && PR_SUCCESS != PR_CallOnce(&loadSoftokenOnce, &softoken_LoadDSO)) return SECFailure; PR_ATOMIC_INCREMENT(&softokenLoadCount); if (mod->isFIPS) { entry = (CK_C_GetFunctionList) PR_FindSymbol(softokenLib, "FC_GetFunctionList"); } else { entry = (CK_C_GetFunctionList) PR_FindSymbol(softokenLib, "NSC_GetFunctionList"); } if (!entry) return SECFailure; #endif if (mod->isModuleDB) { mod->moduleDBFunc = (CK_C_GetFunctionList) #ifdef NSS_TEST_BUILD NSC_ModuleDBFunc; #else PR_FindSymbol(softokenLib, "NSC_ModuleDBFunc"); #endif } if (mod->moduleDBOnly) { mod->loaded = PR_TRUE; return SECSuccess; } } else { /* Not internal, load the DLL and look up C_GetFunctionList */ if (mod->dllName == NULL) { return SECFailure; } /* load the library. If this succeeds, then we have to remember to * unload the library if anything goes wrong from here on out... */ library = PR_LoadLibrary(mod->dllName); mod->library = (void *)library; if (library == NULL) { return SECFailure; } /* * now we need to get the entry point to find the function pointers */ if (!mod->moduleDBOnly) { entry = (CK_C_GetFunctionList) PR_FindSymbol(library, "C_GetFunctionList"); } if (mod->isModuleDB) { mod->moduleDBFunc = (void *) PR_FindSymbol(library, "NSS_ReturnModuleSpecData"); } if (mod->moduleDBFunc == NULL) mod->isModuleDB = PR_FALSE; if (entry == NULL) { if (mod->isModuleDB) { mod->loaded = PR_TRUE; mod->moduleDBOnly = PR_TRUE; return SECSuccess; } PR_UnloadLibrary(library); return SECFailure; } } /* * We need to get the function list */ if ((*entry)((CK_FUNCTION_LIST_PTR *)&mod->functionList) != CKR_OK) goto fail; #ifdef DEBUG_MODULE if (PR_TRUE) { modToDBG = PR_GetEnvSecure("NSS_DEBUG_PKCS11_MODULE"); if (modToDBG && strcmp(mod->commonName, modToDBG) == 0) { mod->functionList = (void *)nss_InsertDeviceLog( (CK_FUNCTION_LIST_PTR)mod->functionList); } } #endif mod->isThreadSafe = PR_TRUE; /* Now we initialize the module */ rv = secmod_ModuleInit(mod, oldModule, &alreadyLoaded); if (rv != SECSuccess) { goto fail; } /* module has been reloaded, this module itself is done, * return to the caller */ if (mod->functionList == NULL) { mod->loaded = PR_TRUE; /* technically the module is loaded.. */ return SECSuccess; } /* check the version number */ if (PK11_GETTAB(mod)->C_GetInfo(&info) != CKR_OK) goto fail2; if (info.cryptokiVersion.major != 2) goto fail2; /* all 2.0 are a priori *not* thread safe */ if (info.cryptokiVersion.minor < 1) { if (!loadSingleThreadedModules) { PORT_SetError(SEC_ERROR_INCOMPATIBLE_PKCS11); goto fail2; } else { mod->isThreadSafe = PR_FALSE; } } mod->cryptokiVersion = info.cryptokiVersion; /* If we don't have a common name, get it from the PKCS 11 module */ if ((mod->commonName == NULL) || (mod->commonName[0] == 0)) { mod->commonName = PK11_MakeString(mod->arena, NULL, (char *)info.libraryDescription, sizeof(info.libraryDescription)); if (mod->commonName == NULL) goto fail2; } /* initialize the Slots */ if (PK11_GETTAB(mod)->C_GetSlotList(CK_FALSE, NULL, &slotCount) == CKR_OK) { CK_SLOT_ID *slotIDs; int i; CK_RV crv; mod->slots = (PK11SlotInfo **)PORT_ArenaAlloc(mod->arena, sizeof(PK11SlotInfo *) * slotCount); if (mod->slots == NULL) goto fail2; slotIDs = (CK_SLOT_ID *)PORT_Alloc(sizeof(CK_SLOT_ID) * slotCount); if (slotIDs == NULL) { goto fail2; } crv = PK11_GETTAB(mod)->C_GetSlotList(CK_FALSE, slotIDs, &slotCount); if (crv != CKR_OK) { PORT_Free(slotIDs); goto fail2; } /* Initialize each slot */ for (i = 0; i < (int)slotCount; i++) { mod->slots[i] = PK11_NewSlotInfo(mod); PK11_InitSlot(mod, slotIDs[i], mod->slots[i]); /* look down the slot info table */ PK11_LoadSlotList(mod->slots[i], mod->slotInfo, mod->slotInfoCount); SECMOD_SetRootCerts(mod->slots[i], mod); /* explicitly mark the internal slot as such if IsInternalKeySlot() * is set */ if (secmod_IsInternalKeySlot(mod) && (i == (mod->isFIPS ? 0 : 1))) { pk11_SetInternalKeySlotIfFirst(mod->slots[i]); } } mod->slotCount = slotCount; mod->slotInfoCount = 0; PORT_Free(slotIDs); } mod->loaded = PR_TRUE; mod->moduleID = nextModuleID++; return SECSuccess; fail2: if (enforceAlreadyInitializedError || (!alreadyLoaded)) { PK11_GETTAB(mod)->C_Finalize(NULL); } fail: mod->functionList = NULL; disableUnload = PR_GetEnvSecure("NSS_DISABLE_UNLOAD"); if (library && !disableUnload) { PR_UnloadLibrary(library); } return SECFailure; }
STDMETHODIMP_(ULONG) CMapiFactory::AddRef() { return (PR_ATOMIC_INCREMENT(&m_cRef)); }
PK11SymKey * PK11_ReferenceSymKey(PK11SymKey *symKey) { PR_ATOMIC_INCREMENT(&symKey->refCount); return symKey; }