Re: Sometimes the output to the stdout in Windows disappears

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: Victor Spirin <v(dot)spirin(at)postgrespro(dot)ru>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Sometimes the output to the stdout in Windows disappears
Date: 2020-10-17 18:44:37
Message-ID: 132799.1602960277@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> Alexander Lakhin <exclusion(at)gmail(dot)com> writes:
>> What bothers me is:
>> There must be a call to *WSACleanup* for each successful call to
>> WSAStartup
>> <https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-wsastartup>.

> Yeah, that is a very odd statement. Surely, the Windows kernel manages
> to cope if a program crashes without having done that. So what exactly
> is the downside of intentionally not doing it?

A bit of grepping showed me that the backend, initdb, and pg_regress
all call WSAStartup without ever doing WSACleanup, and we've seen no
ill effects from that. So it seems clear that this documentation can
safely be ignored.

I propose the attached patch. If this doesn't cause buildfarm problems,
perhaps we should back-patch it.

BTW, I notice that libpq is asking WSAStartup for Winsock version 1.1,
which is remarkably ancient. Almost everyplace else is asking for
version 2.2, which has been current for a decade or two. Shouldn't
we update that? (It occurs to me to wonder if this in itself is
some kind of problem; I wonder how well Winsock works when there are
requests for different API versions in the same program.)

regards, tom lane

Attachment Content-Type Size
remove-WSACleanup-calls.patch text/x-diff 3.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2020-10-17 19:21:34 Re: jit and explain nontext
Previous Message Tom Lane 2020-10-17 16:28:51 Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view?