From dev-return-200324-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Sun Jul 14 17:10:25 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 4B93618066C for ; Sun, 14 Jul 2019 19:10:25 +0200 (CEST) Received: (qmail 6111 invoked by uid 500); 14 Jul 2019 17:10:23 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 6100 invoked by uid 99); 14 Jul 2019 17:10:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 14 Jul 2019 17:10:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3CDF1C0180 for ; Sun, 14 Jul 2019 17:10:23 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.199 X-Spam-Level: X-Spam-Status: No, score=-0.199 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_EXCESS_BASE64=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=frantovo.cz Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 0r6gCqUoeRQM for ; Sun, 14 Jul 2019 17:10:20 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=91.219.244.97; helo=posta.frantovo.cz; envelope-from=konference@frantovo.cz; receiver= Received: from posta.frantovo.cz (czf.frantovo.cz [91.219.244.97]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with ESMTPS id 9F4217E1FD for ; Sun, 14 Jul 2019 17:10:19 +0000 (UTC) Received: from [192.168.1.4] (osma.doma.frantovo.cz [192.168.1.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: fiki@frantovo.cz) by posta.frantovo.cz (Postfix) with ESMTPSA id A80E61877ED for ; Sun, 14 Jul 2019 19:10:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=frantovo.cz; s=default; t=1563124201; bh=wr+R8Tr8JZ4C3AsjDB25Ny5nN30jWeWutkaEDa+iYK4=; h=To:From:Subject:Date; b=UWgS/6iN5KXoCaOIzc0JQAmeWXSC6Xf1erbm8660JGPiV0vZ+nZ1QOfPbNDhPQeis b3u/7YLIEgbWCI2JkZEErBj6VGIDdKlhSQWjL257iq65XtvnAG3R232tS1kEjrFgSU T6DtjS4mkS7l5151KaQhdNCZcPanGEI9PoeFnzqg= To: dev@tomcat.apache.org From: =?UTF-8?B?RnJhbnRpxaFlayBLdcSNZXJh?= Subject: Allow keeping tcpNoDelay untouched (default) Message-ID: <4b88f0d7-9263-9097-000d-a9f154231b71@frantovo.cz> Date: Sun, 14 Jul 2019 19:10:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------489959BA420AB38489172606" Content-Language: en-US X-Virus-Scanned: clamav-milter 0.98.1 at posta X-Virus-Status: Clean --------------489959BA420AB38489172606 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Hello, I got this error when new HTTP request comes: 14-Jul-2019 18:18:39.296 SEVERE [http-nio-8080-Acceptor] org.apache.tomcat.util.net.NioEndpoint.setSocketOptions Error setting socket options         java.net.SocketException: Operace není podporována                 at sun.nio.ch.Net.setIntOption0(Native Method)                 at sun.nio.ch.Net.setSocketOption(Net.java:334)                 at sun.nio.ch.SocketChannelImpl.setOption(SocketChannelImpl.java:190)                 at sun.nio.ch.SocketAdaptor.setBooleanOption(SocketAdaptor.java:271)                 at sun.nio.ch.SocketAdaptor.setTcpNoDelay(SocketAdaptor.java:306)                 at org.apache.tomcat.util.net.SocketProperties.setProperties(SocketProperties.java:204)                 at org.apache.tomcat.util.net.NioEndpoint.setSocketOptions(NioEndpoint.java:401)                 at org.apache.tomcat.util.net.NioEndpoint.setSocketOptions(NioEndpoint.java:73)                 at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:115)                 at java.lang.Thread.run(Thread.java:748) do not panic, this does not happen in normal conditions - my setup is kind of special. Given socket does not support the tcpNoDelay option, so it throws an exception. To get rid of it, I patched the Tomcat's source code (see attachment, it patches the latest git version). I am looking for a more clean solution that could be merged in the official sources. IMHO it might keep the state of socket's tcpNoDelay untouched (i.e. do not call setTcpNoDelay() method) if there is no explicit configuration to set this option. I looked in the git history and current sources and there is the condition: "if (tcpNoDelay != null)" and: /**  * TCP_NO_DELAY option. JVM default used if not set.  */ protected Boolean tcpNoDelay = Boolean.TRUE; and it was "tcpNoDelay = null;" in 2008. So it seems that it worked this way before... But now it always calls setTcpNoDelay(true) if not configured to false (and then it calls setTcpNoDelay(false)). I have not found any way to configure Tomcat to not set this option and keep the socket in its original state. Or there might be a third option in the tcpNoDelay configuration like "default" or "null" besides the "true" and "false" (i.e. convert some booleans to Booleans in the source code and allow the null value). This might be more backward compatible behavior. I can help with writing the patch and testing but I would appreciate some design advice. Context: I am interested in making applications listen on unix domain sockets instead of TCP ones (e.g. Jetty can work this way) and especially in listening on sockets inherited from parent process (the "useInheritedChannel" in Tomcat's Connector configuration). And unix domain socket has no tcpNoDelay option obviously. Franta --------------489959BA420AB38489172606 Content-Type: text/x-patch; name="tomcat-tcpNoDelay-1.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="tomcat-tcpNoDelay-1.diff" diff --git a/java/org/apache/tomcat/util/net/SocketProperties.java b/java/org/apache/tomcat/util/net/SocketProperties.java index a5573b0231..245b29507f 100644 --- a/java/org/apache/tomcat/util/net/SocketProperties.java +++ b/java/org/apache/tomcat/util/net/SocketProperties.java @@ -201,7 +201,11 @@ public class SocketProperties { if (soTimeout != null && soTimeout.intValue() >= 0) socket.setSoTimeout(soTimeout.intValue()); if (tcpNoDelay != null) - socket.setTcpNoDelay(tcpNoDelay.booleanValue()); + try { + socket.setTcpNoDelay(tcpNoDelay.booleanValue()); + } catch (SocketException e) { + // option is not supported - ignore + } } public void setProperties(ServerSocket socket) throws SocketException{ --------------489959BA420AB38489172606 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org --------------489959BA420AB38489172606--