Emmanuel,

I’m not sure my discussions is warranted inside of the ticket unless I come
to some sort of conclusion.

I don’t think that is true that the message is stacked in the IoProcessor
Queue.

@Override
    public void write(S session, WriteRequest writeRequest) {
        WriteRequestQueue writeRequestQueue =
session.getWriteRequestQueue();

        writeRequestQueue.offer(session, writeRequest);

        if (!session.isWriteSuspended()) {
            this.flush(session);
        }
    }

WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();

            if (!s.isWriteSuspended()) {
                if (writeRequestQueue.isEmpty(session)) {
                    // We can write directly the message
                    s.getProcessor().write(s, writeRequest);
                } else {
                    s.getWriteRequestQueue().offer(s, writeRequest);
                    s.getProcessor().flush(s);
                }
            } else {
                s.getWriteRequestQueue().offer(s, writeRequest);
            }

@Override
    public final void flush(S session) {
        // add the session to the queue if it's not already
        // in the queue, then wake up the select()
        if (session.setScheduledForFlush(true)) {
            flushingSessions.add(session);
            wakeup();
        }
    }

Both use Session.getWriteRequestQueue.  Seems like the IoProcessor has a
Queue which contains IoSession objects and not the Writable Data.
Basically, I’m looking for a concise place to unify and make the counters
thread-safe.

On Fri, Oct 6, 2017 at 6:56 PM, Emmanuel Lécharny <elecha...@gmail.com>
wrote:

> Hi Jonathan,
>
>
> it's probably better to put your comment in the JIRA ticket, for a
> better follow up...
>
>
> That being said,
>
>
> Le 06/10/2017 à 20:08, Jonathan Valliere a écrit :
> > I haven’t looked at the Mina code in a while.  Looking at
> > DefaultIoFilterChain.java under HeadFilter#filterWrite
> >
> > WriteRequestQueue writeRequestQueue = s.getWriteRequestQueue();
> >
> >             if (!s.isWriteSuspended()) {
> >                 if (writeRequestQueue.isEmpty(session)) {
> >                     // We can write directly the message
> >                     s.getProcessor().write(s, writeRequest);
> >                 } else {
> >                     s.getWriteRequestQueue().offer(s, writeRequest);
> >                     s.getProcessor().flush(s);
> >                 }
> >             } else {
> >                 s.getWriteRequestQueue().offer(s, writeRequest);
> >             }
> >
> > Checking and working with the WriteRequestQueue is unnecessary because
> the
> > AbstractPollingIoProcessor adds all write requests to the Queue anyway.
>
> Those are two different queues. The HeadFilter stacks the message in a
> session queue, while the AbstractPollingIoProcessor stacks the message
> in the IoProcessor queue. You may have thousands of sessions but nly a
> few IoProcessor which handle many sessions.
> >
> > Similarly, it is confusing that the HeadFilter is controlling the
> > increaseScheduledWriteBytes.  This should be controlled by the
> > AbstractPollingIoProcessor to ensure safety of the increase/decrease
> > operations.
>
> Again, this is a per session counter vs a per IoProcessor counter. The
> application is really interested on what happens on ifself.
>
> --
> Emmanuel Lecharny
>
> Symas.com
> directory.apache.org
>
>

Reply via email to