Apache AWF
  1. Apache AWF
  2. AWF-182

Close channel if we (during read) reach EOF and there is nothing to write

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Labels:
      None

      Description

      Proposal: In AS.handleRead(..) add
      if (read == -1) { // EOF
      reachedEOF = true;
      ioLoop.updateHandler(channel, interestOps &= ~SelectionKey.OP_READ);
      if (writeBuffer.position() == 0)

      { invokeCloseCallback(); }

      return;
      }

      (the invokeCloseCallback() + surronding if statement is new)

      Found this issue during DEFT-151 (disitributed demo application).

      The problem is that its easy to leak connection if we dont handle this case. The problem is that you never will get a notification/callback that the client/server is down (if you only are reading from the asynchronous socket, as soon as you try to write to the socket, you will get a close callback....but that is only if you acctually try to write on the socket).

      1. deft-170.patch
        0.7 kB
        umesh awasthi

        Activity

        Tony Stevenson made changes -
        Project Deft [ 12311521 ] Apache AWF [ 12313220 ]
        Key DEFT-170 AWF-182
        Fix Version/s 0.4.0 [ 12317348 ]
        Johnathan Meehan made changes -
        Status In Progress [ 3 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        Johnathan Meehan added a comment -

        Ready for review.

        Show
        Johnathan Meehan added a comment - Ready for review.
        Hide
        Johnathan Meehan added a comment - - edited

        Committed (as per Roger's original proposal).

        http://svn.apache.org/viewvc?rev=1165679&view=rev

        Show
        Johnathan Meehan added a comment - - edited Committed (as per Roger's original proposal). http://svn.apache.org/viewvc?rev=1165679&view=rev
        Johnathan Meehan made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Johnathan Meehan made changes -
        Assignee Johnathan Meehan [ jmeehan ]
        Hide
        Roger Schildmeijer added a comment -

        the line
        if (buffer.position() == 0)

        {..}
        should probably be
        if (writeBuffer.position() == 0) {..}

        Do you agree?

        Show
        Roger Schildmeijer added a comment - the line if (buffer.position() == 0) {..} should probably be if (writeBuffer.position() == 0) {..} Do you agree?
        umesh awasthi made changes -
        Attachment deft-170.patch [ 12488419 ]
        Hide
        umesh awasthi added a comment -

        Patch to close channel when there is nothing to write

        Show
        umesh awasthi added a comment - Patch to close channel when there is nothing to write
        Roger Schildmeijer made changes -
        Field Original Value New Value
        Fix Version/s 0.4.0 [ 12317348 ]
        Hide
        Roger Schildmeijer added a comment -

        no problem. no questions are stupid

        Show
        Roger Schildmeijer added a comment - no problem. no questions are stupid
        Hide
        umesh awasthi added a comment -

        sorry for such a question, i know this practice but after going through the list i came across that work is going around on many issue still no one is against the assignee field ,so i preferred this way to confirmation

        Show
        umesh awasthi added a comment - sorry for such a question, i know this practice but after going through the list i came across that work is going around on many issue still no one is against the assignee field ,so i preferred this way to confirmation
        Hide
        Roger Schildmeijer added a comment -

        should be enough to look at the "Assignee" field. (atleast in the future, everything is new and all processes are not defined yet)

        Show
        Roger Schildmeijer added a comment - should be enough to look at the "Assignee" field. (atleast in the future, everything is new and all processes are not defined yet)
        Hide
        umesh awasthi added a comment -

        is any one working on this?
        since while walk-through the code base i came across the code of piece and have fixed it on my local machine.

        Show
        umesh awasthi added a comment - is any one working on this? since while walk-through the code base i came across the code of piece and have fixed it on my local machine.
        Roger Schildmeijer created issue -

          People

          • Assignee:
            Johnathan Meehan
            Reporter:
            Roger Schildmeijer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development