tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r416780 - in /tomcat/connectors/trunk/jni: java/org/apache/tomcat/jni/Socket.java native/src/network.c
Date Fri, 23 Jun 2006 17:58:43 GMT
Author: mturk
Date: Fri Jun 23 10:58:41 2006
New Revision: 416780

URL: http://svn.apache.org/viewvc?rev=416780&view=rev
Log:
Add APR functions for set/get of user data
associated with the socket. They can be used to
attach the enclosing Java objects with the socket.

Modified:
    tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java
    tomcat/connectors/trunk/jni/native/src/network.c

Modified: tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java?rev=416780&r1=416779&r2=416780&view=diff
==============================================================================
--- tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java (original)
+++ tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java Fri Jun 23 10:58:41
2006
@@ -525,4 +525,22 @@
      * @param buf The ByteBuffer
      */
     public static native void setrbb(long sock, ByteBuffer buf);
+
+    /**
+     * Set the data associated with the current socket.
+     * @param sock The currently open socket.
+     * @param data The user data to associate with the socket.
+     * @param key The key to associate with the data.
+     * @param cleanup The cleanup to call when the socket is destroyed.
+     */
+      public static native int dataSet(long sock, String key, Object data);
+
+    /**
+     * Return the data associated with the current socket
+     * @param data The user data associated with the socket.
+     * @param key The key to associate with the user data.
+     * @param sock The currently open socket.
+     * @return Data or null in case of error.
+     */
+     public static native Object dataGet(long sock, String key);
 }

Modified: tomcat/connectors/trunk/jni/native/src/network.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/src/network.c?rev=416780&r1=416779&r2=416780&view=diff
==============================================================================
--- tomcat/connectors/trunk/jni/native/src/network.c (original)
+++ tomcat/connectors/trunk/jni/native/src/network.c Fri Jun 23 10:58:41 2006
@@ -953,7 +953,6 @@
     tcn_socket_t *s = J2P(sock, tcn_socket_t *);
     apr_status_t ss;
     apr_size_t nbytes = (apr_size_t)len;
-    apr_interval_time_t t;
 
     UNREFERENCED_STDARGS;
     TCN_ASSERT(sock != 0);
@@ -1276,6 +1275,40 @@
     UNREFERENCED(args);
     return (jint)APR_ENOTIMPL;
 #endif
+}
+
+
+TCN_IMPLEMENT_CALL(jint, Socket, dataSet)(TCN_STDARGS, jlong sock,
+                                          jstring key, jobject data)
+{
+    tcn_socket_t *s = J2P(sock, tcn_socket_t *);
+    apr_status_t rv = APR_SUCCESS;
+    void *old = NULL;
+    TCN_ALLOC_CSTRING(key);
+
+    UNREFERENCED(o);
+    TCN_ASSERT(sock != 0);
+
+    rv = apr_socket_data_set(s->sock, data, J2S(key), NULL);
+    TCN_FREE_CSTRING(key);
+    return rv;
+}
+
+TCN_IMPLEMENT_CALL(jobject, Socket, dataGet)(TCN_STDARGS, jlong socket,
+                                             jstring key)
+{
+    tcn_socket_t *s = J2P(socket, tcn_socket_t *);
+    TCN_ALLOC_CSTRING(key);
+    jobject rv = NULL;
+
+    UNREFERENCED(o);
+    TCN_ASSERT(sock != 0);
+
+    if (apr_socket_data_get(&rv, J2S(key), s->sock) != APR_SUCCESS) {
+        rv = NULL;
+    }
+    TCN_FREE_CSTRING(key);
+    return rv;
 }
 
 TCN_IMPLEMENT_CALL(jint, Mulicast, join)(TCN_STDARGS,



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message