Exemplo n.º 1
0
static
void
__LwSmIpcCallInit(
    void
    )
{
    DWORD dwError = 0;
    
    dwError = MAP_LWMSG_STATUS(lwmsg_protocol_new(NULL, &gpProtocol));
    BAIL_ON_ERROR(dwError);

    dwError = MAP_LWMSG_STATUS(lwmsg_protocol_add_protocol_spec(
                                   gpProtocol,
                                   LwSmIpcGetProtocolSpec()));
    BAIL_ON_ERROR(dwError);

    dwError = MAP_LWMSG_STATUS(lwmsg_peer_new(NULL, gpProtocol, &gpClient));
    BAIL_ON_ERROR(dwError);
    
    dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_connect_endpoint(
                                   gpClient, 
                                   (LWMsgEndpointType)LWMSG_CONNECTION_MODE_LOCAL,
                                   SM_ENDPOINT));
    BAIL_ON_ERROR(dwError);
    
    dwError = MAP_LWMSG_STATUS(lwmsg_peer_connect(
                                   gpClient,
                                   &gpSession));
    BAIL_ON_ERROR(dwError);

cleanup:
    
    gOnceError = dwError;

    return;
    
error:
    
    if (gpClient)
    {
        lwmsg_peer_delete(gpClient);
    }
    
    if (gpProtocol)
    {
        lwmsg_protocol_delete(gpProtocol);
    }

    goto cleanup;
}
Exemplo n.º 2
0
static
DWORD
LwSmStartIpcServer(
    VOID
    )
{
    DWORD dwError = 0;

    SM_LOG_VERBOSE("Starting IPC server");

    if (!gState.bContainer)
    {
        dwError = MAP_LWMSG_STATUS(lwmsg_protocol_new(gState.pIpcContext, &gState.pContolProtocol));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_protocol_add_protocol_spec(
            gState.pContolProtocol,
            LwSmIpcGetProtocolSpec()));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_new(
            gState.pIpcContext,
            gState.pContolProtocol,
            &gState.pControlServer));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_dispatch_spec(
            gState.pControlServer,
            LwSmGetDispatchSpec()));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_listen_endpoint(
            gState.pControlServer,
            LWMSG_ENDPOINT_LOCAL,
            SM_ENDPOINT,
            0666));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_start_listen(gState.pControlServer));
        BAIL_ON_ERROR(dwError);
    }

    dwError = MAP_LWMSG_STATUS(lwmsg_peer_new(
        gState.pIpcContext,
        gState.pContainerProtocol,
        &gState.pContainerServer));
    BAIL_ON_ERROR(dwError);

    if (gState.bContainer)
    {
        dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_dispatch_spec(
            gState.pContainerServer,
            LwSmGetContainerDispatchSpec()));
        BAIL_ON_ERROR(dwError);

        if (!gState.pGroup)
        {
            dwError = MAP_LWMSG_STATUS(lwmsg_peer_accept_fd(
                gState.pContainerServer,
                LWMSG_ENDPOINT_PAIR,
                4));
            BAIL_ON_ERROR(dwError);
        }
        else
        {
            dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_connect_endpoint(
                gState.pContainerServer,
                LWMSG_ENDPOINT_LOCAL,
                SC_ENDPOINT));
            BAIL_ON_ERROR(dwError);

            dwError = LwSmContainerRegister(gState.pContainerServer, gState.pGroup);
            BAIL_ON_ERROR(dwError);
        }
    }
    else
    {
        dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_listen_endpoint(
            gState.pContainerServer,
            LWMSG_ENDPOINT_LOCAL,
            SC_ENDPOINT,
            0666));

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_add_dispatch_spec(
            gState.pContainerServer,
            LwSmGetContainerRegisterDispatchSpec()));
        BAIL_ON_ERROR(dwError);

        dwError = MAP_LWMSG_STATUS(lwmsg_peer_start_listen(gState.pContainerServer));
        BAIL_ON_ERROR(dwError);
    }

cleanup:

    return dwError;

error:

    goto cleanup;
}