Big disconnect_and_exit cleanup in pg_basebackup

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Magnus Hagander <magnus(at)hagander(dot)net>, Hans-Jürgen Schönig <hs(at)cybertec(dot)at>
Subject: Big disconnect_and_exit cleanup in pg_basebackup
Date: 2013-01-02 16:17:59
Message-ID: 50E45DB7.3020306@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

the previously sent "factor out pg_malloc and friends" patch
may call exit() in case of OOM during allocation and as a consequence,
PQfinish() won't get called, leaving an "unexpected EOF from client"
in the log.

Let's close this annoyance in pg_basebackup. The attached patch does
the following:

- adds a PQfinish() (actually PQfinishSafe()) call that was just posted
in another thread
- replace all PQfinish() and PQclear() with their *Safe counterpart so
a normal execution won't result in a crash because of calling PQfinish()
on a stale pointer
- kill the disconnect_and_exit() macro, replace it with plain exit(),
the atexit callback does the disconnect anyway.

Best regards,
Zoltán Böszörményi

--
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt, Austria
Web: http://www.postgresql-support.de
http://www.postgresql.at/

Attachment Content-Type Size
pg_basebackup-disconnect-on-exit-cleanup-v2.patch text/x-patch 17.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-01-02 16:20:21 Re: Minor fix in 'clean' action of 'src/backend/Makefile'
Previous Message Fabrízio de Royes Mello 2013-01-02 16:05:17 Minor fix in 'clean' action of 'src/backend/Makefile'