You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jw...@apache.org on 2002/04/30 08:48:45 UTC

cvs commit: httpd-2.0/modules/ssl ssl_scache_shmcb.c

jwoolley    02/04/29 23:48:45

  Modified:    .        CHANGES
               modules/ssl ssl_scache_shmcb.c
  Log:
  SHMCB should not have been using apr_rmm -- it was doing so incorrectly,
  for one thing.  But it just plain doesn't need it.  Rip it out to avoid
  segfaulting.
  
  Submitted by:  Aaron Bannert
  
  Revision  Changes    Path
  1.747     +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.746
  retrieving revision 1.747
  diff -u -d -u -r1.746 -r1.747
  --- CHANGES	30 Apr 2002 03:47:31 -0000	1.746
  +++ CHANGES	30 Apr 2002 06:48:45 -0000	1.747
  @@ -1,5 +1,7 @@
   Changes with Apache 2.0.37
   
  +  *) Fixed SHMCB session caching.  [Aaron Bannert, Cliff Woolley]
  +
     *) Synced with remaining changes from mod_ssl 2.8.8-1.3.24:
        - Avoid SIGBUS on sparc machines with SHMCB session caches
        - Allow whitespace between the pipe and the name of the
  
  
  
  1.12      +6 -51     httpd-2.0/modules/ssl/ssl_scache_shmcb.c
  
  Index: ssl_scache_shmcb.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/ssl/ssl_scache_shmcb.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -d -u -r1.11 -r1.12
  --- ssl_scache_shmcb.c	30 Apr 2002 03:47:31 -0000	1.11
  +++ ssl_scache_shmcb.c	30 Apr 2002 06:48:45 -0000	1.12
  @@ -357,17 +357,11 @@
   **
   */
   
  -static void *shmcb_malloc(SSLModConfigRec *mc, size_t size)
  -{
  -    apr_rmm_off_t off = apr_rmm_malloc(mc->pSessionCacheDataRMM, size);
  -    return apr_rmm_addr_get(mc->pSessionCacheDataRMM, off);
  -}
  -
   void ssl_scache_shmcb_init(server_rec *s, apr_pool_t *p)
   {
       SSLModConfigRec *mc = myModConfig(s);
  -    void *shm_segment = NULL;
  -    int avail, avail_orig;
  +    void *shm_segment;
  +    apr_size_t shm_segsize;
       apr_status_t rv;
   
       /*
  @@ -388,46 +382,12 @@
                   apr_strerror(rv, buf, sizeof(buf)));
           ssl_die();
       }
  +    shm_segment = apr_shm_baseaddr_get(mc->pSessionCacheDataMM);
  +    shm_segsize = apr_shm_size_get(mc->pSessionCacheDataMM);
   
  -    if ((rv = apr_rmm_init(&(mc->pSessionCacheDataRMM), NULL,
  -                             apr_shm_baseaddr_get(mc->pSessionCacheDataMM),
  -                             mc->nSessionCacheDataSize,
  -                             mc->pPool)) != APR_SUCCESS) {
  -        char buf[100];
  -        ssl_log(s, SSL_LOG_ERROR,
  -                "Cannot initialize rmm: (%d)%s", rv,
  -                apr_strerror(rv, buf, sizeof(buf)));
  -        ssl_die();
  -    }
  -
  -    /*
  -     * Create cache inside the shared memory segment
  -     */
  -    avail_orig = avail = mc->nSessionCacheDataSize - apr_rmm_overhead_get(0);
  -    ssl_log(s, SSL_LOG_TRACE, "Shared-memory segment has %u available",
  -            avail);
  -
  -    /* 
  -     * For some reason to do with MM's internal management, I can't
  -     * allocate the full amount. Implement a reasonable form of trial
  -     * and error and output trace information.
  -     */
  -    while ((shm_segment == NULL) && ((avail_orig - avail) * 100 < avail_orig)) {
  -        shm_segment = shmcb_malloc(mc, avail);
  -        if (shm_segment == NULL) {
  -            ssl_log(s, SSL_LOG_TRACE,
  -                    "shmcb_malloc attempt for %u bytes failed", avail);
  -            avail -= 4;
  -        }
  -    }
  -    if (shm_segment == NULL) {
  -        ssl_log(s, SSL_LOG_ERROR,
  -                "Cannot allocate memory for the 'shmcb' session cache\n");
  -        ssl_die();
  -    }
       ssl_log(s, SSL_LOG_TRACE, "shmcb_init allocated %u bytes of shared "
  -            "memory", avail);
  -    if (!shmcb_init_memory(s, shm_segment, avail)) {
  +            "memory", shm_segsize);
  +    if (!shmcb_init_memory(s, shm_segment, shm_segsize)) {
           ssl_log(s, SSL_LOG_ERROR,
                   "Failure initialising 'shmcb' shared memory");
           ssl_die();
  @@ -446,11 +406,6 @@
   void ssl_scache_shmcb_kill(server_rec *s)
   {
       SSLModConfigRec *mc = myModConfig(s);
  -
  -    if (mc->pSessionCacheDataRMM != NULL) {
  -        apr_rmm_destroy(mc->pSessionCacheDataRMM);
  -        mc->pSessionCacheDataRMM = NULL;
  -    }
   
       if (mc->pSessionCacheDataMM != NULL) {
           apr_shm_destroy(mc->pSessionCacheDataMM);