hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r724177 - /httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
Date Sun, 07 Dec 2008 19:17:18 GMT
Author: olegk
Date: Sun Dec  7 11:17:17 2008
New Revision: 724177

URL: http://svn.apache.org/viewvc?rev=724177&view=rev
Log:
Re-introduced the critical section around interestOps and made it volatile in order to avoid
potential race condition in methods mutating interestOps

Modified:
    httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java

Modified: httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java?rev=724177&r1=724176&r2=724177&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
(original)
+++ httpcomponents/httpcore/trunk/module-nio/src/main/java/org/apache/http/impl/nio/reactor/IOSessionImpl.java
Sun Dec  7 11:17:17 2008
@@ -53,7 +53,7 @@
     private final SessionClosedCallback callback;
     private final Map<String, Object> attributes;
     
-    private int interestOps;
+    private volatile int interestOps;
     private SessionBufferStatus bufferStatus;
     private int socketTimeout;
     
@@ -101,8 +101,10 @@
         if (this.status == CLOSED) {
             return;
         }
-        this.interestOps = ops;
-        this.key.interestOps(ops);
+        synchronized (this.key) {
+            this.interestOps = ops;
+            this.key.interestOps(ops);
+        }
         this.key.selector().wakeup();
     }
     
@@ -110,8 +112,10 @@
         if (this.status == CLOSED) {
             return;
         }
-        this.interestOps = this.interestOps | op;
-        this.key.interestOps(this.interestOps);
+        synchronized (this.key) {
+            this.interestOps = this.interestOps | op;
+            this.key.interestOps(this.interestOps);
+        }
         this.key.selector().wakeup();
     }
     
@@ -119,8 +123,10 @@
         if (this.status == CLOSED) {
             return;
         }
-        this.interestOps = this.interestOps & ~op;
-        this.key.interestOps(this.interestOps);
+        synchronized (this.key) {
+            this.interestOps = this.interestOps & ~op;
+            this.key.interestOps(this.interestOps);
+        }
         this.key.selector().wakeup();
     }
     



Mime
View raw message