Skip to content

Commit

Permalink
Revert "Fix shutdown errors in jruby reactor due to modification of C…
Browse files Browse the repository at this point in the history
…onnections HashMap"

This reverts commit f3f5da4.
  • Loading branch information
tmm1 committed Sep 29, 2009
1 parent f3f5da4 commit 16b6fbf
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions java/src/com/rubyeventmachine/EmReactor.java
Expand Up @@ -53,7 +53,7 @@ public class EmReactor {
private TreeMap<Long, ArrayList<Long>> Timers;
private HashMap<Long, EventableChannel> Connections;
private HashMap<Long, ServerSocketChannel> Acceptors;
private ArrayList<EventableChannel> NewConnections;
private ArrayList<Long> NewConnections;
private ArrayList<Long> UnboundConnections;
private ArrayList<EventableSocketChannel> DetachedConnections;

Expand All @@ -67,7 +67,7 @@ public EmReactor() {
Timers = new TreeMap<Long, ArrayList<Long>>();
Connections = new HashMap<Long, EventableChannel>();
Acceptors = new HashMap<Long, ServerSocketChannel>();
NewConnections = new ArrayList<EventableChannel>();
NewConnections = new ArrayList<Long>();
UnboundConnections = new ArrayList<Long>();
DetachedConnections = new ArrayList<EventableSocketChannel>();

Expand Down Expand Up @@ -121,13 +121,14 @@ void addNewConnections() {
}
DetachedConnections.clear();

ListIterator<EventableChannel> iter2 = NewConnections.listIterator(0);
ListIterator<Long> iter2 = NewConnections.listIterator(0);
while (iter2.hasNext()) {
EventableChannel ec = iter2.next();
long b = iter2.next();

EventableChannel ec = Connections.get(b);
if (ec != null) {
try {
ec.register();
Connections.put (ec.getBinding(), ec);
} catch (ClosedChannelException e) {
UnboundConnections.add (ec.getBinding());
}
Expand Down Expand Up @@ -233,7 +234,8 @@ void isAcceptable (SelectionKey k) {

b = createBinding();
EventableSocketChannel ec = new EventableSocketChannel (sn, b, mySelector);
NewConnections.add (ec);
Connections.put (b, ec);
NewConnections.add (b);

eventCallback (((Long)k.attachment()).longValue(), EM_CONNECTION_ACCEPTED, null, b);
}
Expand Down Expand Up @@ -466,7 +468,8 @@ public long connectTcpServer (String bindAddr, int bindPort, String address, int
}
else {
ec.setConnectPending();
NewConnections.add (ec);
Connections.put (b, ec);
NewConnections.add (b);
}
} catch (IOException e) {
// Can theoretically come here if a connect failure can be determined immediately.
Expand Down Expand Up @@ -516,7 +519,8 @@ public long attachChannel (SocketChannel sc, boolean watch_mode) {
if (watch_mode)
ec.setWatchOnly();

NewConnections.add (ec);
Connections.put (b, ec);
NewConnections.add (b);

return b;
}
Expand Down

0 comments on commit 16b6fbf

Please sign in to comment.