From: Fabien COELHO <coelho@cri.ensmp.fr>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Jawarilal, Manish <Manish.Jawarilal@dell.com>
Cc: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: pgbench bug / limitation
Date: Fri, 5 Jun 2020 06:44:33 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2006050637420.213031@pseudo> (raw)
In-Reply-To: <CAApHDvpDBkjj6a+Ld-9YGW=_Bcxss8Yyz_QYjtjus3WUsTb+1g@mail.gmail.com>
References: <BL0PR1901MB1985F219C46C61EDE7036C34ED8E0@BL0PR1901MB1985.namprd19.prod.outlook.com>
<7221.1590687090@sss.pgh.pa.us>
<BL0PR1901MB1985A8B4D3E5B39E32A9EA55ED8F0@BL0PR1901MB1985.namprd19.prod.outlook.com>
<10327.1590763515@sss.pgh.pa.us>
<BL0PR1901MB198583EAC6C8A3B770D20F1AED8A0@BL0PR1901MB1985.namprd19.prod.outlook.com>
<384920.1591027137@sss.pgh.pa.us>
<CAApHDvrjWtJa9oQ98oH+9PCvTgOkGZP+gcmottNX95sjn6o9fQ@mail.gmail.com>
<512846.1591057287@sss.pgh.pa.us>
<CAApHDvpMEAaZMxtzixbnb7ySo=Kb1eUfshEB-y4YOm8SgGrpiw@mail.gmail.com>
<alpine.DEB.2.22.394.2006021258170.87735@pseudo>
<CAApHDvpDBkjj6a+Ld-9YGW=_Bcxss8Yyz_QYjtjus3WUsTb+1g@mail.gmail.com>
Hello David,
> On Tue, 2 Jun 2020 at 23:27, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>> Attached is a blind attempt at working around the issue based on what you
>> show below, that I cannot test.
>
> I suppose we might be able to do something like that. It does expose
> us to the implementation of Microsoft's fd_set struct, but surely the
> shape of that must be pretty much fixed since if it were to be changed
> then software that's already compiled would break.
Yep. I cannot seen how to do it without some assumption about the
underlying implementation. I agree that it breaks the very principle of
the interface, which is to hide fdset implementation details.
> I tested the patch on a Windows machine
Thanks.
> and it seems to work.
Good.
> I'm not much a fan of the naming of the new macro though. Wouldn't it
> be better to reverse the logic and call it IS_VALID_FD?
I hesitated. Here it is with a inversion/renaming, and a check that fd is
positive on windows. I renamed to "FD_IS_VALID" which seems to read
better.
--
Fabien.
Attachments:pgbench-select-win-2.patch (text/x-diff, 864B) downloaddiff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.cindex 08a5947a9e..23f357315f 100644--- a/src/bin/pgbench/pgbench.c+++ b/src/bin/pgbench/pgbench.c@@ -6698,10 +6698,22 @@ clear_socket_set(socket_set *sa)
sa->maxfd = -1;
}
+#ifndef WIN32+#define FD_IS_VALID(fd, set) ((fd) >= 0 && (fd) < FD_SETSIZE)+#else+/*+ * Windows implementation is bogus: it does not allocate fd with the lowest+ * possible number, and FD_SET is implemented as a simple array.+ *+ * Filling the set is in O(N^2).+ */+#define FD_IS_VALID(fd, set) ((fd) >= 0 && (set)->fd_count < FD_SETSIZE)+#endif /* WIN32 */+
static void
add_socket_to_set(socket_set *sa, int fd, int idx)
{
- if (fd < 0 || fd >= FD_SETSIZE)+ if (!FD_IS_VALID(fd, &sa->fds))
{
/*
* Doing a hard exit here is a bit grotty, but it doesn't seem worth
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: coelho@cri.ensmp.fr, dgrowleyml@gmail.com, tgl@sss.pgh.pa.us, Manish.Jawarilal@dell.com, pgsql-bugs@lists.postgresql.org
Subject: Re: pgbench bug / limitation
In-Reply-To: <alpine.DEB.2.22.394.2006050637420.213031@pseudo>
* 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