diff options
author | Koushik Dutta <koushd@gmail.com> | 2015-01-19 21:27:52 -0800 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2015-01-19 21:27:52 -0800 |
commit | 8777610d5a6e9bd3e9b26322032b0106970d98f8 (patch) | |
tree | c3da37d6064f17cfa5f48ed11bac25f6c20ffbb1 /AndroidAsync | |
parent | 3069bbcb436de674bfb0163f58d3ecf2391afa30 (diff) | |
download | AndroidAsync-8777610d5a6e9bd3e9b26322032b0106970d98f8.tar.gz AndroidAsync-8777610d5a6e9bd3e9b26322032b0106970d98f8.tar.bz2 AndroidAsync-8777610d5a6e9bd3e9b26322032b0106970d98f8.zip |
Fix other potential reentrancy issues.
Diffstat (limited to 'AndroidAsync')
-rw-r--r-- | AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java b/AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java index 555005d..7b642e6 100644 --- a/AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java +++ b/AndroidAsync/src/com/koushikdutta/async/http/AsyncSocketMiddleware.java @@ -141,11 +141,11 @@ public class AsyncSocketMiddleware extends SimpleMiddleware { info.openCount++; - while (!info.sockets.isEmpty()) { IdleSocketHolder idleSocketHolder = info.sockets.pop(); final AsyncSocket socket = idleSocketHolder.socket; if (idleSocketHolder.idleTime + idleTimeoutMs < System.currentTimeMillis()) { + socket.setClosedCallback(null); socket.close(); continue; } @@ -305,7 +305,6 @@ public class AsyncSocketMiddleware extends SimpleMiddleware { public void onCompleted(Exception ex) { synchronized (AsyncSocketMiddleware.this) { sockets.remove(idleSocketHolder); - socket.setClosedCallback(null); maybeCleanupConnectionInfo(lookup); } } @@ -317,6 +316,7 @@ public class AsyncSocketMiddleware extends SimpleMiddleware { socket.setEndCallback(new CompletedCallback() { @Override public void onCompleted(Exception ex) { + socket.setClosedCallback(null); socket.close(); } }); @@ -328,6 +328,7 @@ public class AsyncSocketMiddleware extends SimpleMiddleware { public void onDataAvailable(DataEmitter emitter, ByteBufferList bb) { super.onDataAvailable(emitter, bb); bb.recycle(); + socket.setClosedCallback(null); socket.close(); } }); @@ -364,12 +365,14 @@ public class AsyncSocketMiddleware extends SimpleMiddleware { if (data.exception != null || !data.socket.isOpen()) { data.request.logv("closing out socket (exception)"); + data.socket.setClosedCallback(null); data.socket.close(); return; } if (!HttpUtil.isKeepAlive(data.response.protocol(), data.response.headers()) || !HttpUtil.isKeepAlive(Protocol.HTTP_1_1, data.request.getHeaders())) { data.request.logv("closing out socket (not keep alive)"); + data.socket.setClosedCallback(null); data.socket.close(); return; } |