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

Prevent TcpTransport initialization errors from stopping TcpServer #1175

Merged
merged 2 commits into from
May 11, 2024
Merged
Changes from 1 commit
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
Next Next commit
Prevent TcpTransport initialization errors from stopping TcpServer
paullouisageneau committed May 11, 2024
commit 4978ea7e331989d7b1fe5c71b9ef94976d54adf4
8 changes: 6 additions & 2 deletions src/impl/tcpserver.cpp
Original file line number Diff line number Diff line change
@@ -66,8 +66,12 @@ shared_ptr<TcpTransport> TcpServer::accept() {
socket_t incomingSock = ::accept(mSock, (struct sockaddr *)&addr, &addrlen);

if (incomingSock != INVALID_SOCKET) {
return std::make_shared<TcpTransport>(incomingSock, nullptr); // no state callback

try {
return std::make_shared<TcpTransport>(incomingSock, nullptr); // no state callback
} catch(const std::exception &e) {
PLOG_WARNING << e.what();
::closesocket(incomingSock);
}
} else if (sockerrno != SEAGAIN && sockerrno != SEWOULDBLOCK) {
PLOG_ERROR << "TCP server failed, errno=" << sockerrno;
throw std::runtime_error("TCP server failed");