Andrew,

I filed the following issue to track this:
  https://bugs.openjdk.java.net/browse/JDK-8207335

Once you produce an updated patch, I can review and
sponsor this for you.

-Chris.

On 12/07/18 08:21, Andrew Luo wrote:
Thanks, I can refactor it.  I’m not as familiar with the OpenJDK architecture – should I just duplicate the function into libnio or is there some common utility library that I should move it into?  Also, let me know what in net_util_* needs cleanup.  The other instances of socket/socketpair in Mac/AIX/Solaris I’m willing to handle as well.

Files are mostly already handled: https://bugs.openjdk.java.net/browse/JDK-8043780 (in a similar way – O_CLOEXEC on systems that support it and fcntl on other POSIX systems). One other resource you mentioned is epolls.  Perhaps there’s also other file descriptors that are being used elsewhere, but I think it will take me longer time to figure out.  I’m willing to work on that as well if we all think it’s a good idea.

Anyways, while I agree that it would be ideal to address those other file descriptors as well, is it ok to address those in a separate changeset, or do you think that this changeset doesn’t really provide value unless we make this change everywhere?  Sockets are somewhat more problematic than other types of file descriptors (in my opinion) as if you use it to listen on a port and then fork child processes (from native code) then restart the parent process, it won’t be able to listen to the same port until all of the children processes (of the previous process) exit/close the fd.  Other file descriptors, unless you open in exclusive mode, won’t have the same problem (although the behavior is undesirable).

Thanks,

-Andrew

*From:*Alan Bateman <alan.bate...@oracle.com>
*Sent:* Wednesday, July 11, 2018 11:59 PM
*To:* Andrew Luo <andrewluotechnolog...@outlook.com>
*Cc:* Martin Buchholz <marti...@google.com>; net-dev@openjdk.java.net
*Subject:* Re: [PATCH] SOCK_CLOEXEC for opening sockets

On 12/07/2018 05:55, Andrew Luo wrote:

    Ok, fixed a few more places (and a bug where fcntl was being run on
    a -1 fd).  Patch is below, let me know if there’s any other
    suggestions/etc.

The file system code should not be calling into NET_* functions.  The changes to net_util_* will also need cleanup. Otherwise I think you've got all the places in the networking / NIO APIs, at least on Linux. There are others on macOS, Solaris, ... of course.

That said,  I assume we have many more places in the JDK that have file descriptors to open files and other resources. If we really want to support the case of someone calling fork/exec from JNI code then it will likely need work in several other areas.

-Alan

Reply via email to