pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
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: Tue, 2 Jun 2020 13:27:48 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2006021258170.87735@pseudo> (raw)
In-Reply-To: <CAApHDvpMEAaZMxtzixbnb7ySo=Kb1eUfshEB-y4YOm8SgGrpiw@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>


Attached is a blind attempt at working around the issue based on what you 
show below, that I cannot test.

> typedef struct fd_set {
>        u_int fd_count;               /* how many are SET? */
>        SOCKET  fd_array[FD_SETSIZE];   /* an array of SOCKETs */
> } fd_set;
>
> #define FD_SET(fd, set) do { \
>    u_int __i; \
>    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
>        if (((fd_set FAR *)(set))->fd_array[__i] == (fd)) { \
>            break; \
>        } \
>    } \
>    if (__i == ((fd_set FAR *)(set))->fd_count) { \
>        if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
>            ((fd_set FAR *)(set))->fd_array[__i] = (fd); \
>            ((fd_set FAR *)(set))->fd_count++; \
>        } \
>    } \
> } while(0, 0)

-- 
Fabien.

Attachments:

pgbench-select-win-1.patch (text/x-diff, 861B) download diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 08a5947a9e..0c96384ecb 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 BAD_FD_SETSIZE(fd, set) ((fd) < 0 || (fd) >= FD_SETSIZE) +#else +/* + * Windows implementation is bogus: it does not allocated fd with the lowest + * possible number, and FD_SET is implemented as a simple array. + * + * Filling the set is in O(N^2). + */ +#define BAD_FD_SETSIZE(fd, set) ((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 (BAD_FD_SETSIZE(fd, &sa->fds)) { /* * Doing a hard exit here is a bit grotty, but it doesn't seem worth

view thread (26+ messages)  latest in thread

Message-ID: <alpine.DEB.2.22.394.2006021258170.87735@pseudo>
Permalink:  ../alpine.DEB.2.22.394.2006021258170.87735@pseudo/
Also on:    postgresql.org/message-id/alpine.DEB.2.22.394.2006021258170.87735@pseudo

 ·  · 

reply

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.2006021258170.87735@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