agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Jim Nasby <[email protected]>
To: Pg Hackers <[email protected]>
Subject: Comment patch for bgworker.c
Date: Fri, 24 Oct 2014 19:51:07 -0500
Message-ID: <[email protected]> (raw)
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgsql-hackers>

The comment for the BackgroundWorkerSlot structure tripped me up reviewing Robert's background worker patch; it made it clear that you need to use a memory barrier before setting in_use, but normally you'd never need to worry about that because RegisterDynamicBackgroundWorker() handles it for you. Patch adds a comment to that effect.
-- 
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 85a3b3a..e81dbc1 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -55,7 +55,8 @@ slist_head	BackgroundWorkerList = SLIST_STATIC_INIT(BackgroundWorkerList);
  * responsibility of the postmaster.  Regular backends may no longer modify it,
  * but the postmaster may examine it.  Thus, a backend initializing a slot
  * must fully initialize the slot - and insert a write memory barrier - before
- * marking it as in use.
+ * marking it as in use. Note that RegisterDynamicBackgroundWorker() handles
+ * in_use correctly for you.
  *
  * As an exception, however, even when the slot is in use, regular backends
  * may set the 'terminate' flag for a slot, telling the postmaster not


-- 
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Attachments:

  [text/plain] patch (810B, ../[email protected]/2-patch)
  download | inline diff:
diff --git a/src/backend/postmaster/bgworker.c b/src/backend/postmaster/bgworker.c
index 85a3b3a..e81dbc1 100644
--- a/src/backend/postmaster/bgworker.c
+++ b/src/backend/postmaster/bgworker.c
@@ -55,7 +55,8 @@ slist_head	BackgroundWorkerList = SLIST_STATIC_INIT(BackgroundWorkerList);
  * responsibility of the postmaster.  Regular backends may no longer modify it,
  * but the postmaster may examine it.  Thus, a backend initializing a slot
  * must fully initialize the slot - and insert a write memory barrier - before
- * marking it as in use.
+ * marking it as in use. Note that RegisterDynamicBackgroundWorker() handles
+ * in_use correctly for you.
  *
  * As an exception, however, even when the slot is in use, regular backends
  * may set the 'terminate' flag for a slot, telling the postmaster not


view thread (4+ messages)  latest in thread

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: [email protected]
  Cc: [email protected]
  Subject: Re: Comment patch for bgworker.c
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox