Ejemplo n.º 1
0
DWORD
VmDirDDVectorInit(
    VOID
    )
{
    DWORD   dwError = 0;

    dwError = VmDirAllocateMemory(
            sizeof(VMDIR_REPL_DEADLOCKDETECTION_VECTOR),
            (PVOID*)&gVmdirServerGlobals.pReplDeadlockDetectionVector);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = LwRtlCreateHashMap(
            &gVmdirServerGlobals.pReplDeadlockDetectionVector->pEmptyPageSentMap,
            LwRtlHashDigestPstrCaseless,
            LwRtlHashEqualPstrCaseless,
            NULL);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(
            &gVmdirServerGlobals.pReplDeadlockDetectionVector->pMutex);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    return dwError;

error:
    VMDIR_LOG_ERROR(VMDIR_LOG_MASK_ALL, "failed, error (%d)", dwError);
    goto cleanup;
}
Ejemplo n.º 2
0
static
DWORD
_VmDirWtxnStatsInit()
{
    DWORD dwWtxnOutstandingThresh = W_TXNS_OUTSTANDING_THRESH_D;
    DWORD dwError = 0;

    if (g_w_txns_mutex == NULL)
    {
        dwError = VmDirAllocateMutex(&g_w_txns_mutex);
        BAIL_ON_VMDIR_ERROR(dwError);
    }

    dwError = VmDirGetRegKeyValueDword(
        VMDIR_CONFIG_PARAMETER_V1_KEY_PATH,
        VMDIR_REG_KEY_WTXN_OUTSTANDING_THRESH,
        &dwWtxnOutstandingThresh, 0);

    if (dwError == 0)
    {
       g_w_txns_outstanding_thresh = dwWtxnOutstandingThresh;
    } else
    {
       //Use the default value.
       dwError = 0;
    }

    VMDIR_LOG_INFO(VMDIR_LOG_MASK_ALL, "%s: W_TXNS_OUTSTANDING_THRESH = %d", __func__, g_w_txns_outstanding_thresh);

done:
    return dwError;

error:
    goto done;
}
Ejemplo n.º 3
0
DWORD
VmDirPagedSearchCacheInit(
    VOID
    )
{
    DWORD dwError = 0;

    dwError = VmDirAllocateMutex(&gPagedSearchCache.mutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = LwRtlCreateHashTable(
                    &gPagedSearchCache.pHashTbl,
                    PagedSearchRecordGetKey,
                    LwRtlHashDigestPstr,
                    LwRtlHashEqualPstr,
                    NULL,
                    VMDIR_PAGED_SEARCH_CACHE_HASH_TABLE_SIZE);
    dwError = LwNtStatusToWin32Error(dwError);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    return dwError;
error:
    VmDirPagedSearchCacheFree();
    goto cleanup;
}
Ejemplo n.º 4
0
DWORD
VmDirQueueInit(
    PVDIR_QUEUE*    ppQueue
    )
{
    DWORD       dwError = 0;
    PVDIR_QUEUE pQueue = NULL;

    if (!ppQueue)
    {
        BAIL_WITH_VMDIR_ERROR(dwError, ERROR_INVALID_PARAMETER);
    }

    dwError = VmDirAllocateMemory(sizeof(VDIR_QUEUE), (PVOID*)&pQueue);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&pQueue->pMutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateCondition(&pQueue->pCond);
    BAIL_ON_VMDIR_ERROR(dwError);

    *ppQueue = pQueue;

cleanup:
    return dwError;

error:
    VMDIR_LOG_ERROR(VMDIR_LOG_MASK_ALL, "%s failed, error (%d)", __FUNCTION__, dwError);
    VmDirQueueFree(pQueue);
    goto cleanup;
}
Ejemplo n.º 5
0
DWORD
VmDirInitOPStatisticGlobals(
    VOID
    )
{
    DWORD       dwError = 0;

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opBind.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opAdd.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opSearch.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opModify.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opDelete.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&gVmdirOPStatisticGlobals.opUnbind.pmutex);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:

    return dwError;

error:
    goto cleanup;

}
Ejemplo n.º 6
0
static
PVOID
_VmDirSASLMutexNew(
    VOID
    )
{
    DWORD           dwError = 0;
    PVMDIR_MUTEX    pLocalMutex = NULL;

    dwError = VmDirAllocateMutex(&pLocalMutex);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:

    return pLocalMutex;

error:

    VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "_VmDirSASLMutexNew failed (%d)", dwError);

    VMDIR_SAFE_FREE_MUTEX(pLocalMutex);

    goto cleanup;
}
Ejemplo n.º 7
0
/*
 *    Bootstrap initial schema from default data.
 *    Not a full schema as ones that initialize from file or entry,
 *    but with limited information that we can bootstrap schema entry from
 *    data store or file.
 *    1.  pSchema->ats.pSortName (in sort order)
 *    1.1 pSchema->ats.pSortName(pszName, usIdMap)
 *    2.  pSchema->ats.dwNumATs
 *    3.  pSchema->ats.ppSortIdMap (in sort order)
 *    4.  pSchema-> bIsBootStrapSchema = TRUE
 *    5.  pSchema->usNextId = 100
 *
 *    gVdirSchemaGlobals.pInstances[0] = bootstrap schema
 *
 */
DWORD
VmDirSchemaLibInit(
    VOID
    )
{
    BOOLEAN bInLock = FALSE;
    DWORD   dwError = 0;
    DWORD   dwCnt = 0;
    PVDIR_SCHEMA_INSTANCE pSchema = NULL;

    PSTR OCTable[] = VDIR_SCHEMA_BOOTSTRP_OC_INITIALIZER;
    VDIR_SCHEMA_BOOTSTRAP_TABLE ATTable[] = VDIR_SCHEMA_BOOTSTRP_ATTR_INITIALIZER;

    // initialize gVdirSchemaGlobals
    dwError = VmDirAllocateMutex(&gVdirSchemaGlobals.mutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VdirSchemaInstanceAllocate(   &pSchema,
                                            sizeof(ATTable)/sizeof(ATTable[0]),
                                            sizeof(OCTable)/sizeof(OCTable[0]),
                                            0,  // no content rule in bootstrap
                                            0,  // no structure rule in bootstrap
                                            0); // no fnameforma in bootstrap
    BAIL_ON_VMDIR_ERROR(dwError);

    for (dwCnt = 0 ; dwCnt < sizeof(ATTable)/sizeof(ATTable[0]); dwCnt++)
    {
        dwError = VmDirSchemaParseStrToATDesc(
                ATTable[dwCnt].pszDesc,
                pSchema->ats.pATSortName+dwCnt);
        BAIL_ON_VMDIR_ERROR(dwError);

        pSchema->ats.pATSortName[dwCnt].usAttrID = ATTable[dwCnt].usAttrID;
    }

    qsort(pSchema->ats.pATSortName,
          pSchema->ats.usNumATs,
          sizeof(VDIR_SCHEMA_AT_DESC),
          VdirSchemaPATNameCmp);

    dwError = VmDirAllocateMemory(
            sizeof(PVDIR_SCHEMA_AT_DESC) * pSchema->ats.usNumATs,
            (PVOID*)&pSchema->ats.ppATSortIdMap);
    BAIL_ON_VMDIR_ERROR(dwError);

    for (dwCnt = 0 ; dwCnt < sizeof(ATTable)/sizeof(ATTable[0]); dwCnt++)
    {
        pSchema->ats.ppATSortIdMap[pSchema->ats.pATSortName[dwCnt].usAttrID -1] =
                &pSchema->ats.pATSortName[dwCnt];
    }

    pSchema-> bIsBootStrapSchema = TRUE;
    pSchema->ats.usNextId = MAX_RESERVED_ATTR_ID_MAP + 1;

    dwError = VdirSyntaxLoad();
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VdirMatchingRuleLoad();
    BAIL_ON_VMDIR_ERROR(dwError);

    VMDIR_LOCK_MUTEX(bInLock, gVdirSchemaGlobals.mutex);

    gVdirSchemaGlobals.pSchema = pSchema;
    dwError = VdirSchemaCtxAcquireInLock(TRUE, &gVdirSchemaGlobals.pCtx); // add self reference
    BAIL_ON_VMDIR_ERROR(dwError);

    assert(gVdirSchemaGlobals.pCtx);

    VMDIR_LOG_VERBOSE( VMDIR_LOG_MASK_ALL, "Startup bootstrap schema instance (%p)", gVdirSchemaGlobals.pSchema);

cleanup:

    VMDIR_UNLOCK_MUTEX(bInLock, gVdirSchemaGlobals.mutex);

    return dwError;

error:

    VMDIR_LOG_ERROR( VMDIR_LOG_MASK_ALL, "VmDirSchemaLibInit failed (%d)", dwError);

    gVdirSchemaGlobals.pSchema = NULL;

    if (pSchema)
    {
        VdirSchemaInstanceFree(pSchema);
    }

    goto cleanup;
}
Ejemplo n.º 8
0
DWORD
VdirSchemaInstanceAllocate(
    PVDIR_SCHEMA_INSTANCE* ppSchema,
    USHORT  dwATSize,
    USHORT  dwOCSize,
    USHORT  dwContentSize,
    USHORT  dwStructureSize,
    USHORT  dwNameformSize
    )
{
    DWORD dwError = 0;
    PVDIR_SCHEMA_INSTANCE pSchema = NULL;

    dwError = VmDirAllocateMemory(
            sizeof(VDIR_SCHEMA_INSTANCE),
            (PVOID*)&pSchema);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMemory(
            sizeof(VDIR_SCHEMA_OC_DESC) * dwOCSize,
            (PVOID*)&pSchema->ocs.pOCSortName);
    BAIL_ON_VMDIR_ERROR(dwError);
    pSchema->ocs.usNumOCs = dwOCSize;

    dwError = VmDirAllocateMemory(
            sizeof(VDIR_SCHEMA_AT_DESC) * dwATSize,
            (PVOID*)&pSchema->ats.pATSortName);
    BAIL_ON_VMDIR_ERROR(dwError);
    pSchema->ats.usNumATs = dwATSize;

    if (dwContentSize > 0)
    {
        dwError = VmDirAllocateMemory(
                sizeof(VDIR_SCHEMA_CR_DESC) * dwContentSize,
                (PVOID*)&pSchema->contentRules.pContentSortName);
        BAIL_ON_VMDIR_ERROR(dwError);
    }
    pSchema->contentRules.usNumContents = dwContentSize;

    if (dwStructureSize > 0)
    {
        dwError = VmDirAllocateMemory(
                sizeof(VDIR_SCHEMA_SR_DESC) * dwStructureSize,
                (PVOID*)&pSchema->structureRules.pStructureSortRuleID);
        BAIL_ON_VMDIR_ERROR(dwError);
    }
    pSchema->structureRules.usNumStructures = dwStructureSize;

    if (dwNameformSize > 0)
    {
        dwError = VmDirAllocateMemory(  sizeof(VDIR_SCHEMA_NF_DESC) * dwNameformSize,
                                        (PVOID*)&pSchema->nameForms.pNameFormSortName);
        BAIL_ON_VMDIR_ERROR(dwError);
    }
    pSchema->nameForms.usNumNameForms = dwNameformSize;

    dwError = VmDirAllocateMutex(&(pSchema->mutex));
    BAIL_ON_VMDIR_ERROR(dwError);

    *ppSchema = pSchema;

cleanup:

    return dwError;

error:

    if ( pSchema )
    {
        VdirSchemaInstanceFree( pSchema );
    }

    goto cleanup;
}
Ejemplo n.º 9
0
static
DWORD
VmDirPagedSearchCacheNodeAllocate(
    PVDIR_PAGED_SEARCH_RECORD *ppSearchRec,
    PVDIR_OPERATION pOperation,
    DWORD dwCandidatesProcessed
    )
{
    DWORD dwError = 0;
    PVDIR_PAGED_SEARCH_RECORD pSearchRecord = NULL;
    char szGuidStr[VMDIR_GUID_STR_LEN] = {0};
    uuid_t guid = {0};
    VDIR_BERVALUE strFilter = VDIR_BERVALUE_INIT;

    dwError = VmDirAllocateMemory(sizeof(*pSearchRecord), (PVOID)&pSearchRecord);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirUuidGenerate(&guid);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirUuidToStringLower(&guid, szGuidStr, sizeof(szGuidStr));
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateStringA(szGuidStr, &pSearchRecord->pszGuid);
    BAIL_ON_VMDIR_ERROR(dwError);

    //
    // Capture the original search filter and mark it as undeletable. Because
    // the ava strings aren't allocated separately but are part of the request
    // we have to specifically clone them.
    //
    dwError = FilterToStrFilter(pOperation->request.searchReq.filter, &strFilter);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = StrFilterToFilter(strFilter.lberbv.bv_val, &pSearchRecord->pFilter);
    BAIL_ON_VMDIR_ERROR(dwError);

    pSearchRecord->pTotalCandidates = pOperation->request.searchReq.filter->candidates;
    pOperation->request.searchReq.filter->candidates = NULL;
    pSearchRecord->dwPageSize = pOperation->showPagedResultsCtrl->value.pagedResultCtrlVal.pageSize;
    //
    // dwCandidatesProcessed is the count of entries of pFilter->candidates
    // that we went through building up the first page of results. We add
    // one because we want to start our next search past the point of where
    // we've already been.
    //
    pSearchRecord->dwCandidatesProcessed = dwCandidatesProcessed + 1;

    dwError = dequeCreate(&pSearchRecord->pQueue);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateMutex(&pSearchRecord->mutex);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirAllocateCondition(&pSearchRecord->pDataAvailable);
    BAIL_ON_VMDIR_ERROR(dwError);

    dwError = VmDirPagedSearchCreateThread(pSearchRecord);
    BAIL_ON_VMDIR_ERROR(dwError);

    LwRtlHashTableResizeAndInsert(
                gPagedSearchCache.pHashTbl,
                &pSearchRecord->Node,
                NULL);

    pSearchRecord->dwRefCount = 1;

    pSearchRecord->tLastClientRead = time(NULL);

    *ppSearchRec = pSearchRecord;

cleanup:
    VmDirFreeBervalContent(&strFilter);
    return dwError;
error:
    VmDirPagedSearchCacheRecordFree(pSearchRecord);
    goto cleanup;
}