mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee" <trus...@gmail.com>
Subject Re: Sendind message in filterClose
Date Mon, 03 Jul 2006 08:00:35 GMT
On 7/3/06, daune.jf@daune-consult.com <daune.jf@daune-consult.com> wrote:
>
> Quoting daune.jf@daune-consult.com:
>
> > Quoting peter royal <proyal@apache.org>:
> >
> >> On Jun 30, 2006, at 1:36 PM, daune.jf@daune-consult.com wrote:
> >>> I have implemented a filter, and in filterClose() I send a message
> >>>     without calling nextFilter.filterClose().
> >>>
> >>> The message is never sent. I added a Callback to WriteFuture, and
> >>>    isWritten returns false.
> >>>
> >>> Is it forbidden to send messages in filterClose?
> >>
> >> Off the top of my head, you may be getting the filterClose event
> >> because the other end closed the connection, in which case, you can't
> >> write them anything else.
> >>
> >> I would think that what you're trying to do would work if the close
> >> was initiated by IoSession.close() on the side that you're trying to
> >> do this behavior.
> >>
> >> -pete
> >
> > I am now sure that it is not the client that closes the connection.
> >
> > Is it possible to determine why message is not sent? WriteFuture only
> > has a boolean indicating success or failure. How can I know the
> > failure reason?
> >
> > J-F
>
>
> OK. Once close() is called on BaseIoSession, its state switches to
> 'closing'.
>
> In this state, calling write() leads to calling
> WriteFuture.newNotWrittenFuture() which returns a 'fake' WriteFuture
> without enqueuing the request.
>
> So, you cannot write message to a closing session.


I thought we can write a message in filterClose() by doing like this:

void filterClose(...) {
    WriteFuture future = next.filterWrite(...);
    future.setCallback(new IoFuture.Callback() {
        public void operationComplete(...) {
            future.getSession().close();
        }
    });
}

If this doesn't work, this is a bug.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message