Re: BUG #16678: The ecpg connect/test5 test sometimes fails on Windows
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Date: 2020-10-24T17:39:05Z
Lists: pgsql-bugs
Alexander Lakhin <exclusion@gmail.com> writes:
> So I've also tested on Windows the following version:
> secure_close(MyProcPort);
> shutdown(MyProcPort->sock, SD_SEND);
> for(;;) {
> char buffer[1000];
> int res = recv(MyProcPort->sock, buffer, 1000, 0);
> if (res <= 0)
> break;
> }
> closesocket(MyProcPort->sock);
> And it works too.
I'm afraid this cure is probably worse than the disease, because
now the backend's exiting is held hostage by whether the client
closes its socket (and the resulting FIN reaches us, which it
might not if there's a network problem).
It might be safe to do the shutdown() only, since Microsoft
specifies that that doesn't block, but I have no idea if that
would improve matters.
regards, tom lane
Commits
-
On Windows, close the client socket explicitly during backend shutdown.
- 00cd81723cd0 10.20 landed
- a87c8c3edd7f 11.15 landed
- 3e644dcca1e9 12.10 landed
- 6251f86241ac 13.6 landed
- 4cd2928543c1 14.2 landed
- 6051857fc953 15.0 landed