Ejemplo n.º 1
0
static
NTSTATUS
SrvTransferConfigContents(
    PLWIO_SRV_CONFIG pSrc,
    PLWIO_SRV_CONFIG pDest
    )
{
    SrvFreeConfigContents(pDest);

    *pDest = *pSrc;

    SrvFreeConfigContents(pSrc);

    return 0;
}
Ejemplo n.º 2
0
NTSTATUS
SrvReadConfig(
    PLWIO_SRV_CONFIG pConfig
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    LWIO_SRV_CONFIG srvConfig = {0};
    PLWIO_CONFIG_REG pReg = NULL;
    BOOLEAN bUsePolicy = TRUE;

    ntStatus = SrvInitConfig(&srvConfig);
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = LwIoOpenConfig(
                    "Services\\lwio\\Parameters\\Drivers\\srv",
                    "Policy\\Services\\lwio\\Parameters\\Drivers\\srv",
                    &pReg);
    if (ntStatus)
    {
        LWIO_LOG_ERROR("Failed to access device configuration [error code: %u]",
                       ntStatus);

        ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
    }
    BAIL_ON_NT_STATUS(ntStatus);

    /* Ignore error as it may not exist; we can still use default. */
    LwIoReadConfigBoolean(
            pReg,
            "BootstrapDefaultSharePath",
            bUsePolicy,
            &srvConfig.bBootstrapDefaultSharePath);

    /* Ignore error as it may not exist; we can still use default. */
    LwIoReadConfigDword(
            pReg,
            "MonitorIntervalMinutes",
            bUsePolicy,
            LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MIN,
            LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MAX,
            &srvConfig.ulMonitorIntervalMinutes);

    ntStatus = SrvTransferConfigContents(&srvConfig, pConfig);
    BAIL_ON_NT_STATUS(ntStatus);

cleanup:

    if (pReg)
    {
        LwIoCloseConfig(pReg);
    }

    SrvFreeConfigContents(&srvConfig);

    return ntStatus;

error:

    goto cleanup;
}
Ejemplo n.º 3
0
NTSTATUS
SrvInitConfig(
    PLWIO_SRV_CONFIG pConfig
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;

    SrvFreeConfigContents(pConfig);

    pConfig->ulMaxNumPackets          = LWIO_SRV_DEFAULT_NUM_MAX_PACKETS;
    pConfig->ulNumWorkers = LWIO_SRV_WORKERS_CPU_RATIO * LwRtlGetCpuCount();
    pConfig->ulMaxNumWorkItemsInQueue = LWIO_SRV_DEFAULT_NUM_MAX_QUEUE_ITEMS;
    pConfig->bBootstrapDefaultSharePath       = FALSE;
    pConfig->ulMonitorIntervalMinutes = LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS;

    return ntStatus;
}
Ejemplo n.º 4
0
static
NTSTATUS
SrvShutdown(
    VOID
    )
{
    NTSTATUS ntStatus = 0;

    // TODO: All existing requests must be waited on to be completed before
    //       shutting down the worker queues.

    if (gSMBSrvGlobals.pMutex)
    {
        pthread_mutex_lock(gSMBSrvGlobals.pMutex);

        if (gSMBSrvGlobals.pWorkerArray)
        {
            INT iWorker = 0;

            for (iWorker = 0; iWorker < gSMBSrvGlobals.ulNumWorkers; iWorker++)
            {
                PLWIO_SRV_WORKER pWorker = &gSMBSrvGlobals.pWorkerArray[iWorker];

                SrvWorkerIndicateStop(pWorker);
            }

            // Must indicate stop for all workers before queueing the
            // unblocks.
            for (iWorker = 0; iWorker < gSMBSrvGlobals.ulNumWorkers; iWorker++)
            {
                SrvUnblockOneWorker(&gSMBSrvGlobals.workQueue);
            }

            for (iWorker = 0; iWorker < gSMBSrvGlobals.ulNumWorkers; iWorker++)
            {
                PLWIO_SRV_WORKER pWorker = &gSMBSrvGlobals.pWorkerArray[iWorker];

                SrvWorkerFreeContents(pWorker);
            }

            SrvFreeMemory(gSMBSrvGlobals.pWorkerArray);
            gSMBSrvGlobals.pWorkerArray = NULL;
        }

        SrvProtocolShutdown();

        SrvStatisticsShutdown();

        SrvElementsShutdown();

        SrvShareFreeListContents(&gSMBSrvGlobals.shareList);

        SrvShareShutdown();

        SrvProdConsFreeContents(&gSMBSrvGlobals.workQueue);

        if (gSMBSrvGlobals.hPacketAllocator)
        {
            SMBPacketFreeAllocator(gSMBSrvGlobals.hPacketAllocator);
            gSMBSrvGlobals.hPacketAllocator = NULL;
        }

        SrvFreeConfigContents(&gSMBSrvGlobals.config);

        pthread_mutex_unlock(gSMBSrvGlobals.pMutex);
        gSMBSrvGlobals.pMutex = NULL;
    }

    return ntStatus;
}