示例#1
0
static
DWORD
VmDirLdapSchemaAddDef(
    PLW_HASHMAP             pDefMap,
    PVDIR_LDAP_DEFINITION   pDef
    )
{
    DWORD   dwError = 0;
    BOOLEAN bRemoveOnError = FALSE;
    LW_HASHMAP_PAIR pair = {NULL, NULL};
    PVDIR_LDAP_DEFINITION   pPrevDef = NULL;
    PVDIR_LDAP_DEFINITION_LIST  pDefList = NULL;
    PVDIR_LDAP_DEFINITION_LIST  pNewDefList = NULL;

    if (!pDefMap || !pDef)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMDIR_ERROR(dwError);
    }

    dwError = LwRtlHashMapInsert(pDefMap, pDef->pszName, pDef, &pair);
    BAIL_ON_VMDIR_ERROR(dwError);

    pPrevDef = (PVDIR_LDAP_DEFINITION)pair.pValue;
    if (pPrevDef)
    {
        assert(!pDef->pList);   // linked list conflict
        pDefList = pPrevDef->pList;
    }
    else
    {
        pDefList = pDef->pList;
        bRemoveOnError = TRUE;
    }

    if (!pDefList)
    {
        dwError = VmDirLdapDefListCreate(&pNewDefList);
        BAIL_ON_VMDIR_ERROR(dwError);
        pDefList = pNewDefList;
    }

    dwError = VmDirLdapDefListUpdateHead(pDefList, pDef);
    BAIL_ON_VMDIR_ERROR(dwError);

cleanup:
    return dwError;

error:
    if (pPrevDef)
    {
        (VOID)LwRtlHashMapInsert(pDefMap, pPrevDef->pszName, pPrevDef, NULL);
    }
    else if (bRemoveOnError)
    {
        (VOID)LwRtlHashMapRemove(pDefMap, pDef->pszName, NULL);
    }
    VmDirFreeLdapDefList(pNewDefList);
    goto cleanup;
}
示例#2
0
static
DWORD
_VmDirReplPopulateAttrNewMetaData(
    PVDIR_ENTRY    pEntry,
    USN            localUsn,
    PLW_HASHMAP    pMetaDataMap
    )
{
    PSTR                        pszAttrType = NULL;
    DWORD                       dwError = 0;
    PVDIR_ATTRIBUTE             pCurrAttr = NULL;
    LW_HASHMAP_PAIR             pair = {NULL, NULL};
    PVMDIR_ATTRIBUTE_METADATA   pSupplierMetaData = NULL;

    if (!pEntry || !pMetaDataMap)
    {
        BAIL_WITH_VMDIR_ERROR(dwError, VMDIR_ERROR_INVALID_PARAMETER);
    }

    for (pCurrAttr = pEntry->attrs; pCurrAttr; pCurrAttr = pCurrAttr->next)
    {
        dwError = LwRtlHashMapRemove(pMetaDataMap, pCurrAttr->type.lberbv.bv_val, &pair);

        pszAttrType = (PSTR) pair.pKey;
        pSupplierMetaData = (PVMDIR_ATTRIBUTE_METADATA) pair.pValue;

        /*
         * Supplier won: Attribute type found with value: pSupplierMetaData
         * Supplier lost: Attribute type found with value: NULL
         */
        if (dwError == 0 && IS_VMDIR_REPL_ATTR_CONFLICT(pSupplierMetaData) == FALSE)
        {
            dwError = VmDirMetaDataSetLocalUsn(pSupplierMetaData, localUsn);
            BAIL_ON_VMDIR_ERROR(dwError);

            VmDirFreeMetaData(pCurrAttr->pMetaData);
            pCurrAttr->pMetaData = pSupplierMetaData;
            pair.pValue = NULL;
        }
        else if (dwError == LW_STATUS_NOT_FOUND) //local/non-replicated attribute
        {
            char  origTimeStamp[VMDIR_ORIG_TIME_STR_LEN] = {'\0'};

            dwError = VmDirGenOriginatingTimeStr(origTimeStamp);
            BAIL_ON_VMDIR_ERROR(dwError);

            dwError = VmDirMetaDataCreate(
                    localUsn,
                    (UINT64) 1,
                    gVmdirServerGlobals.invocationId.lberbv.bv_val,
                    origTimeStamp,
                    localUsn,
                    &pCurrAttr->pMetaData);
            BAIL_ON_VMDIR_ERROR(dwError);
        }
        BAIL_ON_VMDIR_ERROR(dwError);

        VmDirFreeMetaDataMapPair(&pair, NULL);
    }

cleanup:
    return dwError;

error:
    VMDIR_LOG_ERROR(VMDIR_LOG_MASK_ALL, "failed, error (%d)", dwError);
    VmDirFreeMetaDataMapPair(&pair, NULL);
    goto cleanup;
}