[nginx] svn commit: r4224 - in trunk/src: core os/unix os/win32

igor at sysoev.ru igor at sysoev.ru
Mon Oct 24 15:46:49 UTC 2011


Author: is
Date: 2011-10-24 15:46:48 +0000 (Mon, 24 Oct 2011)
New Revision: 4224

Modified:
   trunk/src/core/nginx.c
   trunk/src/core/ngx_slab.c
   trunk/src/os/unix/ngx_darwin.h
   trunk/src/os/unix/ngx_darwin_config.h
   trunk/src/os/unix/ngx_darwin_init.c
   trunk/src/os/unix/ngx_freebsd.h
   trunk/src/os/unix/ngx_freebsd_config.h
   trunk/src/os/unix/ngx_freebsd_init.c
   trunk/src/os/unix/ngx_linux_config.h
   trunk/src/os/unix/ngx_os.h
   trunk/src/os/unix/ngx_posix_config.h
   trunk/src/os/unix/ngx_solaris_config.h
   trunk/src/os/win32/ngx_win32_config.h
Log:
malloc() debugging on MacOSX.


Modified: trunk/src/core/nginx.c
===================================================================
--- trunk/src/core/nginx.c	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/core/nginx.c	2011-10-24 15:46:48 UTC (rev 4224)
@@ -203,9 +203,7 @@
     ngx_cycle_t      *cycle, init_cycle;
     ngx_core_conf_t  *ccf;
 
-#if (NGX_FREEBSD)
     ngx_debug_init();
-#endif
 
     if (ngx_strerror_init() != NGX_OK) {
         return 1;

Modified: trunk/src/core/ngx_slab.c
===================================================================
--- trunk/src/core/ngx_slab.c	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/core/ngx_slab.c	2011-10-24 15:46:48 UTC (rev 4224)
@@ -46,10 +46,10 @@
 
 #else
 
-#if (NGX_FREEBSD)
+#if (NGX_HAVE_DEBUG_MALLOC)
 
 #define ngx_slab_junk(p, size)                                                \
-    if (ngx_freebsd_debug_malloc)  ngx_memset(p, 0xD0, size)
+    if (ngx_debug_malloc)          ngx_memset(p, 0xD0, size)
 
 #else
 

Modified: trunk/src/os/unix/ngx_darwin.h
===================================================================
--- trunk/src/os/unix/ngx_darwin.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_darwin.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -8,6 +8,7 @@
 #define _NGX_DARWIN_H_INCLUDED_
 
 
+void ngx_debug_init(void);
 ngx_chain_t *ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
     off_t limit);
 
@@ -15,5 +16,7 @@
 extern int       ngx_darwin_hw_ncpu;
 extern u_long    ngx_darwin_net_inet_tcp_sendspace;
 
+extern ngx_uint_t  ngx_debug_malloc;
 
+
 #endif /* _NGX_DARWIN_H_INCLUDED_ */

Modified: trunk/src/os/unix/ngx_darwin_config.h
===================================================================
--- trunk/src/os/unix/ngx_darwin_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_darwin_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -87,6 +87,7 @@
 
 
 #define NGX_HAVE_OS_SPECIFIC_INIT    1
+#define NGX_HAVE_DEBUG_MALLOC        1
 
 
 extern char **environ;

Modified: trunk/src/os/unix/ngx_darwin_init.c
===================================================================
--- trunk/src/os/unix/ngx_darwin_init.c	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_darwin_init.c	2011-10-24 15:46:48 UTC (rev 4224)
@@ -14,7 +14,9 @@
 int     ngx_darwin_kern_ipc_somaxconn;
 u_long  ngx_darwin_net_inet_tcp_sendspace;
 
+ngx_uint_t  ngx_debug_malloc;
 
+
 static ngx_os_io_t ngx_darwin_io = {
     ngx_unix_recv,
     ngx_readv_chain,
@@ -55,6 +57,34 @@
 };
 
 
+void
+ngx_debug_init()
+{
+#if (NGX_DEBUG_MALLOC)
+
+    /*
+     * MacOSX 10.6, 10.7:  MallocScribble fills freed memory with 0x55
+     *                     and fills allocated memory with 0xAA.
+     * MacOSX 10.4, 10.5:  MallocScribble fills freed memory with 0x55,
+     *                     MallocPreScribble fills allocated memory with 0xAA.
+     * MacOSX 10.3:        MallocScribble fills freed memory with 0x55,
+     *                     and no way to fill allocated memory.
+     */
+
+    setenv("MallocScribble", "1", 0);
+
+    ngx_debug_malloc = 1;
+
+#else
+
+    if (getenv("MallocScribble")) {
+        ngx_debug_malloc = 1;
+    }
+
+#endif
+}
+
+
 ngx_int_t
 ngx_os_specific_init(ngx_log_t *log)
 {

Modified: trunk/src/os/unix/ngx_freebsd.h
===================================================================
--- trunk/src/os/unix/ngx_freebsd.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_freebsd.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -8,6 +8,7 @@
 #define _NGX_FREEBSD_H_INCLUDED_
 
 
+void ngx_debug_init(void);
 ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
     off_t limit);
 
@@ -17,7 +18,7 @@
 
 extern ngx_uint_t  ngx_freebsd_sendfile_nbytes_bug;
 extern ngx_uint_t  ngx_freebsd_use_tcp_nopush;
-extern ngx_uint_t  ngx_freebsd_debug_malloc;
+extern ngx_uint_t  ngx_debug_malloc;
 
 
 #endif /* _NGX_FREEBSD_H_INCLUDED_ */

Modified: trunk/src/os/unix/ngx_freebsd_config.h
===================================================================
--- trunk/src/os/unix/ngx_freebsd_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_freebsd_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -109,6 +109,7 @@
 
 
 #define NGX_HAVE_OS_SPECIFIC_INIT    1
+#define NGX_HAVE_DEBUG_MALLOC        1
 
 
 extern char **environ;

Modified: trunk/src/os/unix/ngx_freebsd_init.c
===================================================================
--- trunk/src/os/unix/ngx_freebsd_init.c	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_freebsd_init.c	2011-10-24 15:46:48 UTC (rev 4224)
@@ -22,9 +22,10 @@
 
 ngx_uint_t  ngx_freebsd_sendfile_nbytes_bug;
 ngx_uint_t  ngx_freebsd_use_tcp_nopush;
-ngx_uint_t  ngx_freebsd_debug_malloc;
 
+ngx_uint_t  ngx_debug_malloc;
 
+
 static ngx_os_io_t ngx_freebsd_io = {
     ngx_unix_recv,
     ngx_readv_chain,
@@ -80,7 +81,7 @@
     malloc_options = "J";
 #endif
 
-    ngx_freebsd_debug_malloc = 1;
+    ngx_debug_malloc = 1;
 
 #else
     char  *mo;
@@ -88,7 +89,7 @@
     mo = getenv("MALLOC_OPTIONS");
 
     if (mo && ngx_strchr(mo, 'J')) {
-        ngx_freebsd_debug_malloc = 1;
+        ngx_debug_malloc = 1;
     }
 #endif
 }

Modified: trunk/src/os/unix/ngx_linux_config.h
===================================================================
--- trunk/src/os/unix/ngx_linux_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_linux_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -108,6 +108,7 @@
 
 
 #define NGX_HAVE_OS_SPECIFIC_INIT    1
+#define ngx_debug_init()
 
 
 extern char **environ;

Modified: trunk/src/os/unix/ngx_os.h
===================================================================
--- trunk/src/os/unix/ngx_os.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_os.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -31,7 +31,6 @@
 } ngx_os_io_t;
 
 
-void ngx_debug_init(void);
 ngx_int_t ngx_os_init(ngx_log_t *log);
 void ngx_os_status(ngx_log_t *log);
 ngx_int_t ngx_os_specific_init(ngx_log_t *log);

Modified: trunk/src/os/unix/ngx_posix_config.h
===================================================================
--- trunk/src/os/unix/ngx_posix_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_posix_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -125,7 +125,9 @@
 
 #define NGX_LISTEN_BACKLOG  511
 
+#define ngx_debug_init()
 
+
 #if (__FreeBSD__) && (__FreeBSD_version < 400017)
 
 #include <sys/param.h>          /* ALIGN() */

Modified: trunk/src/os/unix/ngx_solaris_config.h
===================================================================
--- trunk/src/os/unix/ngx_solaris_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/unix/ngx_solaris_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -98,6 +98,7 @@
 
 
 #define NGX_HAVE_OS_SPECIFIC_INIT    1
+#define ngx_debug_init()
 
 
 extern char **environ;

Modified: trunk/src/os/win32/ngx_win32_config.h
===================================================================
--- trunk/src/os/win32/ngx_win32_config.h	2011-10-24 12:59:01 UTC (rev 4223)
+++ trunk/src/os/win32/ngx_win32_config.h	2011-10-24 15:46:48 UTC (rev 4224)
@@ -182,6 +182,7 @@
 
 
 #define ngx_random               rand
+#define ngx_debug_init()
 
 
 #endif /* _NGX_WIN32_CONFIG_H_INCLUDED_ */



More information about the nginx-devel mailing list