hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r476807 - in /jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio: impl/reactor/DefaultIOReactor.java impl/reactor/SessionSet.java reactor/ConnectingIOReactor.java reactor/ListeningIOReactor.java
Date Sun, 19 Nov 2006 12:26:56 GMT
Author: olegk
Date: Sun Nov 19 04:26:56 2006
New Revision: 476807

URL: http://svn.apache.org/viewvc?view=rev&rev=476807
Log:
* Methods of SessionSet made synchronized
* Split IOReactor into three interfaces: generic IOReactor, ConnectingIOReactor for establishing
outgoing connections, ListeningIOReactor for accepting incoming connections

Added:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ConnectingIOReactor.java
      - copied, changed from r474009, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java
      - copied, changed from r474009, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java
Modified:
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/DefaultIOReactor.java
    jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/SessionSet.java

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/DefaultIOReactor.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/DefaultIOReactor.java?view=diff&rev=476807&r1=476806&r2=476807
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/DefaultIOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/DefaultIOReactor.java
Sun Nov 19 04:26:56 2006
@@ -40,14 +40,15 @@
 import java.util.Iterator;
 import java.util.Set;
 
+import org.apache.http.nio.reactor.ConnectingIOReactor;
 import org.apache.http.nio.reactor.IOEventDispatch;
-import org.apache.http.nio.reactor.IOReactor;
 import org.apache.http.nio.reactor.IOSession;
+import org.apache.http.nio.reactor.ListeningIOReactor;
 import org.apache.http.nio.reactor.SessionRequest;
 import org.apache.http.params.HttpConnectionParams;
 import org.apache.http.params.HttpParams;
 
-public class DefaultIOReactor implements IOReactor {
+public class DefaultIOReactor implements ListeningIOReactor, ConnectingIOReactor {
 
     public static int TIMEOUT_CHECK_INTERVAL = 1000;
     
@@ -267,15 +268,17 @@
     }
 
     private void closeSessions() {
-        for (Iterator it = this.sessions.iterator(); it.hasNext(); ) {
-            IOSession session = (IOSession) it.next();
-            if (!session.isClosed()) {    
+        synchronized (this.sessions) {
+            for (Iterator it = this.sessions.iterator(); it.hasNext(); ) {
+                IOSession session = (IOSession) it.next();
+                if (!session.isClosed()) {    
 
-                session.close();
-                this.eventDispatch.disconnected(session);
+                    session.close();
+                    this.eventDispatch.disconnected(session);
+                }
             }
+            this.sessions.clear();
         }
-        this.sessions.clear();
     }
     
     public void listen(

Modified: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/SessionSet.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/SessionSet.java?view=diff&rev=476807&r1=476806&r2=476807
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/SessionSet.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/impl/reactor/SessionSet.java
Sun Nov 19 04:26:56 2006
@@ -44,21 +44,21 @@
         this.set = new HashSet();
     }
 
-    public void add(final IOSession session) {
+    public synchronized void add(final IOSession session) {
         if (session == null) {
             return;
         }
         this.set.add(session);
     }
 
-    public boolean remove(final IOSession session) {
+    public synchronized boolean remove(final IOSession session) {
         if (session == null) {
             return false;
         }
         return this.set.remove(session);
     }
 
-    public void clear() {
+    public synchronized void clear() {
         this.set.clear();
     }
 

Copied: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ConnectingIOReactor.java
(from r474009, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ConnectingIOReactor.java?view=diff&rev=476807&p1=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java&r1=474009&p2=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ConnectingIOReactor.java&r2=476807
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ConnectingIOReactor.java
Sun Nov 19 04:26:56 2006
@@ -32,19 +32,10 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-public interface IOReactor {
+public interface ConnectingIOReactor extends IOReactor {
 
-    void execute(IOEventDispatch eventDispatch) 
-        throws IOException;
-
-    void shutdown() 
-        throws IOException;
-    
     SessionRequest connect(SocketAddress remoteAddress, 
             SocketAddress localAddress, Object attachment) 
         throws IOException;
         
-    void listen(SocketAddress address) 
-        throws IOException;
-    
 }

Copied: jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java
(from r474009, jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java)
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java?view=diff&rev=476807&p1=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java&r1=474009&p2=jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java&r2=476807
==============================================================================
--- jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/IOReactor.java
(original)
+++ jakarta/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/nio/reactor/ListeningIOReactor.java
Sun Nov 19 04:26:56 2006
@@ -32,18 +32,8 @@
 import java.io.IOException;
 import java.net.SocketAddress;
 
-public interface IOReactor {
+public interface ListeningIOReactor extends IOReactor {
 
-    void execute(IOEventDispatch eventDispatch) 
-        throws IOException;
-
-    void shutdown() 
-        throws IOException;
-    
-    SessionRequest connect(SocketAddress remoteAddress, 
-            SocketAddress localAddress, Object attachment) 
-        throws IOException;
-        
     void listen(SocketAddress address) 
         throws IOException;
     



Mime
View raw message