pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: bianpan2016@163.com
To: pgsql-bugs@lists.postgresql.org
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Re: BUG #15105: OpenTransientFile() should be paired with CloseTransientFile() rather than close()
Date: Fri, 9 Mar 2018 13:40:52 +0900
Message-ID: <20180309044052.GC1416@paquier.xyz> (raw)
In-Reply-To: <152056616579.4966.583293218357089052@wrigleys.postgresql.org>
References: <152056616579.4966.583293218357089052@wrigleys.postgresql.org>

On Fri, Mar 09, 2018 at 03:29:25AM +0000, PG Bug reporting form wrote:
> Details: The handler opened with OpenTransientFile() should be closed with
> CloseTransientFile(). However, in function dsm_impl_mmap(), on a certain
> path, the return value of OpenTransientFile() (at line 885) is passed to
> close() (at line 926). It is better to use CloseTransientFile() here, as
> done at line 909.

Good catch!  This is visibly a copy-paste error coming from
dsm_impl_posix().  As a patch it gives the attached.  I am adding also
Robert in CC for awareness.
--
Michael

Attachments:

  [text/x-diff] dsm-impl-close.patch (464B, ../20180309044052.GC1416@paquier.xyz/2-dsm-impl-close.patch)
  download | inline diff:
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c
index 67e76b98fe..10a7a56875 100644
--- a/src/backend/storage/ipc/dsm_impl.c
+++ b/src/backend/storage/ipc/dsm_impl.c
@@ -923,7 +923,7 @@ dsm_impl_mmap(dsm_op op, dsm_handle handle, Size request_size,
 
 		/* Back out what's already been done. */
 		save_errno = errno;
-		close(fd);
+		CloseTransientFile(fd);
 		if (op == DSM_OP_CREATE)
 			unlink(name);
 		errno = save_errno;

  [application/pgp-signature] signature.asc (832B, ../20180309044052.GC1416@paquier.xyz/3-signature.asc)
  download

view thread (5+ messages)  latest in thread

Message-ID: <20180309044052.GC1416@paquier.xyz>
Permalink:  ../20180309044052.GC1416@paquier.xyz/
Also on:    postgresql.org/message-id/20180309044052.GC1416@paquier.xyz

 ·  · 

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: michael@paquier.xyz, bianpan2016@163.com, pgsql-bugs@lists.postgresql.org, robertmhaas@gmail.com
  Subject: Re: BUG #15105: OpenTransientFile() should be paired with CloseTransientFile() rather than close()
  In-Reply-To: <20180309044052.GC1416@paquier.xyz>

* 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