Review Request (M) - 7157695 - Add windows implementation of socket interface

David Holmes david.holmes at oracle.com
Tue Apr 17 05:23:13 PDT 2012


On 17/04/2012 8:43 PM, Nils Eliasson wrote:
> u_long* and int (for size_t) are the types used by the windows API. So
> they have kept the posix function names but have slightly different types.
>
> So the stack is:
>
> winsock.h ::ioctlsocket(int s, ..., u_long *pbytes)
> os.cpp: os::socket_available(int fd, jint *pbytes)
> prims.cpp: JVM_SocketAvailable(jint fd, jint *pbytes)
>
> So the JNI layer always uses signed value, the os-interface and the
> posix OSes uses some unsigneds, and windows uses some of both. So
> regardless of what we do - there will be casts.

My main concern was 32-bit vs 64-bit but it seems the JVM only provides 
a 32-bit interface to sockets.

Thanks,
David

> //N
>
> David Holmes skrev 2012-04-17 04:57:
>> Hi Nils,
>>
>> I'm very suspicious of the cast from jint* to u_long*, and also from
>> size_t to int. In both cases we would seem to have potential problems
>> on 64-bit systems.
>>
>> What are the actual types expected by the underlying system calls?
>>
>> David
>> -----
>>
>> On 13/04/2012 6:21 PM, Nils Eliasson wrote:
>>> Can only find julong. u_long is defined in winsock.h that this is a
>>> call to.
>>>
>>> Changed the pointer cast to a correct construct.
>>>
>>> http://cr.openjdk.java.net/~neliasso/7157695/webrev.04/
>>> <http://cr.openjdk.java.net/%7Eneliasso/7157695/webrev.04/>
>>>
>>> Otherwise the same.
>>>
>>> Thanks,
>>> //Nils
>>>
>>>
>>> Vladimir Kozlov skrev 2012-04-10 17:08:
>>>> + int ret = ::ioctlsocket(fd, FIONREAD, (u_long*)pbytes);
>>>>
>>>> What type is u_long? VM has defined type 'ulong' not 'u_long'.
>>>>
>>>> Otherwise looks good.
>>>>
>>>> Vladimir
>>>>
>>>> On 4/10/12 6:45 AM, Nils Eliasson wrote:
>>>>> Any comments on the latest rev?
>>>>>
>>>>> //Nils
>>>>>
>>>>> Nils Eliasson skrev 2012-03-30 10:40:
>>>>>> ok,
>>>>>>
>>>>>> New webrev here:
>>>>>> http://cr.openjdk.java.net/~neliasso/7157695/webrev.03/
>>>>>> <http://cr.openjdk.java.net/%7Eneliasso/7157695/webrev.03/>
>>>>>>
>>>>>> Defining socklen_t as int on windows makes a much better impl.
>>>>>>
>>>>>> Remains some casts from size_t to int on windows. So we have jni
>>>>>> call in jvm.h with jint/int -> os.hpp with size_t ->
>>>>>> os_windows.hpp with int. But we don't expect any negative lenghts so
>>>>>> it should work.
>>>>>>
>>>>>> Thanks for the feedback,
>>>>>> Nils E
>>>>>>
>>>>>> David Holmes skrev 2012-03-29 23:20:
>>>>>>> On 30/03/2012 4:36 AM, Dean Long wrote:
>>>>>>>> Isn't this webrev reversing the recent changes for 7091417?
>>>>>>>
>>>>>>> Yes - and it shouldn't be. size_t's and socklen_t's are the correct
>>>>>>> types to use.
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>> dl
>>>>>>>>
>>>>>>>> On 3/29/2012 10:42 AM, Christian Thalinger wrote:
>>>>>>>>> I'm pretty sure this gets us into trouble with some compiler
>>>>>>>>> somewhere
>>>>>>>>> (I'd guess GCC on Linux). On Mac OS X send is declared as:
>>>>>>>>>
>>>>>>>>> ssize_t
>>>>>>>>> send(int socket, const void *buffer, size_t length, int flags);
>>>>>>>>>
>>>>>>>>> but length is now passed as int:
>>>>>>>>>
>>>>>>>>> -inline int os::send(int fd, char* buf, size_t nBytes, uint
>>>>>>>>> flags) {
>>>>>>>>> +inline int os::send(int fd, char* buf, int nBytes, int flags) {
>>>>>>>>> RESTARTABLE_RETURN_INT(::send(fd, buf, nBytes, flags));
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> I think your changes are good but we might need some casts down
>>>>>>>>> in the
>>>>>>>>> OS files eventually.
>>>>>>>>>
>>>>>>>>> -- Chris
>>>>>>>>>
>>>>>>>>> On Mar 29, 2012, at 3:00 PM, Nils Eliasson wrote:
>>>>>>>>>
>>>>>>>>>> http://cr.openjdk.java.net/~neliasso/7157695/webrev.01/<http://cr.openjdk.java.net/%7Eneliasso/7157695/webrev.01/>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> 7157695 - Add windows implementation of socket interface
>>>>>>>>>>
>>>>>>>>>> Using winsock api which is almost posix compatible. Also changing
>>>>>>>>>> some argument types for the socket interface calls in os.hpp to
>>>>>>>>>> make
>>>>>>>>>> the platform independent code more platform independent. This
>>>>>>>>>> made
>>>>>>>>>> the win implementation possible without casts, and allowed me to
>>>>>>>>>> remove a lot of redundant casts from the jni exports in jvm.cpp.
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Oracle <http://www.oracle.com>
>>>>> Nils Eliasson | Senior Member of Technical Staff
>>>>> Oracle Java Platform Group, JVM Engineering
>>>>> ORACLE Sweden
>>>>>
>>>
>>>
>>> --
>>> Oracle <http://www.oracle.com>
>>> Nils Eliasson | Senior Member of Technical Staff
>>> Oracle Java Platform Group, JVM Engineering
>>> ORACLE Sweden
>>>
>
>
> --
> Oracle <http://www.oracle.com>
> Nils Eliasson | Senior Member of Technical Staff
> Oracle Java Platform Group, JVM Engineering
> ORACLE Sweden
>


More information about the hotspot-dev mailing list