mturk       2005/05/16 03:46:59

  Modified:    jni/native/src network.c
  Log:
  Remove all calls to functions that was used for checking of
  input param validity. If needed it is much cheaper to do that in Java
  side, and ensure the calling params are correct.
  
  Revision  Changes    Path
  1.16      +14 -36    jakarta-tomcat-connectors/jni/native/src/network.c
  
  Index: network.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/network.c,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- network.c 23 Apr 2005 18:33:39 -0000      1.15
  +++ network.c 16 May 2005 10:46:59 -0000      1.16
  @@ -195,7 +195,7 @@
                                         jbyteArray buf, jint offset, jint 
tosend)
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
  -    apr_size_t nbytes = (*e)->GetArrayLength(e, buf);
  +    apr_size_t nbytes = (apr_size_t)tosend;
       jbyte *bytes;
       apr_int32_t nb;
       apr_status_t ss;
  @@ -203,8 +203,6 @@
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
       apr_socket_opt_get(s, APR_SO_NONBLOCK, &nb);
  -    if (tosend > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)tosend);
       if (nb)
            bytes = (*e)->GetPrimitiveArrayCritical(e, buf, NULL);
       else
  @@ -225,7 +223,7 @@
                                           jobject buf, jint offset, jint len)
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
  -    apr_size_t nbytes;
  +    apr_size_t nbytes = (apr_size_t)len;
       char *bytes;
       apr_status_t ss;
   
  @@ -233,11 +231,6 @@
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(buf != NULL);
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
  -    nbytes = (apr_size_t)(*e)->GetDirectBufferCapacity(e, buf);
  -    if (bytes == NULL || nbytes < 0)
  -        return (jint)(-APR_EINVAL);
  -    if (len > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)len);
       ss = apr_socket_send(s, bytes + offset, &nbytes);
   
       if (ss == APR_SUCCESS)
  @@ -285,16 +278,16 @@
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
       apr_sockaddr_t *w = J2P(where, apr_sockaddr_t *);
  -    apr_size_t nbytes = (*e)->GetArrayLength(e, buf);
  +    apr_size_t nbytes = (apr_size_t)tosend;
       jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
       apr_int32_t nb;
       apr_status_t ss;
   
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
  +    TCN_ASSERT(bytes != NULL);
  +
       apr_socket_opt_get(s, APR_SO_NONBLOCK, &nb);
  -    if (tosend > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)tosend);
       if (nb)
            bytes = (*e)->GetPrimitiveArrayCritical(e, buf, NULL);
       else
  @@ -315,15 +308,13 @@
                                          jbyteArray buf, jint offset, jint 
toread)
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
  -    apr_size_t nbytes = (*e)->GetArrayLength(e, buf);
  +    apr_size_t nbytes = (apr_size_t)toread;
       jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
       apr_status_t ss;
   
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
  -    if (toread > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)toread);
  -
  +    TCN_ASSERT(bytes != NULL);
       ss = apr_socket_recv(s, bytes + offset, &nbytes);
   
       (*e)->ReleaseByteArrayElements(e, buf, bytes,
  @@ -339,7 +330,7 @@
                                           jint toread, jlong timeout)
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
  -    apr_size_t nbytes = (*e)->GetArrayLength(e, buf);
  +    apr_size_t nbytes = (apr_size_t)toread;
       jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
       apr_status_t ss;
       apr_interval_time_t t;
  @@ -347,9 +338,8 @@
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(buf != NULL);
  +    TCN_ASSERT(bytes != NULL);
   
  -    if (toread > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)toread);
       if ((ss = apr_socket_timeout_get(s, &t)) != APR_SUCCESS)
           goto cleanup;
       if ((ss = apr_socket_timeout_set(s, J2T(timeout))) != APR_SUCCESS)
  @@ -371,19 +361,14 @@
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
       apr_status_t ss;
  -    apr_size_t nbytes;
  +    apr_size_t nbytes = (apr_size_t)len;
       char *bytes;
   
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(buf != NULL);
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
  -    nbytes = (apr_size_t)(*e)->GetDirectBufferCapacity(e, buf);
  -    if (bytes == NULL || nbytes < 0)
  -        return (jint)(-APR_EINVAL);
  -    if (len > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)len);
  -
  +    TCN_ASSERT(bytes != NULL);
       ss = apr_socket_recv(s, bytes + offset, &nbytes);
   
       if (ss == APR_SUCCESS)
  @@ -398,7 +383,7 @@
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
       apr_status_t ss;
  -    apr_size_t nbytes;
  +    apr_size_t nbytes = (apr_size_t)len;
       char *bytes;
       apr_interval_time_t t;
   
  @@ -406,11 +391,7 @@
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(buf != NULL);
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
  -    nbytes = (apr_size_t)(*e)->GetDirectBufferCapacity(e, buf);
  -    if (bytes == NULL || nbytes < 0)
  -        return (jint)(-APR_EINVAL);
  -    if (len > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)len);
  +    TCN_ASSERT(bytes != NULL);
   
       if ((ss = apr_socket_timeout_get(s, &t)) != APR_SUCCESS)
            return -(jint)ss;
  @@ -432,16 +413,13 @@
   {
       apr_socket_t *s = J2P(sock, apr_socket_t *);
       apr_sockaddr_t *f = J2P(from, apr_sockaddr_t *);
  -    apr_size_t nbytes = (*e)->GetArrayLength(e, buf);
  +    apr_size_t nbytes = (apr_size_t)toread;
       jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
       apr_status_t ss;
   
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(buf != NULL);
  -    if (toread > 0)
  -        nbytes = min(nbytes - offset, (apr_size_t)toread);
  -
       ss = apr_socket_recvfrom(f, s, (apr_int32_t)flags, bytes + offset, 
&nbytes);
   
       (*e)->ReleaseByteArrayElements(e, buf, bytes,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to