Author: mturk
Date: Fri Aug 3 07:33:51 2007
New Revision: 562478
URL: http://svn.apache.org/viewvc?view=rev&rev=562478
Log:
Add two new 'immediate' methods for sending the data.
It is the responsibility of the Java callee to deal with
the returned values and retry if the error was non-fatal.
Modified:
tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java
tomcat/connectors/trunk/jni/native/include/tcn_version.h
tomcat/connectors/trunk/jni/native/os/win32/libtcnative.rc
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?view=diff&rev=562478&r1=562477&r2=562478
==============================================================================
--- tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java
(original)
+++ tomcat/connectors/trunk/jni/java/org/apache/tomcat/jni/Socket.java Fri Aug
3 07:33:51 2007
@@ -241,11 +241,42 @@
*/
public static native int sendb(long sock, ByteBuffer buf,
int offset, int len);
+
+ /**
+ * Send data over a network without retry
+ * <PRE>
+ * This functions acts like a blocking write by default. To change
+ * this behavior, use apr_socket_timeout_set() or the APR_SO_NONBLOCK
+ * socket option.
+ *
+ * It is possible for both bytes to be sent and an error to be returned.
+ *
+ * </PRE>
+ * @param sock The socket to send the data over.
+ * @param buf The Byte buffer which contains the data to be sent.
+ * @param offset The offset within the buffer array of the first buffer
from
+ * which bytes are to be retrieved; must be non-negative
+ * and no larger than buf.length
+ * @param len The maximum number of buffers to be accessed; must be
non-negative
+ * and no larger than buf.length - offset
+ * @return The number of bytes send.
+ *
+ */
+ public static native int sendib(long sock, ByteBuffer buf,
+ int offset, int len);
+
/**
* Send data over a network using internally set ByteBuffer
*/
public static native int sendbb(long sock,
int offset, int len);
+
+ /**
+ * Send data over a network using internally set ByteBuffer
+ * without internal retry.
+ */
+ public static native int sendibb(long sock,
+ int offset, int len);
/**
* Send multiple packets of data over a network.
Modified: tomcat/connectors/trunk/jni/native/include/tcn_version.h
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/include/tcn_version.h?view=diff&rev=562478&r1=562477&r2=562478
==============================================================================
--- tomcat/connectors/trunk/jni/native/include/tcn_version.h (original)
+++ tomcat/connectors/trunk/jni/native/include/tcn_version.h Fri Aug 3
07:33:51 2007
@@ -69,7 +69,7 @@
#define TCN_MINOR_VERSION 1
/** patch level */
-#define TCN_PATCH_VERSION 11
+#define TCN_PATCH_VERSION 12
/**
* This symbol is defined for internal, "development" copies of TCN. This
Modified: tomcat/connectors/trunk/jni/native/os/win32/libtcnative.rc
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/os/win32/libtcnative.rc?view=diff&rev=562478&r1=562477&r2=562478
==============================================================================
--- tomcat/connectors/trunk/jni/native/os/win32/libtcnative.rc (original)
+++ tomcat/connectors/trunk/jni/native/os/win32/libtcnative.rc Fri Aug 3
07:33:51 2007
@@ -3,7 +3,7 @@
LANGUAGE 0x9,0x1
1 11 logmessages.bin
-#define TCN_COPYRIGHT "Copyright 2000-2006 The Apache Software " \
+#define TCN_COPYRIGHT "Copyright 2000-2007 The Apache Software " \
"Foundation or its licensors, as applicable."
#define TCN_LICENSE "Licensed under the Apache License, Version 2.0 " \
@@ -19,7 +19,7 @@
"specific language governing permissions and " \
"limitations under the License."
-#define TCN_VERISON "1.1.11"
+#define TCN_VERISON "1.1.12"
1000 ICON "apache.ico"
1001 DIALOGEX 0, 0, 252, 51
@@ -35,8 +35,8 @@
END
1 VERSIONINFO
- FILEVERSION 1,1,11,0
- PRODUCTVERSION 1,1,11,0
+ FILEVERSION 1,1,12,0
+ PRODUCTVERSION 1,1,12,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Modified: tomcat/connectors/trunk/jni/native/src/network.c
URL:
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/src/network.c?view=diff&rev=562478&r1=562477&r2=562478
==============================================================================
--- tomcat/connectors/trunk/jni/native/src/network.c (original)
+++ tomcat/connectors/trunk/jni/native/src/network.c Fri Aug 3 07:33:51 2007
@@ -540,6 +540,40 @@
}
}
+TCN_IMPLEMENT_CALL(jint, Socket, sendib)(TCN_STDARGS, jlong sock,
+ jobject buf, jint offset, jint len)
+{
+ tcn_socket_t *s = J2P(sock, tcn_socket_t *);
+ apr_size_t nbytes = (apr_size_t)len;
+ char *bytes;
+ apr_status_t ss = APR_SUCCESS;
+
+ UNREFERENCED(o);
+ if (!sock) {
+ tcn_ThrowAPRException(e, APR_ENOTSOCK);
+ return -(jint)APR_ENOTSOCK;
+ }
+ TCN_ASSERT(s->opaque != NULL);
+ TCN_ASSERT(buf != NULL);
+#ifdef TCN_DO_STATISTICS
+ sp_max_send = TCN_MAX(sp_max_send, nbytes);
+ sp_min_send = TCN_MIN(sp_min_send, nbytes);
+ sp_tot_send += nbytes;
+ sp_num_send++;
+#endif
+
+ bytes = (char *)(*e)->GetDirectBufferAddress(e, buf);
+
+ ss = (*s->net->send)(s->opaque, bytes + offset, &nbytes);
+
+ if (ss == APR_SUCCESS)
+ return (jint)nbytes;
+ else {
+ TCN_ERROR_WRAP(ss);
+ return -(jint)ss;
+ }
+}
+
TCN_IMPLEMENT_CALL(jint, Socket, sendbb)(TCN_STDARGS, jlong sock,
jint offset, jint len)
{
@@ -574,6 +608,37 @@
else {
TCN_ERROR_WRAP(ss);
return -(jint)ss;
+ }
+}
+
+TCN_IMPLEMENT_CALL(jint, Socket, sendibb)(TCN_STDARGS, jlong sock,
+ jint offset, jint len)
+{
+ tcn_socket_t *s = J2P(sock, tcn_socket_t *);
+ apr_size_t nbytes = (apr_size_t)len;
+ apr_status_t ss = APR_SUCCESS;
+
+ UNREFERENCED(o);
+ if (!sock) {
+ tcn_ThrowAPRException(e, APR_ENOTSOCK);
+ return -(jint)APR_ENOTSOCK;
+ }
+ TCN_ASSERT(s->opaque != NULL);
+ TCN_ASSERT(s->jsbbuff != NULL);
+#ifdef TCN_DO_STATISTICS
+ sp_max_send = TCN_MAX(sp_max_send, nbytes);
+ sp_min_send = TCN_MIN(sp_min_send, nbytes);
+ sp_tot_send += nbytes;
+ sp_num_send++;
+#endif
+
+ ss = (*s->net->send)(s->opaque, s->jsbbuff + offset, &nbytes);
+
+ if (ss == APR_SUCCESS)
+ return (jint)nbytes;
+ else {
+ TCN_ERROR_WRAP(ss);
+ return -(jint)nbytes;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]