Skip to content

Commit

Permalink
Use minus 1 instead of errno to indicate system poll error (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
harryz2000 authored Oct 21, 2024
1 parent b4e640b commit 9e114f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/SystemPoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ std::pair<uint16_t, int> SystemPoll::GetEvents(int fd) const

if ((revents & POLLHUP) || (revents & POLLERR))
{
return std::make_pair<>(0, errno);
Error("-SystemPoll::GetEvents() | Error events: 0x%x fd: %d errno: %d\n", revents, fd, errno);
return std::make_pair<>(0, -1);
}

if (revents & POLLIN)
Expand Down Expand Up @@ -182,7 +183,10 @@ int SystemPoll::Wait(uint32_t timeOutMs)

// Wait for events
if (poll(syspfds.data(), syspfds.size(),timeOutMs) < 0)
return errno;
{
Error("-SystemPoll::Wait() | poll() error. errno: %d\n", errno);
return -1;
}

// Copy back
for (size_t i = 0; i < syspfds.size(); i++)
Expand All @@ -193,7 +197,8 @@ int SystemPoll::Wait(uint32_t timeOutMs)
if ((revents & POLLHUP) || (revents & POLLERR))
{
signalling.ClearSignal();
return errno;
Error("-SystemPoll::Wait() | Error events: 0x%x fd: %d errno: %d\n", revents, syspfds[i].fd, errno);
return -1;
}
else if (revents & POLLIN)
{
Expand Down
2 changes: 1 addition & 1 deletion src/rtmp/rtmpclientconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void RTMPClientConnection::OnPollIn(int fd)
int len = read(fd, buffer, BufferSize);
if (len == 0)
{
Error("-RTMPClientConnection::OnPollIn() Peer closed");
Error("-RTMPClientConnection::OnPollIn() Peer closed\n");
SetStopping(ToUType(RTMPClientConnection::ErrorCode::PeerClosed));
}

Expand Down
4 changes: 2 additions & 2 deletions src/rtmp/rtmpserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int RTMPServer::Run()
if (poll(ufds,1,-1)<0)
{
//Error
Error("-RTMPServer::Run() pool error [fd:%d,errno:%d]\n",ufds[0].fd,errno);
Error("-RTMPServer::Run() poll error [fd:%d,errno:%d]\n",ufds[0].fd,errno);
//Check if already inited
if (!inited)
//Exit
Expand All @@ -145,7 +145,7 @@ int RTMPServer::Run()
if (ufds[0].revents!=POLLIN)
{
//Error
Error("-RTMPServer::Run() poolin error event [event:%d,fd:%d,errno:%d]\n",ufds[0].revents,ufds[0].fd,errno);
Error("-RTMPServer::Run() pollin error event [event:%d,fd:%d,errno:%d]\n",ufds[0].revents,ufds[0].fd,errno);
//Check if already inited
if (!inited)
//Exit
Expand Down

0 comments on commit 9e114f7

Please sign in to comment.