Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set TCP listener created sockets to non blocking #4541

Merged
merged 12 commits into from
Sep 10, 2024
37 changes: 37 additions & 0 deletions src/platform/datapath_epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/filter.h>
#include <linux/in6.h>
#include <netinet/udp.h>
#include <fcntl.h>

#ifdef QUIC_CLOG
#include "datapath_epoll.c.clog.h"
Expand Down Expand Up @@ -1578,6 +1579,42 @@ CxPlatSocketContextAcceptCompletion(
&SocketContext->AcceptSocket->RemoteAddress,
&SocketContext->AcceptSocket->RemoteAddress);

a//
ThadHouse marked this conversation as resolved.
Show resolved Hide resolved
// Set non blocking mode
//
Flags =
fcntl(
SocketContext->AcceptSocket->SocketContexts[0].SocketFd,
F_GETFL,
NULL);
if (Flags < 0) {
Status = errno;
QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
SocketContext->Binding,
Status,
"fcntl(F_GETFL) failed");
goto Exit;
}

Flags |= O_NONBLOCK;
Result =
fcntl(
SocketContext->AcceptSocket->SocketContexts[0].SocketFd,
F_SETFL,
Flags);
if (Result < 0) {
Status = errno;
QuicTraceEvent(
DatapathErrorStatus,
"[data][%p] ERROR, %u, %s.",
SocketContext->Binding,
Status,
"fcntl(F_SETFL) failed");
goto Exit;
}

CxPlatSocketContextSetEvents(&SocketContext->AcceptSocket->SocketContexts[0], EPOLL_CTL_ADD, EPOLLIN);
SocketContext->AcceptSocket->SocketContexts[0].IoStarted = TRUE;
Status = Datapath->TcpHandlers.Accept(
Expand Down