コード例 #1
0
ファイル: socket-manager.cpp プロジェクト: Samsung/ckm
void SocketManager::CynaraSocket(int oldFd, int newFd, bool isRW)
{
    if (newFd != oldFd) {
        if (newFd >= 0) {
            auto &desc = CreateDefaultReadSocketDescription(newFd, false);
            desc.service = nullptr;
            desc.setCynara(true);
        }

        if (oldFd >= 0) {
            auto &old = m_socketDescriptionVector[oldFd];
            old.setOpen(false);
            old.setCynara(false);
            FD_CLR(oldFd, &m_writeSet);
            FD_CLR(oldFd, &m_readSet);
        }
    }

    if (newFd >= 0) {
        FD_SET(newFd, &m_readSet);

        if (isRW)
            FD_SET(newFd, &m_writeSet);
        else
            FD_CLR(newFd, &m_writeSet);
    }
}
コード例 #2
0
ファイル: socket-manager.cpp プロジェクト: Samsung/ckm
void SocketManager::CreateDomainSocket(
    GenericSocketService *service,
    const GenericSocketService::ServiceDescription &desc)
{
    int sockfd = GetSocketFromSystemD(desc);
    if (-1 == sockfd)
        sockfd = CreateDomainSocketHelp(desc);

    auto &description = CreateDefaultReadSocketDescription(sockfd, false);

    description.setListen(true);
    description.interfaceID = desc.interfaceID;
    description.service = service;
    description.cynaraPrivilege = desc.privilege;

    LogDebug("Listen on socket: " << sockfd <<
        " Handler: " << desc.serviceHandlerPath.c_str());
}
コード例 #3
0
void SocketManager::CreateDomainSocket(
    GenericSocketService *service,
    const GenericSocketService::ServiceDescription &desc)
{
    int sockfd = GetSocketFromSystemD(desc);
    if (-1 == sockfd) {
        if (desc.systemdOnly) {
            LogError("Socket " << desc.serviceHandlerPath << " not provided by systemd.");
            ThrowMsg(Exception::InitFailed, "Socket " << desc.serviceHandlerPath <<
                " must be provided by systemd, but it was not.");
        }
        sockfd = CreateDomainSocketHelp(desc);
    }

    auto &description = CreateDefaultReadSocketDescription(sockfd, false);

    description.isListen = true;
    description.interfaceID = desc.interfaceID;
    description.useSendMsg = desc.useSendMsg;
    description.service = service;

    LogDebug("Listen on socket: " << sockfd <<
        " Handler: " << desc.serviceHandlerPath.c_str());
}