示例#1
0
//--------------------------------------------------------------------------------------------------
static WatchdogObj_t* GetClientWatchdogPtr
(
    void
)
{
    /* Get the user id of the client */
    uid_t clientUserId;
    pid_t clientProcId;
    le_msg_SessionRef_t sessionRef = le_wdog_GetClientSessionRef();
    WatchdogObj_t* watchdogPtr = NULL;

    if (LE_OK == le_msg_GetClientUserCreds(sessionRef, &clientUserId, &clientProcId))
    {
        watchdogPtr = LookupClientWatchdogPtrById(clientProcId);
        if (watchdogPtr == NULL)
        {
            watchdogPtr = CreateNewWatchdog(clientProcId, clientUserId);
            AddWatchdog(watchdogPtr);
        }
    }
    else
    {
        LE_WARN("Can't find client Id. The client may have closed the session.");
    }
    return watchdogPtr;
}
示例#2
0
//--------------------------------------------------------------------------------------------------
static void CleanUpClosedClient
(
    le_msg_SessionRef_t sessionRef,
    void*               contextPtr
)
{
    uid_t clientUserId;
    pid_t clientProcId;

    LE_INFO("Client session closed");
    if (LE_OK == le_msg_GetClientUserCreds(sessionRef, &clientUserId, &clientProcId))
    {
        DeleteWatchdog(clientProcId);
    }
}
示例#3
0
//--------------------------------------------------------------------------------------------------
le_avdata_AssetInstanceRef_t le_avdata_Create
(
    const char* assetName
        ///< [IN]
)
{
    // Get the client's credentials.
    pid_t pid;
    uid_t uid;

    if (le_msg_GetClientUserCreds(le_avdata_GetClientSessionRef(), &uid, &pid) != LE_OK)
    {
        LE_KILL_CLIENT("Could not get credentials for the client.");
        return NULL;
    }


    // Look up the process's application name.
    char appName[LE_LIMIT_APP_NAME_LEN+1];

    le_result_t result = le_appInfo_GetName(pid, appName, sizeof(appName));
    LE_FATAL_IF(result == LE_OVERFLOW, "Buffer too small to contain the application name.");

    // TODO: Should this be LE_KILL_CLIENT instead?
    LE_FATAL_IF(result != LE_OK, "Could not get app name");


    // Create an instance of the asset
    assetData_InstanceDataRef_t instRef;
    int instanceId;

    LE_ASSERT( assetData_CreateInstanceByName(appName, assetName, -1, &instRef) == LE_OK );
    LE_ASSERT( instRef != NULL );
    LE_ASSERT( assetData_GetInstanceId(instRef, &instanceId) == LE_OK );
    LE_PRINT_VALUE("%i", instanceId);

    // Return a safe reference for the instance
    InstanceRefData_t* instRefDataPtr = le_mem_ForceAlloc(InstanceRefDataPoolRef);

    instRefDataPtr->clientSessionRef = le_avdata_GetClientSessionRef();
    instRefDataPtr->instRef = instRef;

    instRef = le_ref_CreateRef(InstanceRefMap, instRefDataPtr);

    return instRef;
}