Exemplo n.º 1
0
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());
}
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());
}