You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ds...@apache.org on 2015/09/23 01:39:37 UTC
[3/3] incubator-geode git commit: Connection no longer passes a
Runnable to asyncClose. By doing this the Runnable keeps the Connection
instance alive. If you have a bunch of async closes queued up then this might
consume more memory than is desired. The
Connection no longer passes a Runnable to asyncClose.
By doing this the Runnable keeps the Connection instance alive.
If you have a bunch of async closes queued up then this might consume
more memory than is desired. The code that used to be in the Runnable
is now in a new prepareForAsyncClose method. This code will not block
for long periods of time like close can so it is ok to do it inline.
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/0bc967db
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/0bc967db
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/0bc967db
Branch: refs/heads/feature/GEODE-332
Commit: 0bc967dbda2b3d3b5d0958f33d5aec53c220f605
Parents: b317428
Author: Darrel Schneider <ds...@pivotal.io>
Authored: Tue Sep 22 16:32:51 2015 -0700
Committer: Darrel Schneider <ds...@pivotal.io>
Committed: Tue Sep 22 16:32:51 2015 -0700
----------------------------------------------------------------------
.../gemfire/internal/tcp/Connection.java | 28 +++++++++++---------
1 file changed, 15 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/0bc967db/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java
----------------------------------------------------------------------
diff --git a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java
index 6db01bd..88bca22 100644
--- a/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java
+++ b/gemfire-core/src/main/java/com/gemstone/gemfire/internal/tcp/Connection.java
@@ -830,29 +830,31 @@ public class Connection implements Runnable {
// we do the close in a background thread because the operation may hang if
// there is a problem with the network. See bug #46659
- Runnable r = new Runnable() {
- public void run() {
- synchronized(stateLock) {
- if (readerThread != null && isRunning && !readerShuttingDown
- && (connectionState == STATE_READING
- || connectionState == STATE_READING_ACK)) {
- readerThread.interrupt();
- }
- }
- }
- };
+
// if simulating sickness, sockets must be closed in-line so that tests know
// that the vm is sick when the beSick operation completes
if (beingSick) {
- r.run();
+ prepareForAsyncClose();
}
else {
if (this.asyncCloseCalled.compareAndSet(false, true)) {
- this.owner.getSocketCloser().asyncClose(this.socket, String.valueOf(this.remoteAddr), r);
+ Socket s = this.socket;
+ if (s != null && !s.isClosed()) {
+ prepareForAsyncClose();
+ this.owner.getSocketCloser().asyncClose(s, String.valueOf(this.remoteAddr), null);
+ }
}
}
}
+ private void prepareForAsyncClose() {
+ synchronized(stateLock) {
+ if (readerThread != null && isRunning && !readerShuttingDown
+ && (connectionState == STATE_READING || connectionState == STATE_READING_ACK)) {
+ readerThread.interrupt();
+ }
+ }
+ }
private static final int CONNECT_HANDSHAKE_SIZE = 4096;