Author: odeakin
Date: Thu Jun 17 14:29:37 2010
New Revision: 955614
URL: http://svn.apache.org/viewvc?rev=955614&view=rev
Log:
This function is expected to return the socket handle according to the javadoc for AddressUtil.getChannellAddress(),
but was just returning the descriptor field from FileDescriptor (which could/should have been
done in Java anyway).
Modified:
harmony/enhanced/java/trunk/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
Modified: harmony/enhanced/java/trunk/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c?rev=955614&r1=955613&r2=955614&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio/src/main/native/nio/shared/AddressUtil.c
Thu Jun 17 14:29:37 2010
@@ -27,17 +27,34 @@ JNIEXPORT jlong JNICALL Java_org_apache_
jclass descriptorCLS;
jfieldID descriptorFID;
hysocket_t hysocketP;
+
//TODO add to cache
descriptorCLS = (*env)->FindClass (env, "java/io/FileDescriptor");
if (NULL == descriptorCLS){
return 0;
}
+
descriptorFID = (*env)->GetFieldID (env, descriptorCLS, "descriptor", "J");
if (NULL == descriptorFID){
return 0;
}
+
hysocketP = (hysocket_t) ((IDATA)((*env)->GetLongField (env, fd, descriptorFID)));
- return SOCKET_CAST(hysocketP);
+ if (NULL == hysocketP) {
+ return 0;
+ }
+
+#if defined(WIN32) || defined(WIN64)
+ if (hysocketP->flags & SOCKET_IPV4_OPEN_MASK) {
+ return (jlong)(hysocketP->ipv4);
+ } else if (hysocketP->flags & SOCKET_IPV6_OPEN_MASK) {
+ return (jlong)(hysocketP->ipv6);
+ } else {
+ return 0;
+ }
+#else
+ return (jlong)(hysocketP->sock);
+#endif
}
|