Skip to content

Commit

Permalink
[API] Removed setting +W for a listener socket after accept ready (#2732
Browse files Browse the repository at this point in the history
).
  • Loading branch information
ethouris authored Sep 2, 2024
1 parent 9c7206f commit a6ca566
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
21 changes: 6 additions & 15 deletions srtcore/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11032,6 +11032,11 @@ int srt::CUDT::processConnectRequest(const sockaddr_any& addr, CPacket& packet)

HLOGC(cnlog.Debug, log << CONID() << "processConnectRequest: received a connection request");

// NOTE (IMPORTANT!!!)
//
// The current CUDT object represents a LISTENER SOCKET to which
// the request was redirected from the receiver queue.

if (m_bClosing)
{
m_RejectReason = SRT_REJ_CLOSE;
Expand Down Expand Up @@ -11316,21 +11321,7 @@ int srt::CUDT::processConnectRequest(const sockaddr_any& addr, CPacket& packet)
}
}

if (result == 1)
{
// BUG! There is no need to update write-readiness on the listener socket once new connection is accepted.
// Only read-readiness has to be updated, but it is done so in the newConnection(..) function.
// See PR #1831 and issue #1667.
HLOGC(cnlog.Debug,
log << CONID() << "processConnectRequest: accepted connection, updating epoll to write-ready");

// New connection has been accepted or an existing one has been found. Update epoll write-readiness.
// a new connection has been created, enable epoll for write
// Note: not using SRT_EPOLL_CONNECT symbol because this is a procedure
// executed for the accepted socket.
uglobal().m_EPoll.update_events(m_SocketID, m_sPollID, SRT_EPOLL_OUT, true);
}
else if (result == -1)
if (result == -1)
{
// The new connection failed
// or the connection already existed, but manually sending the HS response above has failed.
Expand Down
4 changes: 2 additions & 2 deletions testing/testmedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void SrtCommon::PrepareListener(string host, int port, int backlog)

if (!m_blocking_mode)
{
srt_conn_epoll = AddPoller(m_bindsock, SRT_EPOLL_OUT);
srt_conn_epoll = AddPoller(m_bindsock, SRT_EPOLL_IN);
}

auto sa = CreateAddr(host, port);
Expand Down Expand Up @@ -547,7 +547,7 @@ void SrtCommon::AcceptNewClient()

int len = 2;
SRTSOCKET ready[2];
while (srt_epoll_wait(srt_conn_epoll, 0, 0, ready, &len, 1000, 0, 0, 0, 0) == -1)
while (srt_epoll_wait(srt_conn_epoll, ready, &len, 0, 0, 1000, 0, 0, 0, 0) == -1)
{
if (::transmit_int_state)
Error("srt_epoll_wait for srt_accept: interrupt");
Expand Down

0 comments on commit a6ca566

Please sign in to comment.