summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-03-18 14:19:12 +0000
committerJonathan Kolb <jon@b0g.us>2008-03-18 14:19:12 +0000
commita2681ba3774279ea4135dc4068a50ce87784a3fc (patch)
treecee9c9b38e47665df3785de823f07164defd2ab2
parente27edb256803b9d1290c490304e8bc11be886cdb (diff)
downloadnginx-a2681ba3774279ea4135dc4068a50ce87784a3fc.tar.gz
Changes with nginx 0.6.29 18 Mar 2008v0.6.29
*) Feature: the ngx_google_perftools_module. *) Bugfix: the ngx_http_perl_module could be not built on 64-bit platforms; bug appeared in 0.6.27.
-rw-r--r--CHANGES8
-rw-r--r--CHANGES.ru8
-rw-r--r--auto/lib/conf4
-rw-r--r--auto/lib/google-perftools/conf33
-rw-r--r--auto/make32
-rw-r--r--auto/modules6
-rw-r--r--auto/options6
-rw-r--r--auto/sources4
-rw-r--r--src/core/nginx.h2
-rw-r--r--src/core/ngx_open_file_cache.c10
-rw-r--r--src/event/modules/ngx_eventport_module.c9
-rw-r--r--src/event/modules/ngx_rtsig_module.c8
-rw-r--r--src/event/ngx_event_openssl.c12
-rw-r--r--src/http/modules/ngx_http_charset_filter_module.c28
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c5
-rw-r--r--src/http/modules/perl/nginx.pm2
-rw-r--r--src/http/modules/perl/ngx_http_perl_module.c14
-rw-r--r--src/http/ngx_http_parse.c6
-rw-r--r--src/http/ngx_http_upstream.c97
-rw-r--r--src/misc/ngx_google_perftools_module.c127
20 files changed, 317 insertions, 104 deletions
diff --git a/CHANGES b/CHANGES
index 7ddc5fb8b..0b3087de3 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,12 @@
+Changes with nginx 0.6.29 18 Mar 2008
+
+ *) Feature: the ngx_google_perftools_module.
+
+ *) Bugfix: the ngx_http_perl_module could be not built on 64-bit
+ platforms; bug appeared in 0.6.27.
+
+
Changes with nginx 0.6.28 13 Mar 2008
*) Bugfix: the rtsig method could be not built; bug appeared in 0.6.27.
diff --git a/CHANGES.ru b/CHANGES.ru
index 5bc39246d..25e21b171 100644
--- a/CHANGES.ru
+++ b/CHANGES.ru
@@ -1,4 +1,12 @@
+Изменения в nginx 0.6.29 18.03.2008
+
+ *) Добавление: модуль ngx_google_perftools_module.
+
+ *) Исправление: модуль ngx_http_perl_module не собирался на 64-битных
+ платформах; ошибка появилась в 0.6.27.
+
+
Изменения в nginx 0.6.28 13.03.2008
*) Исправление: метод rtsig не собирался; ошибка появилась в 0.6.27.
diff --git a/auto/lib/conf b/auto/lib/conf
index e96103468..6411dabfb 100644
--- a/auto/lib/conf
+++ b/auto/lib/conf
@@ -42,3 +42,7 @@ fi
if [ $USE_PERL = YES ]; then
. auto/lib/perl/conf
fi
+
+if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then
+ . auto/lib/google-perftools/conf
+fi
diff --git a/auto/lib/google-perftools/conf b/auto/lib/google-perftools/conf
new file mode 100644
index 000000000..a8987c908
--- /dev/null
+++ b/auto/lib/google-perftools/conf
@@ -0,0 +1,33 @@
+
+# Copyright (C) Igor Sysoev
+
+
+ ngx_feature="Google perftools"
+ ngx_feature_name=
+ ngx_feature_run=no
+ ngx_feature_incs=
+ ngx_feature_path=
+ ngx_feature_libs="-lprofiler"
+ ngx_feature_test="ProfilerStop()"
+ . auto/feature
+
+
+if [ $ngx_found = no ]; then
+
+ # FreeBSD port
+
+ ngx_feature="Google perftools in /usr/local/"
+
+ if [ $NGX_RPATH = YES ]; then
+ ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lprofiler"
+ else
+ ngx_feature_libs="-L/usr/local/lib -lprofiler"
+ fi
+
+ . auto/feature
+fi
+
+
+if [ $ngx_found = yes ]; then
+ CORE_LIBS="$CORE_LIBS $ngx_feature_libs"
+fi
diff --git a/auto/make b/auto/make
index b97d8680f..2c827a311 100644
--- a/auto/make
+++ b/auto/make
@@ -6,7 +6,8 @@ mkdir -p $NGX_OBJS/src/core $NGX_OBJS/src/event $NGX_OBJS/src/event/modules \
$NGX_OBJS/src/os/unix $NGX_OBJS/src/os/win32 \
$NGX_OBJS/src/http $NGX_OBJS/src/http/modules \
$NGX_OBJS/src/http/modules/perl \
- $NGX_OBJS/src/mail
+ $NGX_OBJS/src/mail \
+ $NGX_OBJS/src/misc
ngx_objs_dir=$NGX_OBJS$ngx_regex_dirsep
@@ -127,6 +128,9 @@ END
fi
+ngx_all_srcs="$ngx_all_srcs $NGX_MISC_SRCS"
+
+
if test -n "$NGX_ADDON_SRCS"; then
cat << END >> $NGX_MAKEFILE
@@ -309,6 +313,32 @@ END
fi
+# the misc sources
+
+if test -n "$NGX_MISC_SRCS"; then
+
+ ngx_cc="\$(CC) $ngx_compile_opt \$(CFLAGS) $ngx_use_pch \$(ALL_INCS)"
+
+ for ngx_src in $NGX_MISC_SRCS
+ do
+ ngx_src=`echo $ngx_src | sed -e "s/\//$ngx_regex_dirsep/g"`
+ ngx_obj=`echo $ngx_src \
+ | sed -e "s#^\(.*\.\)cpp\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)cc\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)c\\$#$ngx_objs_dir\1$ngx_objext#g" \
+ -e "s#^\(.*\.\)S\\$#$ngx_objs_dir\1$ngx_objext#g"`
+
+ cat << END >> $NGX_MAKEFILE
+
+$ngx_obj: \$(CORE_DEPS) $ngx_cont$ngx_src
+ $ngx_cc$ngx_tab$ngx_objout$ngx_obj$ngx_tab$ngx_src$NGX_AUX
+
+END
+ done
+
+fi
+
+
# the addons sources
if test -n "$NGX_ADDON_SRCS"; then
diff --git a/auto/modules b/auto/modules
index 94bd7fba0..cba3768d5 100644
--- a/auto/modules
+++ b/auto/modules
@@ -375,6 +375,12 @@ if [ $MAIL = YES ]; then
fi
+if [ $NGX_GOOGLE_PERFTOOLS = YES ]; then
+ modules="$modules $NGX_GOOGLE_PERFTOOLS_MODULE"
+ NGX_MISC_SRCS="$NGX_MISC_SRCS $NGX_GOOGLE_PERFTOOLS_SRCS"
+fi
+
+
cat << END > $NGX_MODULES_C
#include <ngx_config.h>
diff --git a/auto/options b/auto/options
index ac475c9a6..65fd360de 100644
--- a/auto/options
+++ b/auto/options
@@ -115,6 +115,8 @@ ZLIB_ASM=NO
USE_PERL=NO
NGX_PERL=perl
+NGX_GOOGLE_PERFTOOLS=NO
+
NGX_CPU_CACHE_LINE=
@@ -201,6 +203,8 @@ do
--without-mail_imap_module) MAIL_IMAP=NO ;;
--without-mail_smtp_module) MAIL_SMTP=NO ;;
+ --with-google_perftools_module) NGX_GOOGLE_PERFTOOLS=YES ;;
+
--add-module=*) NGX_ADDONS="$NGX_ADDONS $value" ;;
--with-cc=*) CC="$value" ;;
@@ -317,6 +321,8 @@ cat << END
--without-mail_imap_module disable ngx_mail_imap_module
--without-mail_smtp_module disable ngx_mail_smtp_module
+ --with-google_perftools_module enable ngx_google_perftools_module
+
--add-module=PATH enable an external module
--with-cc=PATH set path to C compiler
diff --git a/auto/sources b/auto/sources
index 9c7311eb0..ed78c7164 100644
--- a/auto/sources
+++ b/auto/sources
@@ -460,3 +460,7 @@ MAIL_AUTH_HTTP_SRCS="src/mail/ngx_mail_auth_http_module.c"
MAIL_PROXY_MODULE="ngx_mail_proxy_module"
MAIL_PROXY_SRCS="src/mail/ngx_mail_proxy_module.c"
+
+NGX_GOOGLE_PERFTOOLS_MODULE=ngx_google_perftools_module
+NGX_GOOGLE_PERFTOOLS_SRCS=src/misc/ngx_google_perftools_module.c
+
diff --git a/src/core/nginx.h b/src/core/nginx.h
index c569b68f3..5a2e64dbc 100644
--- a/src/core/nginx.h
+++ b/src/core/nginx.h
@@ -8,7 +8,7 @@
#define _NGINX_H_INCLUDED_
-#define NGINX_VERSION "0.6.28"
+#define NGINX_VERSION "0.6.29"
#define NGINX_VER "nginx/" NGINX_VERSION
#define NGINX_VAR "NGINX"
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
index 9c5cc6732..a1692f101 100644
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -308,8 +308,6 @@ ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name,
/* not found */
- file = NULL;
-
rc = ngx_open_and_stat_file(name->data, of, pool->log);
if (rc != NGX_OK && (of->err == 0 || !of->errors)) {
@@ -413,9 +411,11 @@ failed:
cache->current--;
- if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
- ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
- ngx_close_file_n " \"%s\" failed", file->name);
+ if (file->fd != NGX_INVALID_FILE) {
+ if (ngx_close_file(file->fd) == NGX_FILE_ERROR) {
+ ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno,
+ ngx_close_file_n " \"%s\" failed", file->name);
+ }
}
ngx_free(file->name);
diff --git a/src/event/modules/ngx_eventport_module.c b/src/event/modules/ngx_eventport_module.c
index f9a8e88a4..4becf75d0 100644
--- a/src/event/modules/ngx_eventport_module.c
+++ b/src/event/modules/ngx_eventport_module.c
@@ -40,6 +40,15 @@ typedef struct port_notify {
void *portnfy_user; /* user defined */
} port_notify_t;
+#if (__FreeBSD_version < 700005)
+
+typedef struct itimerspec { /* definition per POSIX.4 */
+ struct timespec it_interval;/* timer period */
+ struct timespec it_value; /* timer expiration */
+} itimerspec_t;
+
+#endif
+
int port_create(void)
{
return -1;
diff --git a/src/event/modules/ngx_rtsig_module.c b/src/event/modules/ngx_rtsig_module.c
index c753854ff..6020936b7 100644
--- a/src/event/modules/ngx_rtsig_module.c
+++ b/src/event/modules/ngx_rtsig_module.c
@@ -11,8 +11,14 @@
#if (NGX_TEST_BUILD_RTSIG)
-#define F_SETSIG 10
+#ifdef SIGRTMIN
#define si_fd _reason.__spare__.__spare2__[0]
+#else
+#define SIGRTMIN 33
+#define si_fd __spare__[0]
+#endif
+
+#define F_SETSIG 10
#define KERN_RTSIGNR 30
#define KERN_RTSIGMAX 31
diff --git a/src/event/ngx_event_openssl.c b/src/event/ngx_event_openssl.c
index 9f964dabe..436237857 100644
--- a/src/event/ngx_event_openssl.c
+++ b/src/event/ngx_event_openssl.c
@@ -1155,11 +1155,21 @@ ngx_ssl_connection_error(ngx_connection_t *c, int sslerr, ngx_err_t err,
n = ERR_GET_REASON(ERR_peek_error());
/* handshake failures */
- if (n == SSL_R_NO_SHARED_CIPHER
+ if (n == SSL_R_DIGEST_CHECK_FAILED
+ || n == SSL_R_NO_SHARED_CIPHER
|| n == SSL_R_UNEXPECTED_MESSAGE
|| n == SSL_R_WRONG_VERSION_NUMBER
+ || n == SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
|| n == 1000 /* SSL_R_SSLV3_ALERT_CLOSE_NOTIFY */
+ || n == SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE
+ || n == SSL_R_SSLV3_ALERT_BAD_RECORD_MAC
+ || n == SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE
+ || n == SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE
+ || n == SSL_R_SSLV3_ALERT_BAD_CERTIFICATE
+ || n == SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE
+ || n == SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED
|| n == SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED
+ || n == SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN
|| n == SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER
|| n == SSL_R_TLSV1_ALERT_UNKNOWN_CA)
{
diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c
index f7d9906a8..850e64e75 100644
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -561,25 +561,33 @@ ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
static ngx_uint_t
ngx_http_charset_recode(ngx_buf_t *b, u_char *table)
{
- u_char *p;
+ u_char *p, *last;
- for (p = b->pos; p < b->last; p++) {
+ last = b->last;
- if (*p == table[*p]) {
- continue;
+ for (p = b->pos; p < last; p++) {
+
+ if (*p != table[*p]) {
+ goto recode;
}
+ }
+
+ return 0;
- while (p < b->last) {
+recode:
+
+ do {
+ if (*p != table[*p]) {
*p = table[*p];
- p++;
}
- b->in_file = 0;
+ p++;
- return 1;
- }
+ } while (p < last);
- return 0;
+ b->in_file = 0;
+
+ return 1;
}
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index b912e19b7..5678e21f3 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -639,6 +639,11 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
code((ngx_http_script_engine_t *) &e);
}
e.ip += sizeof(uintptr_t);
+
+ ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "fastcgi param: \"%*s: %*s\"",
+ key_len, e.pos - (key_len + val_len),
+ val_len, e.pos - val_len);
}
b->last = e.pos;
diff --git a/src/http/modules/perl/nginx.pm b/src/http/modules/perl/nginx.pm
index 77ca6b53c..822ae81ea 100644
--- a/src/http/modules/perl/nginx.pm
+++ b/src/http/modules/perl/nginx.pm
@@ -47,7 +47,7 @@ our @EXPORT = qw(
HTTP_INSUFFICIENT_STORAGE
);
-our $VERSION = '0.6.28';
+our $VERSION = '0.6.29';
require XSLoader;
XSLoader::load('nginx', $VERSION);
diff --git a/src/http/modules/perl/ngx_http_perl_module.c b/src/http/modules/perl/ngx_http_perl_module.c
index d8425b98f..ab89cadcf 100644
--- a/src/http/modules/perl/ngx_http_perl_module.c
+++ b/src/http/modules/perl/ngx_http_perl_module.c
@@ -668,7 +668,7 @@ ngx_http_perl_call_handler(pTHX_ ngx_http_request_t *r, HV *nginx, SV *sub,
XPUSHs(sv);
if (args) {
- EXTEND(sp, (int) args[0]);
+ EXTEND(sp, (intptr_t) args[0]);
for (i = 1; i <= (ngx_uint_t) args[0]; i++) {
PUSHs(sv_2mortal(args[i]));
@@ -1055,8 +1055,20 @@ ngx_http_perl_init_worker(ngx_cycle_t *cycle)
return NGX_OK;
}
+
static void
ngx_http_perl_exit(ngx_cycle_t *cycle)
{
+ ngx_http_perl_main_conf_t *pmcf;
+
+ pmcf = ngx_http_cycle_get_module_main_conf(cycle, ngx_http_perl_module);
+
+ {
+
+ dTHXa(pmcf->perl);
+ PERL_SET_CONTEXT(pmcf->perl);
+
PERL_SYS_TERM();
+
+ }
}
diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c
index b83810d2e..9777ebb98 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -775,7 +775,7 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
if (c) {
hash = ngx_hash(hash, c);
r->lowcase_header[i++] = c;
- i &= ~NGX_HTTP_LC_HEADER_LEN;
+ i &= (NGX_HTTP_LC_HEADER_LEN - 1);
break;
}
@@ -882,10 +882,10 @@ ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b)
/* end of header line */
case sw_almost_done:
switch (ch) {
- case CR:
- break;
case LF:
goto done;
+ case CR:
+ break;
default:
return NGX_HTTP_PARSE_INVALID_HEADER;
}
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 7041514c8..be30b8862 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2125,13 +2125,11 @@ ngx_http_upstream_process_body(ngx_event_t *ev)
static void
ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
{
- char *failed;
- u_char *name;
- size_t root;
- time_t lm;
- ngx_err_t err;
- ngx_str_t *temp, path, *last_modified;
- ngx_temp_file_t *tf;
+ size_t root;
+ time_t lm;
+ ngx_str_t path;
+ ngx_temp_file_t *tf;
+ ngx_ext_rename_file_t ext;
tf = u->pipe->temp_file;
@@ -2160,36 +2158,20 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
u->pipe->temp_file = tf;
}
- temp = &tf->file.name;
-
-#if !(NGX_WIN32)
-
- if (ngx_change_file_access(temp->data, u->conf->store_access)
- == NGX_FILE_ERROR)
- {
- err = ngx_errno;
- failed = ngx_change_file_access_n;
- name = temp->data;
-
- goto failed;
- }
-
-#endif
+ ext.access = u->conf->store_access;
+ ext.time = -1;
+ ext.create_path = 1;
+ ext.delete_file = 1;
+ ext.log = r->connection->log;
if (u->headers_in.last_modified) {
- last_modified = &u->headers_in.last_modified->value;
-
- lm = ngx_http_parse_time(last_modified->data, last_modified->len);
+ lm = ngx_http_parse_time(u->headers_in.last_modified->value.data,
+ u->headers_in.last_modified->value.len);
if (lm != NGX_ERROR) {
- if (ngx_set_file_time(temp->data, tf->file.fd, lm) != NGX_OK) {
- err = ngx_errno;
- failed = ngx_set_file_time_n;
- name = temp->data;
-
- goto failed;
- }
+ ext.time = lm;
+ ext.fd = tf->file.fd;
}
}
@@ -2207,55 +2189,10 @@ ngx_http_upstream_store(ngx_http_request_t *r, ngx_http_upstream_t *u)
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
- "upstream stores \"%s\" to \"%s\"", temp->data, path.data);
-
- failed = ngx_rename_file_n;
- name = path.data;
-
- if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
- return;
- }
-
- err = ngx_errno;
-
- if (err == NGX_ENOENT) {
-
- err = ngx_create_full_path(path.data,
- ngx_dir_access(u->conf->store_access));
- if (err == 0) {
- if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
- return;
- }
-
- err = ngx_errno;
- }
- }
-
-#if (NGX_WIN32)
-
- if (err == NGX_EEXIST) {
- if (ngx_win32_rename_file(temp, &path, r->connection->log) == NGX_OK) {
-
- if (ngx_rename_file(temp->data, path.data) != NGX_FILE_ERROR) {
- return;
- }
- }
-
- err = ngx_errno;
- }
-
-#endif
-
-failed:
-
- if (ngx_delete_file(temp->data) == NGX_FILE_ERROR) {
- ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
- ngx_delete_file_n " \"%s\" failed",
- temp->data);
- }
+ "upstream stores \"%s\" to \"%s\"",
+ tf->file.name.data, path.data);
- ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
- "%s \"%s\" failed", failed, name);
+ (void) ngx_ext_rename_file(&tf->file.name, &path, &ext);
}
diff --git a/src/misc/ngx_google_perftools_module.c b/src/misc/ngx_google_perftools_module.c
new file mode 100644
index 000000000..66c3a1f98
--- /dev/null
+++ b/src/misc/ngx_google_perftools_module.c
@@ -0,0 +1,127 @@
+
+/*
+ * Copyright (C) Igor Sysoev
+ */
+
+
+#include <ngx_config.h>
+#include <ngx_core.h>
+
+/*
+ * declare Profiler here interface because
+ * <google/profiler.h> is C++ header file
+ */
+
+int ProfilerStart(u_char* fname);
+void ProfilerStop(void);
+void ProfilerRegisterThread(void);
+
+
+static void *ngx_google_perftools_create_conf(ngx_cycle_t *cycle);
+static ngx_int_t ngx_google_perftools_worker(ngx_cycle_t *cycle);
+
+
+typedef struct {
+ ngx_str_t profiles;
+} ngx_google_perftools_conf_t;
+
+
+static ngx_command_t ngx_google_perftools_commands[] = {
+
+ { ngx_string("google_perftools_profiles"),
+ NGX_MAIN_CONF|NGX_DIRECT_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_str_slot,
+ 0,
+ offsetof(ngx_google_perftools_conf_t, profiles),
+ NULL },
+
+ ngx_null_command
+};
+
+
+static ngx_core_module_t ngx_google_perftools_module_ctx = {
+ ngx_string("google_perftools"),
+ ngx_google_perftools_create_conf,
+ NULL
+};
+
+
+ngx_module_t ngx_google_perftools_module = {
+ NGX_MODULE_V1,
+ &ngx_google_perftools_module_ctx, /* module context */
+ ngx_google_perftools_commands, /* module directives */
+ NGX_CORE_MODULE, /* module type */
+ NULL, /* init master */
+ NULL, /* init module */
+ ngx_google_perftools_worker, /* init process */
+ NULL, /* init thread */
+ NULL, /* exit thread */
+ NULL, /* exit process */
+ NULL, /* exit master */
+ NGX_MODULE_V1_PADDING
+};
+
+
+static void *
+ngx_google_perftools_create_conf(ngx_cycle_t *cycle)
+{
+ ngx_google_perftools_conf_t *gptcf;
+
+ gptcf = ngx_pcalloc(cycle->pool, sizeof(ngx_google_perftools_conf_t));
+ if (gptcf == NULL) {
+ return NULL;
+ }
+
+ /*
+ * set by pcalloc()
+ *
+ * gptcf->profiles = { 0, NULL };
+ */
+
+ return gptcf;
+}
+
+
+static ngx_int_t
+ngx_google_perftools_worker(ngx_cycle_t *cycle)
+{
+ u_char *profile;
+ ngx_google_perftools_conf_t *gptcf;
+
+ gptcf = (ngx_google_perftools_conf_t *)
+ ngx_get_conf(cycle->conf_ctx, ngx_google_perftools_module);
+
+ if (gptcf->profiles.len == 0) {
+ return NGX_OK;
+ }
+
+ profile = ngx_alloc(gptcf->profiles.len + NGX_INT_T_LEN + 2, cycle->log);
+ if (profile == NULL) {
+ return NGX_OK;
+ }
+
+ if (getenv("CPUPROFILE")) {
+
+ /* disable inherited Profiler enabled in master process */
+ ProfilerStop();
+ }
+
+ ngx_sprintf(profile, "%V.%d%Z", &gptcf->profiles, ngx_pid);
+
+ if (ProfilerStart(profile)) {
+
+ /* start ITIMER_PROF timer */
+ ProfilerRegisterThread();
+
+ } else {
+ ngx_log_error(NGX_LOG_CRIT, cycle->log, ngx_errno,
+ "ProfilerStart(%s) failed", profile);
+ }
+
+ ngx_free(profile);
+
+ return NGX_OK;
+}
+
+
+/* ProfilerStop() is called on Profiler destruction */