You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2006/11/13 19:22:30 UTC

DO NOT REPLY [Bug 40960] New: - APR versus non-APR behavior difference: Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

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=40960>.
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=40960

           Summary: APR versus non-APR behavior difference: Timeout when
                    reading from underlying socket does throw IOException
                    with APR and SocketTimeoutException without APR
           Product: Tomcat 5
           Version: 5.5.20
          Platform: PC
        OS/Version: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Connector:HTTP
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: cpierret@sparus-software.com


Timeout when reading from underlying socket does throw IOException with APR and
SocketTimeoutException without APR.
This difference causes servlet code handling "timeout exceptions" to break (and
not be fixeable) if APR is used.
In class "org.apache.coyote.http11.InternalAprInputBuffer" for method "boolean
fill() throws IOException":
(in block if (!parsingHeader) ) The return code for Socket.recvbb  is not
checked for Status.ETIMEDOUT or Status.TIMEUP, therefore an IOException is
thrown whatever the reason for the exception.  This is a behavior change from
non-APR HTTP 1.1 connector.

The following new code for the fill method fixes the issue:
   /**
     * Fill the internal buffer using data from the undelying input stream.
     *
     * @return false if at end of stream
     */
    protected boolean fill()
        throws IOException {

        int nRead = 0;

        if (parsingHeader) {

            if (lastValid == buf.length) {
                throw new IOException
                    (sm.getString("iib.requestheadertoolarge.error"));
            }

            bbuf.clear();
            nRead = Socket.recvbb
                (socket, 0, buf.length - lastValid);
            if (nRead > 0) {
                bbuf.limit(nRead);
                bbuf.get(buf, pos, nRead);
                lastValid = pos + nRead;
            } else {
                if ((-nRead) == Status.EAGAIN) {
                    return false;
                } else {
                    throw new IOException(sm.getString("iib.failedread"));
                }
            }

        } else {

            buf = bodyBuffer;
            pos = 0;
            lastValid = 0;
            bbuf.clear();
            nRead = Socket.recvbb
                (socket, 0, buf.length);
            if (nRead > 0) {
                bbuf.limit(nRead);
                bbuf.get(buf, 0, nRead);
                lastValid = nRead;
            } else {
// CP: Start change
		if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) {
			throw new java.net.SocketTimeoutException(sm.getString("iib.failedread"));
		} else {
			throw new IOException(sm.getString("iib.failedread"));
		}
// CP: End change
            }

        }

        return (nRead > 0);

    }

Since SocketTimeOutException is also an IOException, this modification cannot
break code that does not filter timeout exceptions.

-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960


yoavs@computer.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From yoavs@computer.org  2007-03-25 09:21 -------
You're right, this is a regression bug inconsistency, and I've run into it
myself.  I've just put in your patch on the 5.5 branch, in time for the next
release (5.5.24).  Thank you for contributing it.

It might also need to be applied in the Tomcat 6 tree, but I haven't checked and
there have been other relevant changes to the connector on that branch.

-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960





------- Additional Comments From cpierret@sparus-software.com  2007-03-27 07:34 -------
This one has been fixed in Tomcat6 using the same patch.

-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - APR versus non-APR behavior difference: Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960





------- Additional Comments From chris@sourcelabs.com  2006-12-29 12:09 -------
Created an attachment (id=19328)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=19328&action=view)
Patch incorporating inline suggested code change


-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960


alexkrish@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|5.5.20                      |5.5.23




-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960


cpierret@sparus-software.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|APR versus non-APR behavior |Timeout when reading from
                   |difference: Timeout when    |underlying socket does throw
                   |reading from underlying     |IOException with APR and
                   |socket does throw           |SocketTimeoutException
                   |IOException with APR and    |without APR
                   |SocketTimeoutException      |
                   |without APR                 |




-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960





------- Additional Comments From markt@apache.org  2007-07-31 04:37 -------
(In reply to comment #4)
> In the description it is told as the issue is there in 5.5.23,but in the
> changelog of tomcat 5.5 it is been told that from the version 5.5.10 this issue
> is fixed.

You are mis-reading the changelog. This issue does not appear in the changelog
for 5.5.23.

> "Fix NPE when POST size exceeds limit defined by maxPostSize. (markt)".

The NPE fix has nothing to do with this bug.

The fix will be in 5.5.24 onwards.

-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - APR versus non-APR behavior difference: Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960


cpierret@sparus-software.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable




-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


DO NOT REPLY [Bug 40960] - Timeout when reading from underlying socket does throw IOException with APR and SocketTimeoutException without APR

Posted by bu...@apache.org.
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=40960>.
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=40960


sujai1009@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows 2000                |All
            Version|5.5.23                      |5.5.22




------- Additional Comments From sujai1009@gmail.com  2007-07-31 00:15 -------
In the description it is told as the issue is there in 5.5.23,but in the
changelog of tomcat 5.5 it is been told that from the version 5.5.10 this issue
is fixed.

"Fix NPE when POST size exceeds limit defined by maxPostSize. (markt)".

Can anyone help me that what i refering is correct or not

(In reply to comment #0)
> Timeout when reading from underlying socket does throw IOException with APR and
> SocketTimeoutException without APR.
> This difference causes servlet code handling "timeout exceptions" to break (and
> not be fixeable) if APR is used.
> In class "org.apache.coyote.http11.InternalAprInputBuffer" for method "boolean
> fill() throws IOException":
> (in block if (!parsingHeader) ) The return code for Socket.recvbb  is not
> checked for Status.ETIMEDOUT or Status.TIMEUP, therefore an IOException is
> thrown whatever the reason for the exception.  This is a behavior change from
> non-APR HTTP 1.1 connector.
> 
> The following new code for the fill method fixes the issue:
>    /**
>      * Fill the internal buffer using data from the undelying input stream.
>      *
>      * @return false if at end of stream
>      */
>     protected boolean fill()
>         throws IOException {
> 
>         int nRead = 0;
> 
>         if (parsingHeader) {
> 
>             if (lastValid == buf.length) {
>                 throw new IOException
>                     (sm.getString("iib.requestheadertoolarge.error"));
>             }
> 
>             bbuf.clear();
>             nRead = Socket.recvbb
>                 (socket, 0, buf.length - lastValid);
>             if (nRead > 0) {
>                 bbuf.limit(nRead);
>                 bbuf.get(buf, pos, nRead);
>                 lastValid = pos + nRead;
>             } else {
>                 if ((-nRead) == Status.EAGAIN) {
>                     return false;
>                 } else {
>                     throw new IOException(sm.getString("iib.failedread"));
>                 }
>             }
> 
>         } else {
> 
>             buf = bodyBuffer;
>             pos = 0;
>             lastValid = 0;
>             bbuf.clear();
>             nRead = Socket.recvbb
>                 (socket, 0, buf.length);
>             if (nRead > 0) {
>                 bbuf.limit(nRead);
>                 bbuf.get(buf, 0, nRead);
>                 lastValid = nRead;
>             } else {
> // CP: Start change
> 		if ((-nRead) == Status.ETIMEDOUT || (-nRead) == Status.TIMEUP) {
> 			throw new java.net.SocketTimeoutException(sm.getString("iib.failedread"));
> 		} else {
> 			throw new IOException(sm.getString("iib.failedread"));
> 		}
> // CP: End change
>             }
> 
>         }
> 
>         return (nRead > 0);
> 
>     }
> 
> Since SocketTimeOutException is also an IOException, this modification cannot
> break code that does not filter timeout exceptions.



-- 
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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org