Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion reflector/TCSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ bool CTCServer::Receive(char module, STCPacket *packet, int ms)
auto pfds = &m_Pfd[pos];
if (pfds->fd < 0)
{
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
return rv;
}

Expand Down Expand Up @@ -287,7 +288,7 @@ bool CTCServer::Accept()
wmod.append(1, c);
}

std::cout << "Waiting at " << m_Ip << " for transcoder connection";
std::cout << "Checking " << m_Ip << " for transcoder connection";
if (wmod.size() > 1)
{
std::cout << "s for modules ";
Expand All @@ -298,8 +299,23 @@ bool CTCServer::Accept()
}
std::cout << wmod << "..." << std::endl;

struct pollfd pfd;
pfd.fd = fd;
pfd.events = POLLIN;

while (AnyAreClosed())
{
auto p = poll(&pfd, 1, 100); // 100ms timeout
if (p < 0)
{
perror("Accept poll");
close(fd);
Close();
return true;
}
if (0 == p)
break; // No more pending connections for now

if (acceptone(fd))
{
close(fd);
Expand Down