DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42701>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42701

           Summary: Http11NioProtocol returns wrong data on non-Comet HTTP
                    requests
           Product: Tomcat 6
           Version: unspecified
          Platform: All
        OS/Version: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: Catalina
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When loading pages via Http11NioProtocol about 50% of images and other resources
are randomly replaced with other images/resources from the same page or fail.
The problem usually is noticeable only when communicating with non-localhost
servers.

Upon investigating I found out that NIO protocol reads from request input stream
until it drains the available data, then puts the partially parsed request and
the partially read socket into event queues and waits until more data comes.

However then it mismatches the request/socket pair and the resulting request is
a mix of headers from several different requests. In fact it doesn't even try to
 keep the mapping - it just grabs any request and any socket and starts parsing.

This bug is not noticeable on localhost, since there the entire request is
typically read at once.

This bug does not happen for Comet requests that keep their socket-request
mapping in Http11NioProtocol.Http11ConnectionHandler.connections map.

Changing Http11NioProtocol.Http11ConnectionHandler.process() to the following
seems to fix the problem (I am keeping the socket-request mapping for regular
requests in the same map where Comet requests keep theirs)
===============================================================
        public SocketState process(MyNioChannel socket) {
            MyHttp11NioProcessor processor = connections.get(socket);
            try {
                if (processor == null) {
                    processor = recycledProcessors.poll();
                }
                if (processor == null) {
                    processor = createProcessor();
                }

                if (processor instanceof ActionHook) {
                    ((ActionHook) processor).action(ActionCode.ACTION_START, 
null);
                }


                processor.setSslSupport(null);


                SocketState state = processor.process(socket);
                if (state != SocketState.CLOSED) {
                    // Associate the connection with the processor. The next 
request
                    // processed by this thread will use either a new or a 
recycled
                    // processor.
                    if (log.isDebugEnabled()) log.debug("Not recycling
["+processor+"]
Comet="+((NioEndpoint.KeyAttachment)socket.getAttachment(false)).getComet());
                    connections.put(socket, processor);
                    socket.getPoller().add(socket);
                } else {
                    connections.remove(socket);
                    recycledProcessors.offer(processor);
                }
                return state;

            } catch (java.net.SocketException e) {
                // SocketExceptions are normal
               
log.debug(sm.getString("http11protocol.proto.socketexception.debug"), e);
            } catch (java.io.IOException e) {
                // IOExceptions are normal
               
log.debug(sm.getString("http11protocol.proto.ioexception.debug"), e);
            }
            // Future developers: if you discover any other
            // rare-but-nonfatal exceptions, catch them here, and log as
            // above.
            catch (Throwable e) {
                // any other exception or error is odd. Here we log it
                // with "ERROR" level, so it will show up even on
                // less-than-verbose logs.
                log.error(sm.getString("http11protocol.proto.error"), e);
            }
            connections.remove(socket);
            recycledProcessors.offer(processor);
            return SocketState.CLOSED;
        }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to