mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee" <trus...@gmail.com>
Subject Re: IoSession-level synchronization of ProtocolEncoder/ProtocolDecoder pair
Date Tue, 16 Jan 2007 03:22:16 GMT
Hi Steven,

On 1/10/07, Steven E. Harris <seh@panix.com> wrote:
>
> I'm using a ProtocolEncoder and ProtocolDecoder pair supplied to a
> ProtocolCodecFilter, and am wondering whether the
> ProtocolEncoder.encode() and ProtocolDecoder.decode() methods will
> ever be called on concurrently for the same IoSession. That is, is it
> possible that an encoder is writing at the same time a decoder is
> reading?


Yes. (Related thread: *http://tinyurl.com/ygazu9)*

The question arises because the network protocol permits
> pipelining. The decoder side may see an error signaled by its peer,
> and wish to notify the encoder side to stop writing requests on this
> connection/session; hence the encoder and decoder communicate. Should
> I assume that this communication between encoder and decoder may be
> happening between separate threads, or can I assume that the encoder
> and decoder are never used concurrently, at least for a given
> IoSession?


IoSession.write() can be invoked from any thread, so you will need some kind
of inter-process communication in you IoHandler and writer thread.  I think
decoder is not a good place to detect a problem.  I'd rather use
exceptionCaught() handler.  You can filter exceptions from a decoder very
easily because all exceptions thrown by a decoder will be wrapped by
ProtocolDecoderException.

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