You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2005/04/18 14:31:13 UTC

cvs commit: jakarta-tomcat-connectors/jni/native/src network.c pool.c

mturk       2005/04/18 05:31:13

  Modified:    jni/native/src network.c pool.c
  Log:
  Added ASSERT macro for DEBUG build to track the invalid params.
  
  Revision  Changes    Path
  1.12      +28 -1     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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- network.c	16 Apr 2005 16:45:13 -0000	1.11
  +++ network.c	18 Apr 2005 12:31:13 -0000	1.12
  @@ -112,6 +112,7 @@
       apr_int32_t f, t;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(pool != 0);
       GET_S_FAMILY(f, family);
       GET_S_TYPE(t, type);
   
  @@ -129,6 +130,7 @@
       apr_socket_t *s = J2P(sock, apr_socket_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_shutdown(s, (apr_shutdown_how_e)how);
   }
   
  @@ -137,6 +139,7 @@
       apr_socket_t *s = J2P(sock, apr_socket_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_close(s);
   }
   
  @@ -147,6 +150,7 @@
       apr_sockaddr_t *a = J2P(sa, apr_sockaddr_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_bind(s, a);
   }
   
  @@ -156,6 +160,7 @@
       apr_socket_t *s = J2P(sock, apr_socket_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_listen(s, backlog);
   }
   
  @@ -167,6 +172,7 @@
       apr_socket_t *n = NULL;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
   
       TCN_THROW_IF_ERR(apr_socket_accept(&n, s, p), s);
   
  @@ -181,6 +187,7 @@
       apr_sockaddr_t *a = J2P(sa, apr_sockaddr_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_connect(s, a);
   }
   
  @@ -194,6 +201,7 @@
       apr_status_t ss;
   
       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);
  @@ -222,6 +230,8 @@
       apr_status_t ss;
   
       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)
  @@ -248,6 +258,7 @@
       apr_status_t ss;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
   
       if (nvec >= APR_MAX_IOVEC_SIZE)
           return (jint)(-APR_ENOMEM);
  @@ -280,6 +291,7 @@
       apr_status_t ss;
   
       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);
  @@ -308,6 +320,7 @@
       apr_status_t ss;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
       if (toread > 0)
           nbytes = min(nbytes - offset, (apr_size_t)toread);
   
  @@ -332,6 +345,8 @@
       apr_interval_time_t t;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
  +    TCN_ASSERT(buf != NULL);
   
       if (toread > 0)
           nbytes = min(nbytes - offset, (apr_size_t)toread);
  @@ -360,6 +375,8 @@
       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)
  @@ -386,6 +403,8 @@
       apr_interval_time_t t;
   
       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)
  @@ -418,6 +437,8 @@
       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);
   
  @@ -437,6 +458,7 @@
       apr_socket_t *s = J2P(sock, apr_socket_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_opt_set(s, (apr_int32_t)opt, (apr_int32_t)on);
   }
   
  @@ -447,6 +469,7 @@
       apr_int32_t on;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
       TCN_THROW_IF_ERR(apr_socket_opt_get(s, (apr_int32_t)opt,
                                           &on), on);
   cleanup:
  @@ -459,6 +482,7 @@
       apr_socket_t *s = J2P(sock, apr_socket_t *);
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       return (jint)apr_socket_timeout_set(s, J2T(timeout));
   }
   
  @@ -468,6 +492,7 @@
       apr_interval_time_t timeout;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
       TCN_THROW_IF_ERR(apr_socket_timeout_get(s, &timeout), timeout);
   
   cleanup:
  @@ -480,6 +505,7 @@
       apr_int32_t mark;
   
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(sock != 0);
       if (apr_socket_atmark(s, &mark) != APR_SUCCESS)
           return JNI_FALSE;
       return mark ? JNI_TRUE : JNI_FALSE;
  @@ -508,6 +534,8 @@
       apr_status_t ss;
   
       UNREFERENCED(o);
  +    TCN_ASSERT(sock != 0);
  +    TCN_ASSERT(file != 0);
   
       if (headers)
           nh = (*e)->GetArrayLength(e, headers);
  @@ -549,4 +577,3 @@
       else
           return -(jint)ss;
   }
  -
  
  
  
  1.3       +33 -30    jakarta-tomcat-connectors/jni/native/src/pool.c
  
  Index: pool.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/pool.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- pool.c	3 Feb 2005 07:48:20 -0000	1.2
  +++ pool.c	18 Apr 2005 12:31:13 -0000	1.3
  @@ -48,6 +48,7 @@
   {
       apr_pool_t *p = J2P(pool, apr_pool_t *);
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(pool != 0);
       apr_pool_clear(p);
   }
   
  @@ -55,6 +56,7 @@
   {
       apr_pool_t *p = J2P(pool, apr_pool_t *);
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(pool != 0);
       apr_pool_destroy(p);
   }
   
  @@ -62,6 +64,7 @@
   {
       apr_pool_t *p = J2P(pool, apr_pool_t *);
       UNREFERENCED_STDARGS;
  +    TCN_ASSERT(pool != 0);
       return P2J(apr_pool_parent_get(p));
   }
   
  @@ -123,33 +126,33 @@
       (*e)->DeleteGlobalRef(e, cb->obj);
       free(cb);
   }
  -
  -TCN_IMPLEMENT_CALL(jobject, Pool, alloc)(TCN_STDARGS, jlong pool,
  -                                         jint size)
  -{
  -    apr_pool_t *p = J2P(pool, apr_pool_t *);
  -    apr_size_t sz = (apr_size_t)size;
  -    void *mem;
  -
  -    UNREFERENCED(o);
  -    
  -    if ((mem = apr_palloc(p, sz)) != NULL)
  -        return (*e)->NewDirectByteBuffer(e, mem, (jlong)sz);
  -    else
  -        return NULL;
  -}
  -
  -TCN_IMPLEMENT_CALL(jobject, Pool, calloc)(TCN_STDARGS, jlong pool,
  -                                          jint size)
  -{
  -    apr_pool_t *p = J2P(pool, apr_pool_t *);
  -    apr_size_t sz = (apr_size_t)size;
  -    void *mem;
  -
  -    UNREFERENCED(o);
  -    
  -    if ((mem = apr_pcalloc(p, sz)) != NULL)
  -        return (*e)->NewDirectByteBuffer(e, mem, (jlong)sz);
  -    else
  -        return NULL;
  -}
  +
  +TCN_IMPLEMENT_CALL(jobject, Pool, alloc)(TCN_STDARGS, jlong pool,
  +                                         jint size)
  +{
  +    apr_pool_t *p = J2P(pool, apr_pool_t *);
  +    apr_size_t sz = (apr_size_t)size;
  +    void *mem;
  +
  +    UNREFERENCED(o);
  +
  +    if ((mem = apr_palloc(p, sz)) != NULL)
  +        return (*e)->NewDirectByteBuffer(e, mem, (jlong)sz);
  +    else
  +        return NULL;
  +}
  +
  +TCN_IMPLEMENT_CALL(jobject, Pool, calloc)(TCN_STDARGS, jlong pool,
  +                                          jint size)
  +{
  +    apr_pool_t *p = J2P(pool, apr_pool_t *);
  +    apr_size_t sz = (apr_size_t)size;
  +    void *mem;
  +
  +    UNREFERENCED(o);
  +
  +    if ((mem = apr_pcalloc(p, sz)) != NULL)
  +        return (*e)->NewDirectByteBuffer(e, mem, (jlong)sz);
  +    else
  +        return NULL;
  +}
  
  
  

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