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 2016/02/16 12:33:28 UTC

[Bug 59010] New: Disabling socketBuffer with "-1" doesn't cause exception on linux

https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

            Bug ID: 59010
           Summary: Disabling socketBuffer with "-1" doesn't cause
                    exception on linux
           Product: Tomcat 7
           Version: 7.0.54
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: rashmikatagall@in.ibm.com

I have implemented a service using Http11Protocol and I have disabled the
socketBuffer for the object by setting its value to "-1". When the client
disconnects before the server responds, then on windows I see the exception:

SEVERE: Error processing request
java.net.SocketException: Unrecognized Windows Sockets error: 0: socket write
er
ror
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:125)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:171)
        at
org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffe
r.doWrite(InternalOutputBuffer.java:243)
        at
org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(Identit
yOutputFilter.java:84)
        at
org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputB
uffer.java:192)
        at org.apache.coyote.Response.doWrite(Response.java:499)
        at dummyAdapter.service(dummyAdapter.java:49)

But on linux, I don't see any exception raised.

My listener looks like this:
public class TomcatCipherTst {
   public static void main(String[] args) throws Exception {
    Http11Protocol h1p = new BrokerProtocolHandler();  
    h1p.setSocketBuffer(-1);
        h1p.setMaxKeepAliveRequests(-1);
        Adapter ac = new dummyAdapter();
        h1p.setAdapter(ac);
        h1p.setPort(7677);
    h1p.init();
    h1p.start();

    boolean status = ((BrokerProtocolHandler)h1p).getEndpoint().isRunning();

        System.out.println("status = " + status);

        Thread.sleep(1000000);  
      }
    }

My adapter service implementation looks like this:
public class dummyAdapter implements Adapter {
  public boolean asyncDispatch(Request arg0, Response arg1, SocketStatus arg2)
            throws Exception {
            return false;
    }

    public boolean event(Request arg0, Response arg1, SocketStatus arg2)
            throws Exception {
        return false;
    }

    public String getDomain() {
        return null;
    }

    public void log(Request arg0, Response arg1, long arg2) {

    }

    public void service(Request req, Response res) throws Exception {

        System.out.println("We got em");
        Thread.sleep(3000);

    String resp = new String("We got request for |" +
req.requestURI().toString() + "|");
        ByteChunk bc = new ByteChunk();
        byte[] respBA = resp.getBytes("utf-8");
        bc.setBytes(respBA, 0, respBA.length);
        res.setContentLength(respBA.length);
        res.doWrite(bc);
        res.finish();
    }

    public void checkRecycled(Request arg0, Response arg1) {

    }

    public void errorDispatch(Request arg0, Response arg1) {

    }
}

BrokerProtocolHandler is:
public class BrokerProtocolHandler extends
org.apache.coyote.http11.Http11Protocol
{
    public BrokerProtocolHandler() {
        super();
    }

    public AbstractEndpoint getEndpoint() {
        return endpoint;
    }
}



Can you please take a look at this and help us understand why there is no
exception on linux?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

--- Comment #3 from Rashmi <ra...@in.ibm.com> ---
So to clarify further, when we set socketBuffer to "-1" and if the client
disconnects before the server responds, what is the expected behaviour?
Is it that a socket error exception must be seen like on windows or the server
silently attempt to send response and not throw an error if that's not possible
like on linux?

The socket error thrown on windows is very useful on server side as we know
that there was an error sending response as the client disconnected. Is there
any other way we can make the server log the error when client disconnects
other than setting socketBuffer to "-1"

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Mark Thomas <ma...@apache.org> changed:

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

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
When I:
- run your test code on linux
- add a break point immediately after the sleep in DummyAdapter
- kill the client when the break point is reached

then I see a broken pipe exception with Linux.

There is always going to be an element of timing and buffering at play in
experiments such as this. If the client goes away after the server has written
the data but before the client has read it then things are going to get lost
and there is very little you can do about that.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Rashmi <ra...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |---
             Status|RESOLVED                    |REOPENED

--- Comment #7 from Rashmi <ra...@in.ibm.com> ---
Since this code is part of our runtime, we cannot add breakpoint to confirm the
behaviour. However I added a very long sleep of 1 minute and disconnected the
client as soon as sending the request. But still dont see the broken pipe :(

Please suggest what could be wrong with the linux box?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Remy Maucherat <re...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |WORKSFORME

--- Comment #10 from Remy Maucherat <re...@apache.org> ---
Ok, so you now get the "not nice" answer ...

You are providing paid support to a third party, and are actively annoying /
spamming the community with your customer issue. That is not fine in BZ, please
move the discussion to the user list.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

--- Comment #4 from Christopher Schultz <ch...@christopherschultz.net> ---
Are you positive you have the same endpoint configuration on both servers
(Windows/Linux)? You appear to be using the BIO endpoint on Windows (given the
stack trace), but you didn't say what you were using on Linux. The handler and
the endpoint must agree on I/O strategy, or at least so-says the javadoc for
AbstractProtocol.endpoint (starting at line 80 in Tomcat 7.0.x trunk):

    /**
     * Endpoint that provides low-level network I/O - must be matched to the
     * ProtocolHandler implementation (ProtocolHandler using BIO, requires BIO
     * Endpoint etc.).
     */

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|REOPENED                    |RESOLVED

--- Comment #8 from Mark Thomas <ma...@apache.org> ---
No idea but unless you can provide a reproducible test case that demonstrates a
problem, this isn't a Tomcat bug.

If you want a "what might be going wrong" discussion then this isn't the place.
Please use the users mailing list.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

--- Comment #2 from Christopher Schultz <ch...@christopherschultz.net> ---
This looks like a JVM bug to me: error code 0 is usually considered "success".
It could also be some other networking component (e.g. software firewall,
virus-scanner, etc.) interfering with the channel.

Do you have anything like that running that might unexpectedly close a network
connection, or otherwise cause data to refuse to write?

A similar issue closed INVALID based upon the assumption that it's a problem
with the OS (more likely the JVM, but possibly the OS):
https://issues.apache.org/jira/browse/HTTPCLIENT-957

Another similar issue (no JVM involved, I think), claiming that the problem is
with a firewall (seems like a sketchy explanation to me):
http://www-01.ibm.com/support/docview.wss?uid=swg21968078

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

--- Comment #5 from Rashmi <ra...@in.ibm.com> ---
I think the same configuration is used on Linux as well. We are using the same
code sample attached in the first comment on both servers and the jre is also
the same.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

--- Comment #1 from Rashmi <ra...@in.ibm.com> ---
Can you please help me with this? I work for IBM L3 support and customer is
looking for an answer.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Rashmi <ra...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WORKSFORME                  |FIXED

--- Comment #9 from Rashmi <ra...@in.ibm.com> ---
Can you please check it without the breakpoint and with increased sleep time?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 59010] Disabling socketBuffer with "-1" doesn't cause exception on linux

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59010

Rashmi <ra...@in.ibm.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rashmikatagall@in.ibm.com

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org