mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel L├ęcharny <elecha...@gmail.com>
Subject [MINA 2] Big bug in the NioDatagramAcceptor
Date Thu, 24 Dec 2015 17:09:29 GMT
Hi guys,

as this is a bit slow those days, I'm spending some time doing some
cleanup on MINA 2.0 code (cleaning the Javadoc, checking
https://analysis.apache.org/dashboard/index/109933). It's absolutly
incredible the numbers of bug I have found... A few of them were easy,
but this one :

    public void write(NioSession session, WriteRequest writeRequest) {
        final WriteRequestQueue writeRequestQueue =
        // Deal with the special case of a Message marker (no bytes in
the request)
        // We just have to return after having calle dthe messageSent event
        IoBuffer buf = (IoBuffer) writeRequest.getMessage();

        // Now, write the data
        try {
            for (;;) {
                if (writeRequest == null) {
                    writeRequest = writeRequestQueue.poll(session);

                    if (writeRequest == null) {
                        setInterestedInWrite(session, false);


Here, there is *no chance* the writeRequest can be null when we enter
the for loop, and there is no place in the for loop where we update the
writeRequest object !

That means we actually never loop on the queue content.

From the performance POV, this is atrocious, because it means we will
simply have to wait for the next event loop to be processed, instead of
trying to fill the socket with all what we have.

We most certainly can do better !

View raw message