예제 #1
0
//--------------------------------------------------------------------------------------------------
static void StartMonitoringDirectorySocket
(
    Service_t*  servicePtr
)
//--------------------------------------------------------------------------------------------------
{
    le_event_FdHandlerRef_t handlerRef;

    char name[128];
    size_t bytes;
    le_utf8_Copy(name, le_msg_GetProtocolIdStr(servicePtr->id.protocolRef), sizeof(name), &bytes);
    le_utf8_Copy(name + bytes, servicePtr->id.name, sizeof(name) - bytes, NULL);

    servicePtr->fdMonitorRef = le_event_CreateFdMonitor(name, servicePtr->directorySocketFd);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_READABLE,
                                       DirectorySocketReadable);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_READ_HANG_UP,
                                       DirectorySocketClosed);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_WRITE_HANG_UP,
                                       DirectorySocketClosed);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_ERROR,
                                       DirectorySocketError);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);
}
예제 #2
0
//--------------------------------------------------------------------------------------------------
static void StartMonitoringDirectorySocket
(
    Service_t*  servicePtr
)
//--------------------------------------------------------------------------------------------------
{
    le_event_FdHandlerRef_t handlerRef;

    char name[LIMIT_MAX_MEM_POOL_NAME_BYTES];
    char* destPtr = name;
    size_t spaceLeft = sizeof(name);
    size_t bytesCopied;
    le_utf8_Copy(destPtr, servicePtr->id.name, spaceLeft, &bytesCopied);
    destPtr += bytesCopied;
    spaceLeft -= bytesCopied;
    le_utf8_Copy(destPtr, ":", spaceLeft, &bytesCopied);
    destPtr += bytesCopied;
    spaceLeft -= bytesCopied;
    le_utf8_Copy(destPtr, le_msg_GetProtocolIdStr(servicePtr->id.protocolRef), spaceLeft, NULL);

    servicePtr->fdMonitorRef = le_event_CreateFdMonitor(name, servicePtr->directorySocketFd);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_WRITEABLE,
                                       DirectorySocketWriteable);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_READABLE,
                                       DirectorySocketReadable);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_READ_HANG_UP,
                                       DirectorySocketClosed);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_WRITE_HANG_UP,
                                       DirectorySocketClosed);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);

    handlerRef = le_event_SetFdHandler(servicePtr->fdMonitorRef,
                                       LE_EVENT_FD_ERROR,
                                       DirectorySocketError);
    le_event_SetFdHandlerContextPtr(handlerRef, servicePtr);
}