From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: Re: [JGIT PATCH v2] Fix a race condition when loading non-mmapd byte windows
Date: Sat, 7 Mar 2009 17:24:15 -0800 [thread overview]
Message-ID: <20090308012415.GT16213@spearce.org> (raw)
In-Reply-To: <1236471435-21888-1-git-send-email-spearce@spearce.org>
"Shawn O. Pearce" <spearce@spearce.org> wrote:
> Oh hell, I missed the fact that markLoaded(ByteWindow) may be
> dropping the last reference and need to close the file.
*and* you need to squash this in to prevent a deadlock:
Frell. What a Saturday.
diff --git a/org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java b/org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java
index 055a329..c07a260 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/lib/ByteArrayWindow.java
@@ -100,16 +100,25 @@ void inflateVerify(final byte[] array, final int pos, final Inflater inf)
inf.inflate(verifyGarbageBuffer, 0, verifyGarbageBuffer.length);
}
- synchronized void ensureLoaded(final byte[] array) {
- if (!loaded) {
- try {
- provider.fd.getChannel().read(ByteBuffer.wrap(array), start);
- } catch (IOException e) {
- throw new RuntimeException("Cannot fault in window", e);
- } finally {
+ void ensureLoaded(final byte[] array) {
+ boolean release = false;
+ try {
+ synchronized (this) {
+ if (!loaded) {
+ release = true;
+ try {
+ provider.fd.getChannel().read(ByteBuffer.wrap(array),
+ start);
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot fault in window", e);
+ }
+ loaded = true;
+ }
+ }
+ } finally {
+ if (release) {
WindowCache.markLoaded(this);
}
- loaded = true;
}
}
}
\ No newline at end of file
--
Shawn.
prev parent reply other threads:[~2009-03-08 1:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-08 0:12 [JGIT PATCH] Fix a race condition when loading non-mmapd byte windows Shawn O. Pearce
2009-03-08 0:17 ` [JGIT PATCH v2] " Shawn O. Pearce
2009-03-08 1:24 ` Shawn O. Pearce [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090308012415.GT16213@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).