X-Recipient: archive-cygwin@delorie.com
X-SWARE-Spam-Status: No, hits=-2.6 required=5.0	tests=AWL,BAYES_00,GENERIC_IXHASH,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_HOSTKARMA_W,RCVD_IN_HOSTKARMA_WL,RP_MATCHES_RCVD,SPF_HELO_PASS
X-Spam-Check-By: sourceware.org
X-IronPortListener: Outbound_SMTP
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AqkJALKur1CcKEep/2dsb2JhbABEhie5G4EKbAeCHgEBAQMBEhERSgsCAQgaAgYgAgICHRMVEAEBBBsah2UGok6KB5JMgSKOQzJhA401mQ6Cb4Id
From: "Lavrentiev, Anton (NIH/NLM/NCBI) [C]" <lavr@ncbi.nlm.nih.gov>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>
Subject: RE: Possible race in SYSV IPC (semaphores)
Date: Fri, 23 Nov 2012 17:16:02 +0000
Message-ID: <5F8AAC04F9616747BC4CC0E803D5907D0162C6@MLBXv04.nih.gov>
References: <5F8AAC04F9616747BC4CC0E803D5907D012856@MLBXV09.nih.gov> <20121123113605.GN17347@calimero.vinschen.de> <20121123131020.GR17347@calimero.vinschen.de> <20121123133332.GU17347@calimero.vinschen.de> <20121123164404.GX17347@calimero.vinschen.de>
In-Reply-To: <20121123164404.GX17347@calimero.vinschen.de>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
X-IsSubscribed: yes
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id qANHGP0N025282

> This should avoid the race (*and* work...)
> Please give it a try.

Thanks!  I've tried both patches (pipe race + semadj), and they do seem to work!

Although (not being a party pooper :-), I think that all the logic
around "pipe_instance" can now be dropped entirely, and benefit from eliminating
an unnecessary synchronization point (pipe_instance is now only used
for logging a proper pipe ID, which is not even seen in regular use,
and for an assert(), which again is only there in debug mode builds).
So there is no need to arrange Enter'ing/Leave'ing of the critical section
to do just the hidden things, yet the working code would be a bit cleaner.

Anton Lavrentiev
Contractor NIH/NLM/NCBI


