[Swift-commit] cog r3459
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Tue Aug 21 02:15:11 CDT 2012
------------------------------------------------------------------------
r3459 | hategan | 2012-08-21 02:13:46 -0500 (Tue, 21 Aug 2012) | 1 line
fixed race condition in stagein buffer (de)allocation
------------------------------------------------------------------------
Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java (revision 3458)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/NIOChannelReadBuffer.java (working copy)
@@ -33,18 +33,15 @@
public void doStuff(boolean last, ByteBuffer b, Buffers.Allocation alloc) {
synchronized(this) {
if (closed) {
+ if (logger.isInfoEnabled()) {
+ logger.info("Transfer done. De-allocating one unused buffer");
+ }
+ if (alloc != null) {
+ buffers.free(alloc);
+ }
return;
}
}
- if (read >= size) {
- if (logger.isDebugEnabled()) {
- logger.debug("Transfer done. De-allocating one unused buffer");
- }
- if (alloc != null) {
- buffers.free(alloc);
- }
- return;
- }
if (alloc != null) {
bufferCreated(alloc);
}
Index: modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java
===================================================================
--- modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (revision 3458)
+++ modules/provider-coaster/src/org/globus/cog/abstraction/impl/file/coaster/buffers/ReadBuffer.java (working copy)
@@ -58,7 +58,7 @@
}
int queuedBuffers = requestFill();
if (logger.isInfoEnabled()) {
- logger.info(this + " actual allocated buffers " + (nbuf - queuedBuffers));
+ logger.info(this + " actual allocated buffers " + (nbuf - queuedBuffers) + "(" + queuedBuffers + " queued)");
}
if (queuedBuffers == nbuf) {
// all buffers are queued
@@ -71,9 +71,9 @@
synchronized (this) {
b = full.removeFirst();
b.clear();
+ empty.addLast(b);
+ requestFill();
}
- buffers.queueRequest(false, b, this, this);
- requestFill();
}
protected int requestFill() {
@@ -81,25 +81,20 @@
return 0;
}
int queued = 0;
- synchronized (empty) {
- while (!empty.isEmpty() && read < size) {
- ByteBuffer buf = empty.removeFirst();
- if (buf != null) {
- buf.clear();
- }
- if (buffers.queueRequest(false, buf, this, this)) {
- queued++;
- }
+ while (!empty.isEmpty() && read < size) {
+ ByteBuffer buf = empty.removeFirst();
+ if (buf != null) {
+ buf.clear();
}
+ if (buffers.queueRequest(false, buf, this, this)) {
+ queued++;
+ }
}
return queued;
}
public void error(ByteBuffer buf, Exception e) {
- synchronized (empty) {
- empty.addLast(buf);
- getCallback().error(false, e);
- }
+ getCallback().error(false, e);
}
public void bufferRead(ByteBuffer buf) {
More information about the Swift-commit
mailing list