I think it's better to have it rather than not - safeguarding the code
against any compiler optimizations is a preferable thing to me.

BTW, did anybody get a chance to see if the patch actually works on
different platforms - it still does not work for me on HP-UX :-(.. it dumps
core at apr_rmm_malloc().

-Madhu

-----Original Message-----
From: Joe Orton [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 15, 2002 1:14 AM
To: [EMAIL PROTECTED]
Subject: Re: cvs commit: httpd-2.0/modules/ssl ssl_scache_shmcb.c
ssl_util_table.c


On Fri, Mar 15, 2002 at 01:46:47AM -0000, [EMAIL PROTECTED] wrote:
>    /* This is necessary simply so that the size passed to memset() is not
a
>     * compile-time constant, preventing the compiler from optimising it.
*/
>   +#if 0
>   +/* XXX: this isn't used, is it needed? */
>    static void shmcb_safe_clear(void *ptr, size_t size)
>    {
>       memset(ptr, 0, size);
>    }
>   +#endif

It was needed in mod_ssl 2.8 as in the below patch, since 'idx' wasn't
guaranteed to be word-aligned, and some compilers would optimise the
memset into instructions which operated on words. If you can guarantee
that idx is word-aligned in 2.0 with the new rmm stuff, it probably
isn't needed.

Index: ssl_scache_shmcb.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/ssl/ssl_scache_shmcb.c,v
retrieving revision 1.7
diff -u -r1.7 ssl_scache_shmcb.c
--- ssl_scache_shmcb.c  15 Mar 2002 01:46:47 -0000      1.7
+++ ssl_scache_shmcb.c  15 Mar 2002 08:49:02 -0000
@@ -269,13 +269,10 @@
 
 /* This is necessary simply so that the size passed to memset() is not a
  * compile-time constant, preventing the compiler from optimising it. */
-#if 0
-/* XXX: this isn't used, is it needed? */
 static void shmcb_safe_clear(void *ptr, size_t size)
 {
        memset(ptr, 0, size);
 }
-#endif
 
 /* Underlying functions for session-caching */
 static BOOL shmcb_init_memory(server_rec *, void *, unsigned int);
@@ -1178,7 +1175,7 @@
                 "internal error");
         return FALSE;
     }
-    memset(idx, 0, sizeof(SHMCBIndex));
+    shmcb_safe_clear(idx, sizeof(SHMCBIndex));
     shmcb_set_safe_time(&(idx->expires), expiry_time);
     shmcb_set_safe_uint(&(idx->offset), new_offset);
 

Reply via email to