Re: BUG #16678: The ecpg connect/test5 test sometimes fails on Windows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16678: The ecpg connect/test5 test sometimes fails on Windows
Date: 2020-10-24 17:39:05
Message-ID: 383222.1603561145@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Alexander Lakhin <exclusion(at)gmail(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Lakhin 2020-10-24 18:00:00 Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows
Previous Message Tom Lane 2020-10-24 16:54:23 Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows