You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/05/02 15:26:59 UTC
svn commit: r1098557 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/net/DatagramSocketInstance.java
native/shared/dsock.c
Author: mturk
Date: Mon May 2 13:26:59 2011
New Revision: 1098557
URL: http://svn.apache.org/viewvc?rev=1098557&view=rev
Log:
Add native datagram socket descriptor setter
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/DatagramSocketInstance.java
commons/sandbox/runtime/trunk/src/main/native/shared/dsock.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/DatagramSocketInstance.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/DatagramSocketInstance.java?rev=1098557&r1=1098556&r2=1098557&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/DatagramSocketInstance.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/DatagramSocketInstance.java Mon May 2 13:26:59 2011
@@ -39,6 +39,7 @@ public final class DatagramSocketInstanc
private static native FileDescriptor fd0(DatagramSocket s);
private static native int nd0(DatagramSocket s);
+ private static native int sd0(DatagramSocket s, int d);
private static native int nb0(DatagramSocket s, boolean on);
public static FileDescriptor getFileDescriptor(DatagramSocket s)
@@ -57,6 +58,16 @@ public final class DatagramSocketInstanc
return nd0(s);
}
+ public static void setNativeDescriptor(DatagramSocket s, int desc)
+ throws IllegalArgumentException, IOException
+ {
+ if (s == null)
+ throw new IllegalArgumentException();
+ int rc = sd0(s, desc);
+ if (rc != 0)
+ throw new IOException(Status.describe(rc));
+ }
+
public static void configureBlocking(DatagramSocket s, boolean on)
throws IllegalArgumentException, IOException
{
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/dsock.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/dsock.c?rev=1098557&r1=1098556&r2=1098557&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/dsock.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/dsock.c Mon May 2 13:26:59 2011
@@ -102,6 +102,27 @@ ACR_NET_EXPORT(jint, DatagramSocketInsta
return -1;
}
+ACR_NET_EXPORT(jint, DatagramSocketInstance, sd0)(JNI_STDARGS, jobject sock, jint sd)
+{
+ jobject impl = 0;
+ jobject fd;
+
+ if (J4FLD_OFF(0000) != INVALID_FIELD_OFFSET) {
+ char *oa = *(char **)sock;
+ if (oa != 0)
+ impl = (jobject)(oa + J4FLD_PTR(0000));
+ }
+ else if (CLAZZ_LOADED) {
+ impl = GET_IFIELD_O(0000, sock);
+ }
+ if (impl != 0) {
+ fd = AcrGetDatagramSocketImplFd(env, impl);
+ if (fd != 0)
+ return AcrSetFileDescriptorFd(env, fd, sd);
+ }
+ return ACR_EBADF;
+}
+
ACR_NET_EXPORT(jint, DatagramSocketInstance, nb0)(JNI_STDARGS, jobject sock, jboolean on)
{
jobject impl = 0;