Changeset 719

Show
Ignore:
Timestamp:
06/20/08 19:50:10 (4 months ago)
Author:
francis
Message:

fixed an error in which writing to a connection that hasn't finished connecting yet
would suppress the connect-completion event from the reactor.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/java/src/com/rubyeventmachine/EventableSocketChannel.java

    r717 r719  
    5454        LinkedList<ByteBuffer> outboundQ; 
    5555        boolean bCloseScheduled; 
     56        boolean bConnectPending; 
    5657         
    5758        SSLEngine sslEngine; 
     
    6667                selector = sel; 
    6768                bCloseScheduled = false; 
     69                bConnectPending = false; 
    6870                outboundQ = new LinkedList<ByteBuffer>(); 
    6971                 
     
    98100                                        outboundQ.addLast(bb); 
    99101                                } 
    100                                 channel.register(selector, SelectionKey.OP_WRITE | SelectionKey.OP_READ, this); 
     102                                channel.register(selector, SelectionKey.OP_WRITE | SelectionKey.OP_READ | (bConnectPending ? SelectionKey.OP_CONNECT : 0), this); 
    101103                        } 
    102104                } catch (ClosedChannelException e) { 
     
    169171        public void setConnectPending() throws ClosedChannelException { 
    170172                channel.register(selector, SelectionKey.OP_CONNECT, this); 
     173                bConnectPending = true; 
    171174        } 
    172175         
     
    183186                        return false; 
    184187                } 
    185                 channel.register(selector, SelectionKey.OP_READ, this); 
     188                bConnectPending = false; 
     189                channel.register(selector, SelectionKey.OP_READ | (outboundQ.isEmpty() ? 0 : SelectionKey.OP_WRITE), this); 
    186190                return true; 
    187191        } 
    188192         
    189193        public void scheduleClose (boolean afterWriting) { 
     194                // TODO: What the hell happens here if bConnectPending is set? 
    190195                if (!afterWriting) 
    191196                        outboundQ.clear();