Fix a possible socket leak at Windows (src/backend/port/win32/socket.c)

Ranier Vilela <ranier.vf@gmail.com>

From: Ranier Vilela <ranier.vf@gmail.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2024-01-13T21:38:13Z
Lists: pgsql-hackers

Attachments

Hi.

While there are plans to remove the sockets functions (Windows) [1], I
believe it is worth fixing possible current bugs.

In the pgwin32_socket function (src/backend/port/win32/socket.c), there is
a possible socket leak if the socket cannot be made non-blocking.

Trivial patch attached.

Best regards,
Ranier Vilela

[1] Re: Windows sockets (select missing events?)
<https://www.postgresql.org/message-id/CA%2BhUKGKSLgxFhSP8%2BdqQqHsuZvrRRU3wZ6ytLOcno-mdGvckHg%40mail.gmail.com>

Commits

  1. Close socket in case of errors in setting non-blocking