Re: Fwd: race in pg_ctl start -w - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Re: Fwd: race in pg_ctl start -w
Date
Msg-id 50805A52.6050009@vmware.com
Whole thread Raw
In response to Re: Fwd: race in pg_ctl start -w  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-bugs
On 18.10.2012 22:15, Alvaro Herrera wrote:
> Dave Vitek wrote:
>
>> Heikki,
>>
>> It's happy about the overruns.  It did flag an issue where the file
>> descriptor can leak when the various early returns get taken.
>
> This is a common problem with static analysers; they don't realise we
> don't care about the leaked resource because the program is shortly
> going to terminate anyway.  We (used to?) have plenty of false positives
> in initdb as reported in the Coverity scanner, for example.

Actually, this was a real leak. I should've put close() calls to the
cases where the file is empty, or fstat() fails. It doesn't matter when
the function is called only once, but in the "pg_ctl start -w" case it's
called repeatedly to poll for postmaster startup.

Fixed, and I also changed it to not return the last line if it doesn't
end in a newline, per Tom's suggestion.

- Heikki

pgsql-bugs by date:

Previous
From: Gezeala M. Bacuño II
Date:
Subject: Re: BUG #7521: Cannot disable WAL log while using pg_dump
Next
From: henrique.assessoria@hotmail.com
Date:
Subject: BUG #7613: INTIDB