Hi Alan/Volker, I just found out that the code works by adding the same static block (net library loading) into SocketImpl.java although isReusePortAvailable() is being defined in its subclass AbstractPlainSocketIml.java. I use a print statement to confirm that both static blocks from SocketImpl and AbstractSocketImpl are being executed.
Is this a reasonable way to implement? Or, we can remove the block from AbstractPlainSocketImpl, only have it in SocketImpl if you think that is better. Please let us know. Thanks, Lucy -----Original Message----- From: net-dev [mailto:net-dev-boun...@openjdk.java.net] On Behalf Of Lu, Yingqi Sent: Monday, January 04, 2016 3:30 PM To: Volker Simonis <volker.simo...@gmail.com>; Alan Bateman <alan.bate...@oracle.com> Cc: net-dev@openjdk.java.net; Viswanathan, Sandhya <sandhya.viswanat...@intel.com>; Kharbas, Kishor <kishor.khar...@intel.com>; Aundhe, Shirish <shirish.aun...@intel.com>; Kaczmarek, Eric <eric.kaczma...@intel.com> Subject: RE: Patch for adding SO_REUSEPORT socket option One more question, we tried to move the isReusePortAvailable() from SocketImpl.java to AbstractPlainSocketImpl.java. However, we found out the static block (attached below) inside the AbstractPlainSocketImpl.java never being executed when the AbstractPlainSocketImpl.isReusePortAvailable() is called which leads to an unsatisfiedlinkerror (net library is not loaded). We created a small testing java program which has an abstract class. The static block inside the abstract class is executed no problem at all. What did we miss here? static { java.security.AccessController.doPrivileged( new java.security.PrivilegedAction<>() { public Void run() { System.loadLibrary("net"); return null; } }); } Thanks, Lucy -----Original Message----- From: Volker Simonis [mailto:volker.simo...@gmail.com] Sent: Monday, January 04, 2016 11:26 AM To: Alan Bateman <alan.bate...@oracle.com> Cc: Lu, Yingqi <yingqi...@intel.com>; Kaczmarek, Eric <eric.kaczma...@intel.com>; Viswanathan, Sandhya <sandhya.viswanat...@intel.com>; Kharbas, Kishor <kishor.khar...@intel.com>; Aundhe, Shirish <shirish.aun...@intel.com>; net-dev@openjdk.java.net Subject: Re: Patch for adding SO_REUSEPORT socket option On Mon, Jan 4, 2016 at 8:24 PM, Alan Bateman <alan.bate...@oracle.com> wrote: > > > On 04/01/2016 18:43, Volker Simonis wrote: >> >> : >> Alan, what do you mean by "unknown" platform? Currently, as far as I >> know, 0x0200 is used by AIX and MacOS X. Do you suggest to name these >> platforms explicitly and set it to 0 otherwise? Leaving the default >> at >> 0x0200 has the advantage that it would implicitly work on other >> platforms like HPUX at the risk that it may be the wrong value on >> other, yet still unknown platforms. So in general I'm not against >> setting it to 0 on unknown platfroms (as this is the most secure >> setting) but in that case we should definitely name AIX and MacOS X >> as "known" platforms. > > My concern with defaulting to 0x0200 is that it might be used on a > platform where this is not the right value. Defaulting to 0 makes it > easier to catch the issue and allows us to includes assertion that the > socket option is != 0. If we build on versions of AIX and OSX that > don't have SO_REUSEPORT defined then it would be good to get those into the > known platform list. > Agree! Lucy, please add the MacOs and AIX cases. No need to do it for HPUX as this is not an official OpenJDK platform yet (we'll do that in our internal port). Thanks, Volker > -Alan