Re: innocuous: pgbench does FD_ISSET on invalid socket

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: innocuous: pgbench does FD_ISSET on invalid socket
Date: 2016-02-15 06:34:45
Message-ID: CAB7nPqSjGq7bYjh6KvkaW_na31Yq=GsJt+7GLh59AxDPSQ=bBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Feb 15, 2016 at 3:20 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Sat, Feb 13, 2016 at 6:25 AM, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>> I noticed that pgbench calls FD_ISSET on a socket returned by
>> PQsocket() without first checking that it's not invalid. I don't think
>> there's a real problem here because the socket was already checked a few
>> lines above, but I think applying the same coding pattern to both places
>> is cleaner.
>>
>> Any objections to changing it like this? I'd probably backpatch to 9.5,
>> but no further (even though this pattern actually appears all the way
>> back.)
>
> Not really, +1 for consistency here, and this makes the code clearer.
>
> Different issues in the same area:
> 1) In vacuumdb.c, init_slot() does not check for the return value of PQsocket():
> slot->sock = PQsocket(conn);
> 2) In isolationtester.c, try_complete_step() should do the same.
> 3) In pg_recvlogical.c for StreamLogicalLog() I am spotting the same problem.
> I guess those ones should be fixed as well, no?

With a patch, that's even better.
--
Michael

Attachment Content-Type Size
pqsocket-error-fix.patch text/x-diff 2.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-02-15 07:10:19 Re: extend pgbench expressions with functions
Previous Message Rushabh Lathia 2016-02-15 06:20:20 Re: Optimization for updating foreign tables in Postgres FDW