From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Clean up messy API for src/port/thread.c.
Date: Tue, 11 Jan 2022 18:46:42 +0000
Message-ID: <E1n7MAM-0003OO-A3@gemulon.postgresql.org> (raw)
Clean up messy API for src/port/thread.c.
The point of this patch is to reduce inclusion spam by not needing
to #include <netdb.h> or <pwd.h> in port.h (which is read by every
compile in our tree). To do that, we must remove port.h's
declarations of pqGetpwuid and pqGethostbyname.
pqGethostbyname is only used, and is only ever likely to be used,
in src/port/getaddrinfo.c --- which isn't even built on most
platforms, making pqGethostbyname dead code for most people.
Hence, deal with that by just moving it into getaddrinfo.c.
To clean up pqGetpwuid, invent a couple of simple wrapper
functions with less-messy APIs. This allows removing some
duplicate error-handling code, too.
In passing, remove thread.c from the MSVC build, since it
contains nothing we use on Windows.
Noted while working on 376ce3e40.
Discussion: https://postgr.es/m/1634252654444.90107@mit.edu
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/98e93a1fc93e9b54eb477d870ec744e9e1669f34
Modified Files
--------------
src/backend/libpq/auth.c | 1 +
src/bin/psql/common.c | 1 +
src/include/port.h | 14 ++----
src/interfaces/libpq/fe-auth.c | 54 ++++++++++++----------
src/interfaces/libpq/fe-auth.h | 1 +
src/interfaces/libpq/fe-connect.c | 40 ++++------------
src/port/Makefile | 4 ++
src/port/getaddrinfo.c | 44 ++++++++++++++++++
src/port/path.c | 11 +----
src/port/thread.c | 96 +++++++++++++++++++++++++--------------
src/tools/msvc/Mkvcbuild.pm | 2 +-
11 files changed, 158 insertions(+), 110 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Clean up messy API for src/port/thread.c.
In-Reply-To: <E1n7MAM-0003OO-A3@gemulon.postgresql.org>
References: <E1n7MAM-0003OO-A3@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox