tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/jni/native/src network.c sslnetwork.c
Date Sat, 02 Jul 2005 07:19:11 GMT
mturk       2005/07/02 00:19:11

  Modified:    jni/native/include tcn.h
               jni/native/os/unix uxpipe.c
               jni/native/os/win32 ntpipe.c
               jni/native/src network.c sslnetwork.c
  Log:
  Used abstract structure for setting the network layer instead directly
  setting the functions. There is no function change, just the code is
  easier to read and maintain.
  
  Revision  Changes    Path
  1.29      +14 -11    jakarta-tomcat-connectors/jni/native/include/tcn.h
  
  Index: tcn.h
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/include/tcn.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- tcn.h	30 Jun 2005 08:20:56 -0000	1.28
  +++ tcn.h	2 Jul 2005 07:19:10 -0000	1.29
  @@ -120,21 +120,24 @@
   #define TCN_SOCKET_GET_TYPE 3
   
   typedef struct {
  -    apr_pool_t   *pool;
  -    apr_socket_t *sock;
  -    void         *opaque;
  -    int          type;
  +    int type;
       apr_status_t (*cleanup)(void *);
  -    apr_status_t (APR_THREAD_FUNC *tmset)(apr_socket_t *, apr_interval_time_t);
  -    apr_status_t (APR_THREAD_FUNC *tmget)(apr_socket_t *, apr_interval_time_t *);
  -    apr_status_t (APR_THREAD_FUNC *set)(apr_socket_t *, apr_int32_t, apr_int32_t);
  -    apr_status_t (APR_THREAD_FUNC *get)(apr_socket_t *, apr_int32_t, apr_int32_t *);
  +    apr_status_t (APR_THREAD_FUNC *close) (apr_socket_t *);
  +    apr_status_t (APR_THREAD_FUNC *shutdown) (apr_socket_t *, apr_shutdown_how_e);
  +    apr_status_t (APR_THREAD_FUNC *opt_get)(apr_socket_t *, apr_int32_t, apr_int32_t *);
  +    apr_status_t (APR_THREAD_FUNC *opt_set)(apr_socket_t *, apr_int32_t, apr_int32_t);
  +    apr_status_t (APR_THREAD_FUNC *timeout_get)(apr_socket_t *, apr_interval_time_t *);
  +    apr_status_t (APR_THREAD_FUNC *timeout_set)(apr_socket_t *, apr_interval_time_t);
       apr_status_t (APR_THREAD_FUNC *send) (apr_socket_t *, const char *, apr_size_t *);
       apr_status_t (APR_THREAD_FUNC *sendv)(apr_socket_t *, const struct iovec *, apr_int32_t,
apr_size_t *);
       apr_status_t (APR_THREAD_FUNC *recv) (apr_socket_t *, char *, apr_size_t *);
  -    apr_status_t (APR_THREAD_FUNC *close) (apr_socket_t *);
  -    apr_status_t (APR_THREAD_FUNC *shutdown) (apr_socket_t *, apr_shutdown_how_e);
  +} tcn_nlayer_t;
   
  +typedef struct {
  +    apr_pool_t   *pool;
  +    apr_socket_t *sock;
  +    void         *opaque;
  +    tcn_nlayer_t *net;
   } tcn_socket_t;
   
   /* Private helper functions */
  
  
  
  1.3       +21 -25    jakarta-tomcat-connectors/jni/native/os/unix/uxpipe.c
  
  Index: uxpipe.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/os/unix/uxpipe.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- uxpipe.c	30 Jun 2005 15:22:32 -0000	1.2
  +++ uxpipe.c	2 Jul 2005 07:19:10 -0000	1.3
  @@ -180,6 +180,20 @@
       return APR_SUCCESS;
   }
   
  +static tcn_nlayer_t uxp_socket_layer = {
  +    TCN_SOCKET_UNIX,
  +    uxp_cleanup,
  +    uxp_socket_close,
  +    uxp_socket_shutdown,
  +    uxp_socket_opt_get,
  +    uxp_socket_opt_set,
  +    uxp_socket_timeout_get,
  +    uxp_socket_timeout_set,
  +    uxp_socket_send,
  +    uxp_socket_sendv,
  +    uxp_socket_recv
  +};
  +
   TCN_IMPLEMENT_CALL(jlong, Local, create)(TCN_STDARGS, jstring name,
                                            jlong pool)
   {
  @@ -212,17 +226,9 @@
       else
           strcpy(con->uxaddr.sun_path, DEFNAME);
       s = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -    s->pool     = p;
  -    s->type     = TCN_SOCKET_UNIX;
  -    s->cleanup  = uxp_cleanup;
  -    s->recv     = uxp_socket_recv;
  -    s->send     = uxp_socket_send;
  -    s->sendv    = uxp_socket_sendv;
  -    s->shutdown = uxp_socket_shutdown;
  -    s->tmget    = uxp_socket_timeout_get;
  -    s->tmset    = uxp_socket_timeout_set;
  -    s->close    = uxp_socket_close;
  -    s->opaque   = con;
  +    s->pool   = p;
  +    s->net    = &uxp_socket_layer;
  +    s->opaque = con;
       apr_pool_cleanup_register(p, (const void *)s,
                                 uxp_socket_cleanup,
                                 apr_pool_cleanup_null);
  @@ -305,19 +311,9 @@
           apr_atomic_inc32(&uxp_accepted);
   #endif
           a = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -        a->pool = p;
  -        a->type     = TCN_SOCKET_UNIX;
  -        a->cleanup  = uxp_cleanup;
  -        a->recv     = uxp_socket_recv;
  -        a->send     = uxp_socket_send;
  -        a->sendv    = uxp_socket_sendv;
  -        a->shutdown = uxp_socket_shutdown;
  -        a->tmget    = uxp_socket_timeout_get;
  -        a->tmset    = uxp_socket_timeout_set;
  -        a->get      = uxp_socket_opt_get;
  -        a->set      = uxp_socket_opt_set;
  -        a->close    = uxp_socket_close;
  -        a->opaque   = con;
  +        a->pool   = p;
  +	    a->net    = &uxp_socket_layer;
  +        a->opaque = con;
           apr_pool_cleanup_register(p, (const void *)a,
                                     uxp_socket_cleanup,
                                     apr_pool_cleanup_null);
  
  
  
  1.3       +28 -34    jakarta-tomcat-connectors/jni/native/os/win32/ntpipe.c
  
  Index: ntpipe.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/os/win32/ntpipe.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ntpipe.c	30 Jun 2005 08:20:56 -0000	1.2
  +++ ntpipe.c	2 Jul 2005 07:19:10 -0000	1.3
  @@ -265,9 +265,9 @@
   {
       tcn_socket_t *s = (tcn_socket_t *)data;
   
  -    if (s->cleanup) {
  -        (*s->cleanup)(s->opaque);
  -        s->cleanup = NULL;
  +    if (s->net->cleanup) {
  +        (*s->net->cleanup)(s->opaque);
  +        s->net->cleanup = NULL;
       }
   #ifdef TCN_DO_STATISTICS
       apr_atomic_inc32(&ntp_cleared);
  @@ -275,6 +275,20 @@
       return APR_SUCCESS;
   }
   
  +static tcn_nlayer_t ntp_socket_layer = {
  +    TCN_SOCKET_NTPIPE,
  +    ntp_cleanup,
  +    ntp_socket_close,
  +    ntp_socket_shutdown,
  +    ntp_socket_opt_get,
  +    ntp_socket_opt_set,
  +    ntp_socket_timeout_get,
  +    ntp_socket_timeout_set,
  +    ntp_socket_send,
  +    ntp_socket_sendv,
  +    ntp_socket_recv
  +};
  +
   static BOOL create_DACL(LPSECURITY_ATTRIBUTES psa)
   {
   
  @@ -321,19 +335,9 @@
       }
   
       s = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -    s->pool     = p;
  -    s->type     = TCN_SOCKET_NTPIPE;
  -    s->cleanup  = ntp_cleanup;
  -    s->recv     = ntp_socket_recv;
  -    s->send     = ntp_socket_send;
  -    s->sendv    = ntp_socket_sendv;
  -    s->shutdown = ntp_socket_shutdown;
  -    s->tmget    = ntp_socket_timeout_get;
  -    s->tmset    = ntp_socket_timeout_set;
  -    s->get      = ntp_socket_opt_get;
  -    s->set      = ntp_socket_opt_set;
  -    s->close    = ntp_socket_close;
  -    s->opaque   = con;
  +    s->pool   = p;
  +    s->net    = &ntp_socket_layer;
  +    s->opaque = con;
       apr_pool_cleanup_register(p, (const void *)s,
                                 ntp_socket_cleanup,
                                 apr_pool_cleanup_null);
  @@ -350,7 +354,7 @@
       UNREFERENCED_STDARGS;
       UNREFERENCED(sa);
       TCN_ASSERT(sock != 0);
  -    if (s->type == TCN_SOCKET_NTPIPE) {
  +    if (s->net->type == TCN_SOCKET_NTPIPE) {
           tcn_ntp_conn_t *c = (tcn_ntp_conn_t *)s->opaque;
           c->mode = TCN_NTP_SERVER;
           return APR_SUCCESS;
  @@ -366,7 +370,7 @@
       UNREFERENCED_STDARGS;
   
       TCN_ASSERT(sock != 0);
  -    if (s->type == TCN_SOCKET_NTPIPE) {
  +    if (s->net->type == TCN_SOCKET_NTPIPE) {
           tcn_ntp_conn_t *c = (tcn_ntp_conn_t *)s->opaque;
           c->mode = TCN_NTP_SERVER;
           if (backlog > 0)
  @@ -390,7 +394,7 @@
       TCN_ASSERT(sock != 0);
   
       TCN_THROW_IF_ERR(apr_pool_create(&p, s->pool), p);
  -    if (s->type == TCN_SOCKET_NTPIPE) {
  +    if (s->net->type == TCN_SOCKET_NTPIPE) {
           tcn_ntp_conn_t *c = (tcn_ntp_conn_t *)s->opaque;
           con = (tcn_ntp_conn_t *)apr_pcalloc(p, sizeof(tcn_ntp_conn_t));
           con->pool = p;
  @@ -434,19 +438,9 @@
           apr_atomic_inc32(&ntp_accepted);
   #endif
           a = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -        a->pool = p;
  -        a->type     = TCN_SOCKET_NTPIPE;
  -        a->cleanup  = ntp_cleanup;
  -        a->recv     = ntp_socket_recv;
  -        a->send     = ntp_socket_send;
  -        a->sendv    = ntp_socket_sendv;
  -        a->shutdown = ntp_socket_shutdown;
  -        a->tmget    = ntp_socket_timeout_get;
  -        a->tmset    = ntp_socket_timeout_set;
  -        a->get      = ntp_socket_opt_get;
  -        a->set      = ntp_socket_opt_set;
  -        a->close    = ntp_socket_close;
  -        a->opaque   = con;
  +        a->pool   = p;
  +        a->net    = &ntp_socket_layer;
  +        a->opaque = con;
           apr_pool_cleanup_register(p, (const void *)a,
                                     ntp_socket_cleanup,
                                     apr_pool_cleanup_null);
  @@ -469,7 +463,7 @@
       UNREFERENCED(o);
       UNREFERENCED(sa);
       TCN_ASSERT(sock != 0);
  -    if (s->type != TCN_SOCKET_NTPIPE)
  +    if (s->net->type != TCN_SOCKET_NTPIPE)
           return APR_ENOTSOCK;
       con = (tcn_ntp_conn_t *)s->opaque;
       if (con->mode == TCN_NTP_SERVER)
  
  
  
  1.42      +74 -70    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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- network.c	30 Jun 2005 08:20:56 -0000	1.41
  +++ network.c	2 Jul 2005 07:19:10 -0000	1.42
  @@ -40,6 +40,11 @@
   static volatile apr_uint32_t sp_rst_recv = 0;
   static volatile apr_status_t sp_erl_recv = 0;
   
  +static volatile apr_size_t   sf_max_send = 0;
  +static volatile apr_size_t   sf_min_send = 10000000;
  +static volatile apr_uint32_t sf_num_send = 0;
  +static volatile apr_off_t    sf_tot_send = 0;
  +
   #endif
   
   #if  !APR_HAVE_IPV6
  @@ -78,6 +83,11 @@
       fprintf(stderr, "Receive errors          : %d\n", sp_err_recv);
       fprintf(stderr, "Receive resets          : %d\n", sp_rst_recv);
       fprintf(stderr, "Last receive error      : %d\n", sp_erl_recv);
  +
  +    fprintf(stderr, "Total sendfile calls    : %d\n", sf_num_send);
  +    fprintf(stderr, "Minimum sendfile lenght : %d\n", sf_min_send);
  +    fprintf(stderr, "Maximum sendfile lenght : %d\n", sf_max_send);
  +
   }
   
   #endif
  @@ -169,9 +179,9 @@
   {
       tcn_socket_t *s = (tcn_socket_t *)data;
   
  -    if (s->cleanup) {
  -        (*s->cleanup)(s->opaque);
  -        s->cleanup = NULL;
  +    if (s->net->cleanup) {
  +        (*s->net->cleanup)(s->opaque);
  +        s->net->cleanup = NULL;
       }
       if (s->sock) {
           apr_socket_close(s->sock);
  @@ -244,6 +254,20 @@
   #define APR_socket_opt_get      apr_socket_opt_get
   #endif
   
  +static tcn_nlayer_t apr_socket_layer = {
  +    TCN_SOCKET_APR,
  +    NULL,
  +    NULL,
  +    APR_socket_shutdown,
  +    APR_socket_opt_get,
  +    APR_socket_opt_set,
  +    APR_socket_timeout_get,
  +    APR_socket_timeout_set,
  +    APR_socket_send,
  +    APR_socket_sendv,
  +    APR_socket_recv
  +};
  +
   TCN_IMPLEMENT_CALL(jlong, Socket, create)(TCN_STDARGS, jint family,
                                             jint type, jint protocol,
                                             jlong pool)
  @@ -268,18 +292,8 @@
       a = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
       a->sock = s;
       a->pool = p;
  -    if (family > 0) { 
  -        a->type     = TCN_SOCKET_APR;
  -        a->recv     = APR_socket_recv;
  -        a->send     = APR_socket_send;
  -        a->sendv    = APR_socket_sendv;
  -        a->shutdown = APR_socket_shutdown;
  -        a->tmget    = APR_socket_timeout_get;
  -        a->tmset    = APR_socket_timeout_set;
  -        a->get      = APR_socket_opt_get;
  -        a->set      = APR_socket_opt_set;
  -        a->close    = NULL;
  -    }
  +    if (family > 0)
  +        a->net = &apr_socket_layer;
       a->opaque   = s;
       apr_pool_cleanup_register(p, (const void *)a,
                                 sp_socket_cleanup,
  @@ -327,7 +341,7 @@
               return P2J(s->sock);
           break;
           case TCN_SOCKET_GET_TYPE:
  -            return (jlong)(s->type);
  +            return (jlong)(s->net->type);
           break;
       }
       return 0;
  @@ -340,7 +354,7 @@
   
       UNREFERENCED_STDARGS;
       TCN_ASSERT(sock != 0);
  -    return (jint)(*s->shutdown)(s->opaque, how);
  +    return (jint)(*s->net->shutdown)(s->opaque, how);
   }
   
   TCN_IMPLEMENT_CALL(jint, Socket, close)(TCN_STDARGS, jlong sock)
  @@ -353,8 +367,8 @@
   #ifdef TCN_DO_STATISTICS
       apr_atomic_inc32(&sp_closed);
   #endif
  -    if (s->close)
  -        rv = (*s->close)(s->opaque);
  +    if (s->net->close)
  +        rv = (*s->net->close)(s->opaque);
       if (s->sock) {
           rv = (jint)apr_socket_close(s->sock);
           s->sock = NULL;
  @@ -396,7 +410,7 @@
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
   
  -    if (s->type == TCN_SOCKET_APR) {
  +    if (s->net->type == TCN_SOCKET_APR) {
           TCN_ASSERT(s->sock != NULL);
           TCN_THROW_IF_ERR(apr_socket_accept(&n, s->sock, p), n);
       }
  @@ -409,19 +423,10 @@
           apr_atomic_inc32(&sp_accepted);
   #endif
           a = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -        a->sock = n;
  -        a->pool = p;
  -        a->type = TCN_SOCKET_APR;
  -        a->recv     = APR_socket_recv;
  -        a->send     = APR_socket_send;
  -        a->sendv    = APR_socket_sendv;
  -        a->shutdown = APR_socket_shutdown;
  -        a->tmget    = APR_socket_timeout_get;
  -        a->tmset    = APR_socket_timeout_set;
  -        a->get      = APR_socket_opt_get;
  -        a->set      = APR_socket_opt_set;
  -        a->close    = NULL;
  -        a->opaque   = n;
  +        a->sock   = n;
  +        a->pool   = p;
  +        a->net    = &apr_socket_layer;
  +        a->opaque = n;
           apr_pool_cleanup_register(p, (const void *)a,
                                     sp_socket_cleanup,
                                     apr_pool_cleanup_null);
  @@ -442,7 +447,7 @@
       TCN_ASSERT(sock != 0);
   
       TCN_THROW_IF_ERR(apr_pool_create(&p, s->pool), p);
  -    if (s->type == TCN_SOCKET_APR) {
  +    if (s->net->type == TCN_SOCKET_APR) {
           TCN_ASSERT(s->sock != NULL);
           TCN_THROW_IF_ERR(apr_socket_accept(&n, s->sock, p), n);
       }
  @@ -455,19 +460,10 @@
           apr_atomic_inc32(&sp_accepted);
   #endif
           a = (tcn_socket_t *)apr_pcalloc(p, sizeof(tcn_socket_t));
  -        a->sock = n;
  -        a->pool = p;
  -        a->type = TCN_SOCKET_APR;
  -        a->recv     = APR_socket_recv;
  -        a->send     = APR_socket_send;
  -        a->sendv    = APR_socket_sendv;
  -        a->shutdown = APR_socket_shutdown;
  -        a->tmget    = APR_socket_timeout_get;
  -        a->tmset    = APR_socket_timeout_set;
  -        a->get      = APR_socket_opt_get;
  -        a->set      = APR_socket_opt_set;
  -        a->close    = NULL;
  -        a->opaque   = n;
  +        a->sock   = n;
  +        a->pool   = p;
  +        a->net    = &apr_socket_layer;
  +        a->opaque = n;
           apr_pool_cleanup_register(p, (const void *)a,
                                     sp_socket_cleanup,
                                     apr_pool_cleanup_null);
  @@ -511,7 +507,7 @@
       if (tosend <= TCN_BUFFER_SZ) {
           char sb[TCN_BUFFER_SZ];
           (*e)->GetByteArrayRegion(e, buf, offset, tosend, (jbyte *)sb);
  -        ss = (*s->send)(s->opaque, sb, &nbytes);
  +        ss = (*s->net->send)(s->opaque, sb, &nbytes);
       }
       else {
           jbyte *bytes;
  @@ -521,7 +517,7 @@
               bytes = (*e)->GetPrimitiveArrayCritical(e, buf, NULL);
           else
               bytes = (*e)->GetByteArrayElements(e, buf, NULL);
  -        ss = (*s->send)(s->opaque, bytes + offset, &nbytes);
  +        ss = (*s->net->send)(s->opaque, bytes + offset, &nbytes);
           if (nb)
               (*e)->ReleasePrimitiveArrayCritical(e, buf, bytes, JNI_ABORT);
           else
  @@ -555,7 +551,7 @@
   #endif
   
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
  -    ss = (*s->send)(s->opaque, bytes + offset, &nbytes);
  +    ss = (*s->net->send)(s->opaque, bytes + offset, &nbytes);
   
       if (ss == APR_SUCCESS)
           return (jint)nbytes;
  @@ -590,7 +586,7 @@
           vec[i].iov_base = (*e)->GetByteArrayElements(e, ba[i], NULL);
       }
   
  -    ss = (*s->sendv)(s->opaque, vec, nvec, &written);
  +    ss = (*s->net->sendv)(s->opaque, vec, nvec, &written);
   
       for (i = 0; i < nvec; i++) {
           (*e)->ReleaseByteArrayElements(e, ba[i], vec[i].iov_base, JNI_ABORT);
  @@ -653,12 +649,12 @@
       if (toread <= TCN_BUFFER_SZ) {
           char sb[TCN_BUFFER_SZ];
   
  -        if ((ss = (*s->recv)(s->opaque, sb, &nbytes)) == APR_SUCCESS)
  +        if ((ss = (*s->net->recv)(s->opaque, sb, &nbytes)) == APR_SUCCESS)
               (*e)->SetByteArrayRegion(e, buf, offset, (jsize)nbytes, sb);
       }
       else {
           jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
  -        ss = (*s->recv)(s->opaque, bytes + offset, &nbytes);
  +        ss = (*s->net->recv)(s->opaque, bytes + offset, &nbytes);
           (*e)->ReleaseByteArrayElements(e, buf, bytes,
                                          nbytes ? 0 : JNI_ABORT);
       }
  @@ -705,23 +701,23 @@
       TCN_ASSERT(s->opaque != NULL);
       TCN_ASSERT(buf != NULL);
   
  -    if ((ss = (*s->tmget)(s->opaque, &t)) != APR_SUCCESS)
  +    if ((ss = (*s->net->timeout_get)(s->opaque, &t)) != APR_SUCCESS)
           goto cleanup;
  -    if ((ss = (*s->tmset)(s->opaque, J2T(timeout))) != APR_SUCCESS)
  +    if ((ss = (*s->net->timeout_set)(s->opaque, J2T(timeout))) != APR_SUCCESS)
           goto cleanup;
       if (toread <= TCN_BUFFER_SZ) {
           char sb[TCN_BUFFER_SZ];
  -        ss = (*s->recv)(s->opaque, sb, &nbytes);
  +        ss = (*s->net->recv)(s->opaque, sb, &nbytes);
           (*e)->SetByteArrayRegion(e, buf, offset, (jsize)nbytes, sb);
       }
       else {
           jbyte *bytes = (*e)->GetByteArrayElements(e, buf, NULL);
  -        ss = (*s->recv)(s->opaque, bytes + offset, &nbytes);
  +        ss = (*s->net->recv)(s->opaque, bytes + offset, &nbytes);
           (*e)->ReleaseByteArrayElements(e, buf, bytes,
                                          nbytes ? 0 : JNI_ABORT);
       }
       /* Resore the original timeout */
  -    (*s->tmset)(s->opaque, t);
  +    (*s->net->timeout_set)(s->opaque, t);
   #ifdef TCN_DO_STATISTICS
       if (ss == APR_SUCCESS) {
           sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
  @@ -767,7 +763,7 @@
   
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
       TCN_ASSERT(bytes != NULL);
  -    ss = (*s->recv)(s->opaque, bytes + offset, &nbytes);
  +    ss = (*s->net->recv)(s->opaque, bytes + offset, &nbytes);
   #ifdef TCN_DO_STATISTICS
       if (ss == APR_SUCCESS) {
           sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
  @@ -815,13 +811,13 @@
       bytes  = (char *)(*e)->GetDirectBufferAddress(e, buf);
       TCN_ASSERT(bytes != NULL);
   
  -    if ((ss = (*s->tmget)(s->opaque, &t)) != APR_SUCCESS)
  +    if ((ss = (*s->net->timeout_get)(s->opaque, &t)) != APR_SUCCESS)
            return -(jint)ss;
  -    if ((ss = (*s->tmset)(s->opaque, J2T(timeout))) != APR_SUCCESS)
  +    if ((ss = (*s->net->timeout_set)(s->opaque, J2T(timeout))) != APR_SUCCESS)
            return -(jint)ss;
  -    ss = (*s->recv)(s->opaque, bytes + offset, &nbytes);
  +    ss = (*s->net->recv)(s->opaque, bytes + offset, &nbytes);
       /* Resore the original timeout */
  -    (*s->tmset)(s->opaque, t);
  +    (*s->net->timeout_set)(s->opaque, t);
   #ifdef TCN_DO_STATISTICS
       if (ss == APR_SUCCESS) {
           sp_max_recv = TCN_MAX(sp_max_recv, nbytes);
  @@ -887,7 +883,7 @@
       if (!s->sock)
           return APR_EINVAL;
       else
  -        return (jint)(*s->set)(s->opaque, (apr_int32_t)opt, (apr_int32_t)on);
  +        return (jint)(*s->net->opt_set)(s->opaque, (apr_int32_t)opt, (apr_int32_t)on);
   }
   
   TCN_IMPLEMENT_CALL(jint, Socket, optGet)(TCN_STDARGS, jlong sock,
  @@ -901,8 +897,8 @@
       if (s->sock)
           tcn_ThrowAPRException(e, APR_EINVAL);
       else {
  -        TCN_THROW_IF_ERR((*s->get)(s->opaque, (apr_int32_t)opt,
  -                                   &on), on);
  +        TCN_THROW_IF_ERR((*s->net->opt_get)(s->opaque, (apr_int32_t)opt,
  +                                            &on), on);
       }
   cleanup:
       return (jint)on;
  @@ -916,7 +912,7 @@
       UNREFERENCED_STDARGS;
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(s->opaque != NULL);
  -    return (jint)(*s->tmset)(s->opaque, J2T(timeout));
  +    return (jint)(*s->net->timeout_set)(s->opaque, J2T(timeout));
   }
   
   TCN_IMPLEMENT_CALL(jlong, Socket, timeoutGet)(TCN_STDARGS, jlong sock)
  @@ -927,7 +923,7 @@
       UNREFERENCED(o);
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(s->opaque != NULL);
  -    TCN_THROW_IF_ERR((*s->tmget)(s->opaque, &timeout), timeout);
  +    TCN_THROW_IF_ERR((*s->net->timeout_get)(s->opaque, &timeout), timeout);
   cleanup:
       return (jlong)timeout;
   }
  @@ -972,7 +968,7 @@
       TCN_ASSERT(sock != 0);
       TCN_ASSERT(file != 0);
   
  -    if (s->type != TCN_SOCKET_APR)
  +    if (s->net->type != TCN_SOCKET_APR)
           return (jint)(-APR_ENOTIMPL);
       if (headers)
           nh = (*e)->GetArrayLength(e, headers);
  @@ -997,8 +993,16 @@
       hdrs.trailers = &tvec[0];
       hdrs.numtrailers = nt;
   
  +
       ss = apr_socket_sendfile(s->sock, f, &hdrs, &off, &written, (apr_int32_t)flags);
   
  +#ifdef TCN_DO_STATISTICS
  +    sf_max_send = TCN_MAX(sf_max_send, written);
  +    sf_min_send = TCN_MIN(sf_min_send, written);
  +    sf_tot_send += written;
  +    sf_num_send++;
  +#endif
  +
       for (i = 0; i < nh; i++) {
           (*e)->ReleaseByteArrayElements(e, hba[i], hvec[i].iov_base, JNI_ABORT);
       }
  
  
  
  1.21      +18 -14    jakarta-tomcat-connectors/jni/native/src/sslnetwork.c
  
  Index: sslnetwork.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/sslnetwork.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- sslnetwork.c	30 Jun 2005 08:20:56 -0000	1.20
  +++ sslnetwork.c	2 Jul 2005 07:19:10 -0000	1.21
  @@ -281,7 +281,7 @@
   
       UNREFERENCED_STDARGS;
       TCN_ASSERT(sock != 0);
  -    if (ss->type != TCN_SOCKET_SSL)
  +    if (ss->net->type != TCN_SOCKET_SSL)
           return APR_EINVAL;
       con = (tcn_ssl_conn_t *)ss->opaque;
       while (!SSL_is_init_finished(con->ssl)) {
  @@ -449,6 +449,20 @@
       return APR_SUCCESS;
   }
   
  +static tcn_nlayer_t ssl_socket_layer = {
  +    TCN_SOCKET_SSL,
  +    ssl_cleanup,
  +    ssl_socket_close,
  +    ssl_socket_shutdown,
  +    ssl_socket_opt_get,
  +    ssl_socket_opt_set,
  +    ssl_socket_timeout_get,
  +    ssl_socket_timeout_set,
  +    ssl_socket_send,
  +    ssl_socket_sendv,
  +    ssl_socket_recv
  +};
  +
   
   TCN_IMPLEMENT_CALL(jint, SSLSocket, attach)(TCN_STDARGS, jlong ctx,
                                               jlong sock)
  @@ -475,18 +489,8 @@
       else
           SSL_set_connect_state(con->ssl);
       /* Change socket type */
  -    s->type     = TCN_SOCKET_SSL;
  -    s->cleanup  = ssl_cleanup;
  -    s->recv     = ssl_socket_recv;
  -    s->send     = ssl_socket_send;
  -    s->sendv    = ssl_socket_sendv;
  -    s->shutdown = ssl_socket_shutdown;
  -    s->tmget    = ssl_socket_timeout_get;
  -    s->tmset    = ssl_socket_timeout_set;
  -    s->get      = ssl_socket_opt_get;
  -    s->set      = ssl_socket_opt_set;
  -    s->close    = ssl_socket_close;
  -    s->opaque   = con;
  +    s->net    = &ssl_socket_layer;
  +    s->opaque = con;
   
       return APR_SUCCESS;
   }
  
  
  

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


Mime
View raw message