Skip to main content

[xadisk~svn:536] Changes for JIRA issue #140.

  • From: nitin_verma@...
  • To: commits@...
  • Subject: [xadisk~svn:536] Changes for JIRA issue #140.
  • Date: Fri, 16 Aug 2013 12:19:53 +0000

Project:    xadisk
Repository: svn
Revision:   536
Author:     nitin_verma
Date:       2013-08-16 12:19:51 UTC
Link:       

Log Message:
------------
Changes for JIRA issue #140.


Revisions:
----------
536


Modified Paths:
---------------
trunk/src/org/xadisk/bridge/server/conversation/RemoteMethodInvocationHandler.java
trunk/src/org/xadisk/bridge/server/PointOfContact.java
trunk/src/org/xadisk/bridge/server/conversation/ConversationGateway.java


Diffs:
------
Index: trunk/src/org/xadisk/bridge/server/PointOfContact.java
===================================================================
--- trunk/src/org/xadisk/bridge/server/PointOfContact.java      (revision 535)
+++ trunk/src/org/xadisk/bridge/server/PointOfContact.java      (revision 536)
@@ -5,6 +5,10 @@
 "Eclipse Public License 1.0" located at 
http://www.opensource.org/licenses/eclipse-1.0.php.
 */
 
+/*
+ * Many Thanks to Jasper Siepkes for suggesting the bug fix for
+ * https://java.net/jira/browse/XADISK-140
+*/
 
 package org.xadisk.bridge.server;
 
@@ -49,16 +53,23 @@
             }
         } catch (Throwable t) {
             xaFileSystem.notifySystemFailure(t);
+        } finally {
+            conversationGateway.release();
+            closeServerSocket();
         }
     }
 
     public void release() {
         enabled = false;
-        conversationGateway.release();
+        closeServerSocket();
+        //we need to close the channel here to come out of accept.
+    }
+
+    private void closeServerSocket() {
         try {
             serverSocketChannel.close();
         } catch (Throwable t) {
             //no-op.
         }
     }
-}
+}
\ No newline at end of file
Index: 
trunk/src/org/xadisk/bridge/server/conversation/RemoteMethodInvocationHandler.java
===================================================================
--- 
trunk/src/org/xadisk/bridge/server/conversation/RemoteMethodInvocationHandler.java
  (revision 535)
+++ 
trunk/src/org/xadisk/bridge/server/conversation/RemoteMethodInvocationHandler.java
  (revision 536)
@@ -80,6 +80,8 @@
                 }
                 Set<SelectionKey> selectionKeys = 
writeSelector.selectedKeys();
                 //this will be only one key always, the above one.
+                //we needed to use selector here as the channel is being 
used in
+                //ConversationGateway in multiplexing (which requires 
non-blocking mode).
                 channel.write(toSend);
                 selectionKeys.clear();
             }
Index: 
trunk/src/org/xadisk/bridge/server/conversation/ConversationGateway.java
===================================================================
--- trunk/src/org/xadisk/bridge/server/conversation/ConversationGateway.java  
  (revision 535)
+++ trunk/src/org/xadisk/bridge/server/conversation/ConversationGateway.java  
  (revision 536)
@@ -5,6 +5,10 @@
 "Eclipse Public License 1.0" located at 
http://www.opensource.org/licenses/eclipse-1.0.php.
 */
 
+/*
+ * Many Thanks to Jasper Siepkes for suggesting the bug fix for
+ * https://java.net/jira/browse/XADISK-140
+*/
 
 package org.xadisk.bridge.server.conversation;
 
@@ -67,23 +71,34 @@
                         buffer.flip();
                         context.updateWithConversation(buffer);
                     } catch (IOException ioe) {
-                        selectionKey.cancel();
+                        closeClientConversation(selectionKey, channel);
                     }
                 }
                 selectedReadable.clear();
             }
-            informDisconnectionToClients();
         } catch (Throwable t) {
             xaFileSystem.notifySystemFailure(t);
+        } finally {
+            closeAllClientConversations();
         }
     }
-
+    
     public void release() {
         this.enabled = false;
         this.selector.wakeup();
     }
+    
+    private void closeClientConversation(SelectionKey selectionKey, 
SocketChannel channel) {
+        selectionKey.cancel();
+        try {
+            channel.socket().close();
+        } catch(Throwable t) {
+            //no-op.
+        }
+    }
 
-    private void informDisconnectionToClients() {
+    private void closeAllClientConversations() {
+        //no need to cancel keys as we will close selector itself.
         Set<SelectionKey> connectedClientKeys = selector.keys();
         for (SelectionKey key : connectedClientKeys) {
             try {
@@ -92,5 +107,10 @@
                 //no-op.
             }
         }
+        try {
+            selector.close();
+        } catch(Throwable t) {
+            //no-op.
+        }
     }
 }





[xadisk~svn:536] Changes for JIRA issue #140.

nitin_verma 08/16/2013
 
 
Close
loading
Please Confirm
Close