Re: RFR: 8255078: sun/net/ftp/imp/FtpClient$MLSxParser uses wrong datetime format [v3]

2020-10-26 Thread Igor Ignatyev
On Sun, 25 Oct 2020 00:35:20 GMT, Marcono1234 
 wrote:

>> Igor Ignatyev has updated the pull request incrementally with one additional 
>> commit since the last revision:
>> 
>>   use only filename in assert message
>
> src/java.base/share/classes/sun/net/ftp/impl/FtpClient.java line 1777:
> 
>> 1775: }
>> 1776: 
>> 1777: private static Date parseRfc3659TimeValue(String s) {
> 
> Shouldn't this method be synchronized because `SimpleDateFormat` is not 
> thread-safe, but instances are stored in the static field `dateFormats`?
> (Note though that this issue existed before as well)

thanks @Marcono1234, it indeed needs to be `synchronized`, I'll take care of 
fixing that.

-

PR: https://git.openjdk.java.net/jdk/pull/776


RFR: 8255405: sun/net/ftp/imp/FtpClient uses SimpleDateFormat in not thread-safe manner

2020-10-26 Thread Igor Ignatyev
Hi all,

could you please review this small and trivial fix?

`sun/net/ftp/imp/FtpClient::dateFormats` is an array of `SimpleDateFormat` 
which are shared among all instances of `FtpClient`. the fact that 
`SimpleDateFormat` isn't thread-safe renders`FtpClient` to be non-thread-safe 
as well. the patch makes the only usage of `dateFormats` array, 
`parseRfc3659TimeValue` method, `synchronized`.

the problem was reported in #776

Thanks,
-- Igor

-

Commit messages:
 - 8255405: sun/net/ftp/imp/FtpClient uses SimpleDateFormat in not thread-safe 
manner

Changes: https://git.openjdk.java.net/jdk/pull/867/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=867&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8255405
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/jdk/pull/867.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/867/head:pull/867

PR: https://git.openjdk.java.net/jdk/pull/867


Re: RFR(s): Improving performance of Windows socket connect on the loopback adapter

2020-10-26 Thread Mat Carter
Nikola has opened an issue to cover the loopback address range and we're 
preparing a patch:

https://bugs.openjdk.java.net/browse/JDK-8255264

We've identified some unit tests to include in the patch, does 
gtest/runtime/test_os_windows.cpp seem the appropriate location for them?

Patch (preview):


diff --git a/src/java.base/windows/native/libnet/net_util_md.h 
b/src/java.base/windows/native/libnet/net_util_md.h

index b76935db3de..2f873b6295e 100644

--- a/src/java.base/windows/native/libnet/net_util_md.h

+++ b/src/java.base/windows/native/libnet/net_util_md.h

@@ -90,24 +90,30 @@ struct ipv6bind {

 /**

  * With dual socket implementation the

  * IPv4 addresseses might be mapped as IPv6.

- * The IPv4 loopback adapter address will

- * be mapped as the following IPv6 :::127.0.0.1.

+ * The IPv4 loopback adapter address ranges (127.0.0.0 through 
127.255.255.255) will

+ * be mapped as the following IPv6 :::127.0.0.0 through 
:::127.255.255.255.

  * For example, this is done by NET_InetAddressToSockaddr.

  */

 #define IN6_IS_ADDR_V4MAPPED_LOOPBACK(x) ( \

-(((x)->s6_words[0] == 0)  &&  \

- ((x)->s6_words[1] == 0)  &&  \

- ((x)->s6_words[2] == 0)  &&  \

- ((x)->s6_words[3] == 0)  &&  \

- ((x)->s6_words[4] == 0)  &&  \

- ((x)->s6_words[5] == 0x) &&  \

- ((x)->s6_words[6] == 0x007F) &&  \

- ((x)->s6_words[7] == 0x0100))\

+(((x)->s6_words[0] == 0)   &&  \

+ ((x)->s6_words[1] == 0)   &&  \

+ ((x)->s6_words[2] == 0)   &&  \

+ ((x)->s6_words[3] == 0)   &&  \

+ ((x)->s6_words[4] == 0)   &&  \

+ ((x)->s6_words[5] == 0x)  &&  \

+ (((x)->s6_words[6] & 0x00FF) == 0x007F)) \

+)

+

+/**

+ * Check for IPv4 loopback adapter address ranges (127.0.0.0 through 
127.255.255.255)

+ */

+#define IN4_IS_ADDR_NETLONG_LOOPBACK(l) ( \

+((l & 0xFF00) == 0x7F00) \

 )



 #define IS_LOOPBACK_ADDRESS(x) ( \

 ((x)->sa.sa_family == AF_INET) ? \

-(ntohl((x)->sa4.sin_addr.s_addr) == INADDR_LOOPBACK) : \

+(IN4_IS_ADDR_NETLONG_LOOPBACK(ntohl((x)->sa4.sin_addr.s_addr))) : \

 ((IN6_IS_ADDR_LOOPBACK(&(x)->sa6.sin6_addr)) || \

  (IN6_IS_ADDR_V4MAPPED_LOOPBACK(&(x)->sa6.sin6_addr))) \

 )

Cheers
Mat

From: net-dev  on behalf of Nikola Grcevski 

Sent: Thursday, August 6, 2020 7:37 AM
To: Alan Bateman ; net-dev@openjdk.java.net 

Subject: RE: RFR(s): Improving performance of Windows socket connect on the 
loopback adapter

Yes, please.

Thank you,
Nikola

-Original Message-
From: Alan Bateman 
Sent: August 6, 2020 9:49 AM
To: Nikola Grcevski ; net-dev@openjdk.java.net
Subject: Re: RFR(s): Improving performance of Windows socket connect on the 
loopback adapter

On 04/08/2020 16:36, Nikola Grcevski wrote:
> Hi Alan,
>
>> What cheap is VerifyVersionInfoW? The check is done everytime but the 
>> overhead might be in the noise. Overall it looks good to me.
> I wrote a small benchmark to measure the overhead of the version check 
> (attached below).
>
> On my SurfaceBook 2 running Windows 10 Build 19041, the version check
> measures about ~2.2us (micro seconds) on average, when the version matches.
>
> Elapsed time 2244us. (for 1,000 iterations)
>
> On a Windows 2016 Data Center Server the version check is much smaller
> ~0.13us (micro seconds) on average, when the version doesn't match.
>
> Elapsed time 128us. (for 1,000 iterations)
>
> I think the overhead is reasonably small compared to everything else. Please 
> let me know if it's acceptable and if we can proceed.
>
>
Okay. So do you me to sponsor this?

-Alan


Re: RFR: 8254871: Remove unnecessary string copy in NetworkInterface.c

2020-10-26 Thread Eric Liu
On Fri, 23 Oct 2020 03:18:27 GMT, Eric Liu 
 wrote:

> A small improvement to avoid extra string copy.
> 
> [Tests]
> Jtreg hotspot::hotspot_all_no_apps, jdk::jdk_core and langtools::tier1.
> No new failure found.

@kimbarrett Could you help to take look at this trivial patch?

-

PR: https://git.openjdk.java.net/jdk/pull/821