Native Socket Error On OS X (BSDs)

Xiaobin Lu Xiaobin.Lu at Sun.COM
Mon Dec 22 14:26:49 PST 2008


So if I understand correctly, the usage under "#ifdef __APPLE__" isn't 
working properly, in other words, using "select" is problematic in this 
case. But my question is "why using poll instead of select worked?"

Thanks so much in advance for your clarification.

-Xiaobin

Michael Franz wrote:
> Greg,
>
> On Mon, Dec 22, 2008 at 9:29 AM, Greg Lewis <glewis at eyesbeyond.com 
> <mailto:glewis at eyesbeyond.com>> wrote:
>
>     G'day Michael,
>
>     On Sun, Dec 21, 2008 at 09:16:41PM -0500, Michael Franz wrote:
>     > I have been investigating this more and been trying to figure
>     out where
>     > NET_Timeout is defined on OS X.  It is being called in
>     PlanSocketImpl.c.
>     > There are two definitions that I have found, one for linux and
>     one for bsd.
>     > A third uses JVM_Timeout.  The bsd version is specific to
>     FreeBSD.  Are
>     > there known issues with JVM_Timeout?  Why does Linux and FreeBSD
>     need
>     > definitions that are different from the one in Hotspot?
>
>
> Based on the fact that Solaris does not have a specific version and 
> Linux and FreeBSD do, the HotSpot implementation should be available.  
> It might be a good time to remove the Linux and FreeBSD version so 
> that all the platforms use the same code.
>  
>
>
>     They look very similar don't they.  I wonder if the HotSpot version is
>     actually exposed for the JDK code to use?
>
>     > jdk/src/solaris/native/java/net/bsd_close.c
>     > jdk/src/solaris/native/java/net/linux_close.c
>     > hotspot/src/os/bsd/vm/hpi_bsd.hpp
>     >
>     > I changed the inline int hpi::timeout(int fd, long timeout)
>     method to not
>     > use the Apple specific code and I think the problem is fixed (at
>     least for
>     > me).
>
>
> Yes, just ignoring/removing the Apple specific coding seemed to fix 
> the problem. 
>
> I did not do any deep research into socket programming on OS X.  
> Anyone with knowledge of sockets on OS X comment on the comments?  Is 
> poll on Tiger really not interruptable?
>  
>
>
>     So just removing the __APPLE__ code below fixes it for you?  I can
>     commit
>     that change for you.
>
>     > #ifdef __APPLE__
>     >     // XXXDARWIN: poll() appears non-interruptable on Leopard:
>     > Thread.interrupt() failed to
>     >     // cause interrupt. Does poll work at all on Tiger? Needs
>     investigation.
>     >     fd_set fdset;
>     >     struct timeval seltv;
>     >
>     >     FD_ZERO(&fdset);
>     >     FD_SET(fd, &fdset);
>     >
>     >     seltv.tv_sec = timeout / 1000;
>     >     seltv.tv_usec = (timeout % 1000) * 1000;
>     >
>     >     INTERRUPTIBLE_NORESTART(::select(fd+1, &fdset, NULL, NULL,
>     &seltv), res,
>     > os::Bsd::clear_interrupted);
>     > #else
>     >     struct pollfd pfd;
>     >
>     >     pfd.fd = fd;
>     >     pfd.events = POLLIN | POLLERR;
>     >
>     >     INTERRUPTIBLE_NORESTART(::poll(&pfd, 1, timeout), res,
>     > os::Bsd::clear_interrupted);
>     > #endif
>     >
>     > Michael
>     >
>     --
>     Greg Lewis                          Email   :
>     glewis at eyesbeyond.com <mailto:glewis at eyesbeyond.com>
>     Eyes Beyond                         Web     :
>     http://www.eyesbeyond.com
>     Information Technology              FreeBSD : glewis at FreeBSD.org
>
> Michael
> ------------------------------------------------------------------------
>
>
>   




More information about the bsd-port-dev mailing list