Native Socket Error On OS X (BSDs)
Xiaobin Lu
Xiaobin.Lu at Sun.COM
Tue Dec 23 10:20:27 PST 2008
Michael,
Thanks for your investigation on this. So instead of removing the Apple
specific code, can we just detect the "-1" argument and pass "NULL" to
select as the last argument which has equivalent meaning as "-1" to
"poll"? I think that might be a safer fix than just removing that code.
My 2 cents.
-Xiaobin
On 12/22/08 20:30, Michael Franz wrote:
> Xiaobin,
>
> By not using the APPLE specific code the connections work. The reason
> the select does not is that there is an invalid argument being passed
> to it. The invalid argument is a -1 for the time out.
>
> I assume that a -1 to poll is valid parameter and it just works.
>
> Michael
> On Mon, Dec 22, 2008 at 5:26 PM, Xiaobin Lu <Xiaobin.Lu at sun.com
> <mailto:Xiaobin.Lu at sun.com>> wrote:
>
> 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>
> <mailto: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>
> <mailto:glewis at eyesbeyond.com <mailto:glewis at eyesbeyond.com>>
>
> Eyes Beyond Web :
> http://www.eyesbeyond.com
> Information Technology FreeBSD :
> glewis at FreeBSD.org
>
> Michael
> ------------------------------------------------------------------------
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20081223/e6bc3db6/attachment.html
More information about the bsd-port-dev
mailing list