[Mulgara-svn] r1481 - trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa
ronald at mulgara.org
ronald at mulgara.org
Thu Feb 12 17:59:52 UTC 2009
Author: ronald
Date: 2009-02-12 09:59:50 -0800 (Thu, 12 Feb 2009)
New Revision: 1481
Modified:
trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
Log:
Fix potential starvation issue if the writer thread completely empties
the queue while the client is waiting for space in a full queue.
Modified: trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java
===================================================================
--- trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java 2009-02-12 11:45:10 UTC (rev 1480)
+++ trunk/src/jar/resolver-store/java/org/mulgara/store/statement/xa/TripleWriteThread.java 2009-02-12 17:59:50 UTC (rev 1481)
@@ -93,31 +93,28 @@
synchronized (this) {
checkForException();
+ // Make sure the Queue doesn't exceed its maximum size.
+ if (queue.size() == QUEUE_MAX_BUFFERS) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Triple write queue full for file: " + file + " Waiting.");
+ }
+
+ // Wait for the Queue to be less than full.
+ do {
+ try {
+ wait();
+ } catch (InterruptedException ie) {
+ throw new RuntimeException("Exception in " + getName(), ie);
+ }
+ } while (queue.size() == QUEUE_MAX_BUFFERS);
+ }
+
+ // Put the buffer in the queue.
if (queue.isEmpty()) {
// Transition from empty to not empty.
notifyAll();
- } else {
- // Make sure the Queue doesn't exceed its maximum size.
- if (queue.size() == QUEUE_MAX_BUFFERS) {
- // Queue is full. Log a message.
- if (logger.isInfoEnabled()) {
- logger.info(
- "Triple write queue full for file: " + file + " Waiting."
- );
- }
-
- // Wait for the Queue to be less than full.
- do {
- try {
- wait();
- } catch (InterruptedException ie) {
- throw new RuntimeException("Exception in " + getName(), ie);
- }
- } while (queue.size() == QUEUE_MAX_BUFFERS);
- }
}
- // Put the buffer in the queue.
queue.addLast(buffer);
}
buffer = null;
More information about the Mulgara-svn
mailing list