[jgroups-dev] FLUSH.blockMessageDuringFlush() broken?
balrog of moria <[email protected]> Fri, 23 Sep 2011 17:19:04 +0200
| Newsgroups | gmane.comp.java.javagroups.devel |
|---|---|
| Message-ID | <CACxvA2ArEvqYhGDYW7FzcDq812GpBQprK3GDGRjO4bo3pASGGA@mail.gmail.com> |
Before posting to the JIRA about a potential bug, I have a question
regarding the blockMessageDuringFlush() method in FLUSH. I'm working with
latest 2.12.1.Final version of JGroups. I'm copying the code here:
private void blockMessageDuringFlush() {
boolean shouldSuspendByItself = false;
blockMutex.lock();
try {
while (isBlockingFlushDown) {
if (log.isDebugEnabled())
log.debug(localAddress + ": blocking for " + (timeout <=
0 ? "ever" : timeout + "ms"));
shouldSuspendByItself = !notBlockedDown.await(timeout,
TimeUnit.MILLISECONDS);
}
if (shouldSuspendByItself) {
isBlockingFlushDown = false;
log.warn(localAddress + ": unblocking after " + timeout +
"ms");
flush_promise.setResult(Boolean.TRUE);
notBlockedDown.signalAll();
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
blockMutex.unlock();
}
}
So my first question is regarding the shouldSuspendByItself flag. Shouldn't
if the if clause be located inside the while clause since it seems that even
if the timeout expires on the await(timeout) and the flag is true, since
isBlockingFlushDown is still true, the if clause will NEVER be invoked as it
will continue to wait on the timeout.
My second question is regarding timeouts which are 0 or negative. Invoking
await(0L) will simply return immediately, and seeing as I've pointed out a
bug in flushing self, it just loops forever until someone miraculously stops
or aborts the flush normally.
I might have missed something, which is why I'm posting to this list ;)
Thanks again
Nicolas
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2dcopy2
_______________________________________________
Javagroups-development mailing list