On 25/07/2018 13:49, Chris Hegarty wrote:
:
The updates to the various site to use the NET_* functions are fine. However, I 
think the new functions in net_util_md.c could be cleaner. I think it would be 
better to fallback to socket/socketpair + fcntl when the initial call fails 
with EINVAL.
Agreed. How about this ( trying to reduce the ifdef blocks, and
keep them relatively clean ) :

---
JNIEXPORT int JNICALL
NET_Socket(int domain, int type, int protocol) {
     int s;
#if defined(SOCK_CLOEXEC)
     s = socket(domain, type | SOCK_CLOEXEC, protocol);
     if (s != -1 || (s == -1 && errno != EINVAL)) {
         return s;
     }
#endif
     s = socket(domain, type, protocol);
     if (s != -1) {
         // Best effort - return value is intentionally ignored since the socket
         // was successfully created.
         fcntl(s, F_SETFD, FD_CLOEXEC);
     }
     return s;
}
---

Updated webrev:
   http://cr.openjdk.java.net/~chegar/8207335/webrev.01/

This looks much better - thanks!

-Alan

Reply via email to