1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:47:34 +00:00

RequestServer: Recreate socket if it reached EOF

This ensures we don't continue using a socket that has EOF'ed (meaning
the protocol has disconnected in the case of TCP) for new requests.
This commit is contained in:
Idan Horowitz 2022-02-11 17:33:57 +02:00
parent 75fe51a9ca
commit 873f4d5de6

View file

@ -106,7 +106,7 @@ template<typename T>
ErrorOr<void> recreate_socket_if_needed(T& connection, URL const& url)
{
using SocketType = typename T::SocketType;
if (!connection.socket->is_open()) {
if (!connection.socket->is_open() || connection.socket->is_eof()) {
// Create another socket for the connection.
auto set_socket = [&](auto socket) -> ErrorOr<void> {
connection.socket = TRY(Core::Stream::BufferedSocket<SocketType>::create(move(socket)));