nginxtra 1.6.3.9 → 1.8.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/nginxtra +1 -1
- data/bin/nginxtra_rails +1 -1
- data/lib/nginxtra/version.rb +1 -1
- data/vendor/nginx/CHANGES +358 -14
- data/vendor/nginx/CHANGES.ru +372 -18
- data/vendor/nginx/LICENSE +2 -2
- data/vendor/nginx/auto/cc/clang +5 -0
- data/vendor/nginx/auto/cc/gcc +5 -0
- data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
- data/vendor/nginx/auto/lib/openssl/make +0 -5
- data/vendor/nginx/auto/lib/perl/conf +9 -1
- data/vendor/nginx/auto/make +1 -1
- data/vendor/nginx/auto/modules +11 -0
- data/vendor/nginx/auto/options +10 -2
- data/vendor/nginx/auto/os/darwin +0 -1
- data/vendor/nginx/auto/os/freebsd +6 -23
- data/vendor/nginx/auto/sources +16 -14
- data/vendor/nginx/auto/summary +3 -24
- data/vendor/nginx/auto/threads +20 -0
- data/vendor/nginx/auto/types/sizeof +2 -12
- data/vendor/nginx/auto/unix +50 -6
- data/vendor/nginx/configure +5 -0
- data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
- data/vendor/nginx/src/core/nginx.c +21 -9
- data/vendor/nginx/src/core/nginx.h +8 -2
- data/vendor/nginx/src/core/ngx_buf.c +88 -0
- data/vendor/nginx/src/core/ngx_buf.h +15 -1
- data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
- data/vendor/nginx/src/core/ngx_connection.c +25 -66
- data/vendor/nginx/src/core/ngx_connection.h +1 -3
- data/vendor/nginx/src/core/ngx_core.h +11 -3
- data/vendor/nginx/src/core/ngx_crypt.c +1 -1
- data/vendor/nginx/src/core/ngx_cycle.c +7 -1
- data/vendor/nginx/src/core/ngx_cycle.h +6 -2
- data/vendor/nginx/src/core/ngx_file.c +13 -5
- data/vendor/nginx/src/core/ngx_file.h +6 -0
- data/vendor/nginx/src/core/ngx_log.c +215 -21
- data/vendor/nginx/src/core/ngx_log.h +9 -1
- data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
- data/vendor/nginx/src/core/ngx_palloc.c +3 -7
- data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
- data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
- data/vendor/nginx/src/core/ngx_regex.c +14 -6
- data/vendor/nginx/src/core/ngx_resolver.c +16 -23
- data/vendor/nginx/src/core/ngx_resolver.h +8 -7
- data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
- data/vendor/nginx/src/core/ngx_slab.c +89 -2
- data/vendor/nginx/src/core/ngx_slab.h +3 -0
- data/vendor/nginx/src/core/ngx_string.c +58 -2
- data/vendor/nginx/src/core/ngx_string.h +1 -0
- data/vendor/nginx/src/core/ngx_syslog.c +374 -0
- data/vendor/nginx/src/core/ngx_syslog.h +30 -0
- data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
- data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
- data/vendor/nginx/src/core/ngx_times.c +19 -2
- data/vendor/nginx/src/core/ngx_times.h +1 -0
- data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
- data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
- data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
- data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
- data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
- data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
- data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
- data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
- data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
- data/vendor/nginx/src/event/ngx_event.c +5 -33
- data/vendor/nginx/src/event/ngx_event.h +15 -50
- data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
- data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
- data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
- data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
- data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
- data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
- data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
- data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
- data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
- data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
- data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
- data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
- data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
- data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
- data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
- data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
- data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
- data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
- data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
- data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
- data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
- data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
- data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
- data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
- data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
- data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
- data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
- data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
- data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
- data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
- data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
- data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
- data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
- data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
- data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
- data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
- data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
- data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
- data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
- data/vendor/nginx/src/http/ngx_http.c +10 -5
- data/vendor/nginx/src/http/ngx_http.h +4 -4
- data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
- data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
- data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
- data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
- data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
- data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
- data/vendor/nginx/src/http/ngx_http_request.c +14 -6
- data/vendor/nginx/src/http/ngx_http_request.h +12 -4
- data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
- data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
- data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
- data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
- data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
- data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
- data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
- data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
- data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
- data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
- data/vendor/nginx/src/mail/ngx_mail.c +2 -3
- data/vendor/nginx/src/mail/ngx_mail.h +2 -0
- data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
- data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
- data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
- data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
- data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
- data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
- data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
- data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
- data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
- data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
- data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
- data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
- data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
- data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
- data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
- data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
- data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
- data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
- data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
- data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
- data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
- data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
- data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
- data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
- data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
- data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
- data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
- data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
- data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
- data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
- data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
- metadata +16 -17
- data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
- data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
- data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
- data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
- data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
- data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
- data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
- data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
- data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
- data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -66,7 +66,7 @@ ngx_crypt_apr1(ngx_pool_t *pool, u_char *key, u_char *salt, u_char **encrypted)
|
|
66
66
|
size_t saltlen, keylen;
|
67
67
|
ngx_md5_t md5, ctx1;
|
68
68
|
|
69
|
-
/* Apache's apr1 crypt is
|
69
|
+
/* Apache's apr1 crypt is Poul-Henning Kamp's md5 crypt with $apr1$ magic */
|
70
70
|
|
71
71
|
keylen = ngx_strlen(key);
|
72
72
|
|
@@ -26,7 +26,7 @@ static ngx_event_t ngx_cleaner_event;
|
|
26
26
|
ngx_uint_t ngx_test_config;
|
27
27
|
ngx_uint_t ngx_quiet_mode;
|
28
28
|
|
29
|
-
#if (
|
29
|
+
#if (NGX_OLD_THREADS)
|
30
30
|
ngx_tls_key_t ngx_core_tls_key;
|
31
31
|
#endif
|
32
32
|
|
@@ -1104,6 +1104,8 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
|
1104
1104
|
ngx_close_file_n " \"%s\" failed",
|
1105
1105
|
file[i].name.data);
|
1106
1106
|
}
|
1107
|
+
|
1108
|
+
continue;
|
1107
1109
|
}
|
1108
1110
|
|
1109
1111
|
if (fi.st_uid != user) {
|
@@ -1117,6 +1119,8 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
|
1117
1119
|
ngx_close_file_n " \"%s\" failed",
|
1118
1120
|
file[i].name.data);
|
1119
1121
|
}
|
1122
|
+
|
1123
|
+
continue;
|
1120
1124
|
}
|
1121
1125
|
}
|
1122
1126
|
|
@@ -1133,6 +1137,8 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user)
|
|
1133
1137
|
ngx_close_file_n " \"%s\" failed",
|
1134
1138
|
file[i].name.data);
|
1135
1139
|
}
|
1140
|
+
|
1141
|
+
continue;
|
1136
1142
|
}
|
1137
1143
|
}
|
1138
1144
|
}
|
@@ -103,7 +103,7 @@ typedef struct {
|
|
103
103
|
ngx_array_t env;
|
104
104
|
char **environment;
|
105
105
|
|
106
|
-
#if (
|
106
|
+
#if (NGX_OLD_THREADS)
|
107
107
|
ngx_int_t worker_threads;
|
108
108
|
size_t thread_stack_size;
|
109
109
|
#endif
|
@@ -111,10 +111,14 @@ typedef struct {
|
|
111
111
|
} ngx_core_conf_t;
|
112
112
|
|
113
113
|
|
114
|
+
#if (NGX_OLD_THREADS)
|
115
|
+
|
114
116
|
typedef struct {
|
115
117
|
ngx_pool_t *pool; /* pcre's malloc() pool */
|
116
118
|
} ngx_core_tls_t;
|
117
119
|
|
120
|
+
#endif
|
121
|
+
|
118
122
|
|
119
123
|
#define ngx_is_init_cycle(cycle) (cycle->conf_ctx == NULL)
|
120
124
|
|
@@ -136,7 +140,7 @@ extern ngx_array_t ngx_old_cycles;
|
|
136
140
|
extern ngx_module_t ngx_core_module;
|
137
141
|
extern ngx_uint_t ngx_test_config;
|
138
142
|
extern ngx_uint_t ngx_quiet_mode;
|
139
|
-
#if (
|
143
|
+
#if (NGX_OLD_THREADS)
|
140
144
|
extern ngx_tls_key_t ngx_core_tls_key;
|
141
145
|
#endif
|
142
146
|
|
@@ -114,7 +114,7 @@ ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
|
|
114
114
|
rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool,
|
115
115
|
tf->persistent, tf->clean, tf->access);
|
116
116
|
|
117
|
-
if (rc
|
117
|
+
if (rc != NGX_OK) {
|
118
118
|
return rc;
|
119
119
|
}
|
120
120
|
|
@@ -356,7 +356,7 @@ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
356
356
|
}
|
357
357
|
|
358
358
|
if (ngx_conf_full_name(cf->cycle, &path->name, 0) != NGX_OK) {
|
359
|
-
return
|
359
|
+
return NGX_CONF_ERROR;
|
360
360
|
}
|
361
361
|
|
362
362
|
path->conf_file = cf->conf_file->file.name.data;
|
@@ -372,8 +372,8 @@ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
372
372
|
path->len += level + 1;
|
373
373
|
}
|
374
374
|
|
375
|
-
|
376
|
-
|
375
|
+
if (path->len > 10 + i) {
|
376
|
+
return "invalid value";
|
377
377
|
}
|
378
378
|
|
379
379
|
*slot = path;
|
@@ -1035,10 +1035,18 @@ ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree)
|
|
1035
1035
|
ctx->access = ngx_de_access(&dir);
|
1036
1036
|
ctx->mtime = ngx_de_mtime(&dir);
|
1037
1037
|
|
1038
|
-
|
1038
|
+
rc = ctx->pre_tree_handler(ctx, &file);
|
1039
|
+
|
1040
|
+
if (rc == NGX_ABORT) {
|
1039
1041
|
goto failed;
|
1040
1042
|
}
|
1041
1043
|
|
1044
|
+
if (rc == NGX_DECLINED) {
|
1045
|
+
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
|
1046
|
+
"tree skip dir \"%s\"", file.data);
|
1047
|
+
continue;
|
1048
|
+
}
|
1049
|
+
|
1042
1050
|
if (ngx_walk_tree(ctx, &file) == NGX_ABORT) {
|
1043
1051
|
goto failed;
|
1044
1052
|
}
|
@@ -14,6 +14,23 @@ static char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log);
|
|
14
14
|
static void ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log);
|
15
15
|
|
16
16
|
|
17
|
+
#if (NGX_DEBUG)
|
18
|
+
|
19
|
+
static void ngx_log_memory_writer(ngx_log_t *log, ngx_uint_t level,
|
20
|
+
u_char *buf, size_t len);
|
21
|
+
static void ngx_log_memory_cleanup(void *data);
|
22
|
+
|
23
|
+
|
24
|
+
typedef struct {
|
25
|
+
u_char *start;
|
26
|
+
u_char *end;
|
27
|
+
u_char *pos;
|
28
|
+
ngx_atomic_t written;
|
29
|
+
} ngx_log_memory_buf_t;
|
30
|
+
|
31
|
+
#endif
|
32
|
+
|
33
|
+
|
17
34
|
static ngx_command_t ngx_errlog_commands[] = {
|
18
35
|
|
19
36
|
{ngx_string("error_log"),
|
@@ -91,15 +108,14 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
|
91
108
|
va_list args;
|
92
109
|
#endif
|
93
110
|
u_char *p, *last, *msg;
|
94
|
-
|
111
|
+
ssize_t n;
|
95
112
|
ngx_uint_t wrote_stderr, debug_connection;
|
113
|
+
u_char errstr[NGX_MAX_ERROR_STR];
|
96
114
|
|
97
115
|
last = errstr + NGX_MAX_ERROR_STR;
|
98
116
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
p = errstr + ngx_cached_err_log_time.len;
|
117
|
+
p = ngx_cpymem(errstr, ngx_cached_err_log_time.data,
|
118
|
+
ngx_cached_err_log_time.len);
|
103
119
|
|
104
120
|
p = ngx_slprintf(p, last, " [%V] ", &err_levels[level]);
|
105
121
|
|
@@ -148,12 +164,34 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
|
|
148
164
|
break;
|
149
165
|
}
|
150
166
|
|
151
|
-
|
167
|
+
if (log->writer) {
|
168
|
+
log->writer(log, level, errstr, p - errstr);
|
169
|
+
goto next;
|
170
|
+
}
|
171
|
+
|
172
|
+
if (ngx_time() == log->disk_full_time) {
|
173
|
+
|
174
|
+
/*
|
175
|
+
* on FreeBSD writing to a full filesystem with enabled softupdates
|
176
|
+
* may block process for much longer time than writing to non-full
|
177
|
+
* filesystem, so we skip writing to a log for one second
|
178
|
+
*/
|
179
|
+
|
180
|
+
goto next;
|
181
|
+
}
|
182
|
+
|
183
|
+
n = ngx_write_fd(log->file->fd, errstr, p - errstr);
|
184
|
+
|
185
|
+
if (n == -1 && ngx_errno == NGX_ENOSPC) {
|
186
|
+
log->disk_full_time = ngx_time();
|
187
|
+
}
|
152
188
|
|
153
189
|
if (log->file->fd == ngx_stderr) {
|
154
190
|
wrote_stderr = 1;
|
155
191
|
}
|
156
192
|
|
193
|
+
next:
|
194
|
+
|
157
195
|
log = log->next;
|
158
196
|
}
|
159
197
|
|
@@ -225,9 +263,8 @@ ngx_log_stderr(ngx_err_t err, const char *fmt, ...)
|
|
225
263
|
u_char errstr[NGX_MAX_ERROR_STR];
|
226
264
|
|
227
265
|
last = errstr + NGX_MAX_ERROR_STR;
|
228
|
-
p = errstr + 7;
|
229
266
|
|
230
|
-
|
267
|
+
p = ngx_cpymem(errstr, "nginx: ", 7);
|
231
268
|
|
232
269
|
va_start(args, fmt);
|
233
270
|
p = ngx_vslprintf(p, last, fmt, args);
|
@@ -366,15 +403,35 @@ ngx_log_init(u_char *prefix)
|
|
366
403
|
ngx_int_t
|
367
404
|
ngx_log_open_default(ngx_cycle_t *cycle)
|
368
405
|
{
|
369
|
-
|
406
|
+
ngx_log_t *log;
|
407
|
+
static ngx_str_t error_log = ngx_string(NGX_ERROR_LOG_PATH);
|
370
408
|
|
371
|
-
if (cycle->new_log
|
372
|
-
|
373
|
-
|
409
|
+
if (ngx_log_get_file_log(&cycle->new_log) != NULL) {
|
410
|
+
return NGX_OK;
|
411
|
+
}
|
412
|
+
|
413
|
+
if (cycle->new_log.log_level != 0) {
|
414
|
+
/* there are some error logs, but no files */
|
415
|
+
|
416
|
+
log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t));
|
417
|
+
if (log == NULL) {
|
374
418
|
return NGX_ERROR;
|
375
419
|
}
|
376
420
|
|
377
|
-
|
421
|
+
} else {
|
422
|
+
/* no error logs at all */
|
423
|
+
log = &cycle->new_log;
|
424
|
+
}
|
425
|
+
|
426
|
+
log->log_level = NGX_LOG_ERR;
|
427
|
+
|
428
|
+
log->file = ngx_conf_open_file(cycle, &error_log);
|
429
|
+
if (log->file == NULL) {
|
430
|
+
return NGX_ERROR;
|
431
|
+
}
|
432
|
+
|
433
|
+
if (log != &cycle->new_log) {
|
434
|
+
ngx_log_insert(&cycle->new_log, log);
|
378
435
|
}
|
379
436
|
|
380
437
|
return NGX_OK;
|
@@ -390,7 +447,8 @@ ngx_log_redirect_stderr(ngx_cycle_t *cycle)
|
|
390
447
|
return NGX_OK;
|
391
448
|
}
|
392
449
|
|
393
|
-
|
450
|
+
/* file log always exists when we are called */
|
451
|
+
fd = ngx_log_get_file_log(cycle->log)->file->fd;
|
394
452
|
|
395
453
|
if (fd != ngx_stderr) {
|
396
454
|
if (ngx_set_stderr(fd) == NGX_FILE_ERROR) {
|
@@ -405,6 +463,21 @@ ngx_log_redirect_stderr(ngx_cycle_t *cycle)
|
|
405
463
|
}
|
406
464
|
|
407
465
|
|
466
|
+
ngx_log_t *
|
467
|
+
ngx_log_get_file_log(ngx_log_t *head)
|
468
|
+
{
|
469
|
+
ngx_log_t *log;
|
470
|
+
|
471
|
+
for (log = head; log; log = log->next) {
|
472
|
+
if (log->file != NULL) {
|
473
|
+
return log;
|
474
|
+
}
|
475
|
+
}
|
476
|
+
|
477
|
+
return NULL;
|
478
|
+
}
|
479
|
+
|
480
|
+
|
408
481
|
static char *
|
409
482
|
ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log)
|
410
483
|
{
|
@@ -482,8 +555,9 @@ ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
|
482
555
|
char *
|
483
556
|
ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head)
|
484
557
|
{
|
485
|
-
ngx_log_t
|
486
|
-
ngx_str_t
|
558
|
+
ngx_log_t *new_log;
|
559
|
+
ngx_str_t *value, name;
|
560
|
+
ngx_syslog_peer_t *peer;
|
487
561
|
|
488
562
|
if (*head != NULL && (*head)->log_level == 0) {
|
489
563
|
new_log = *head;
|
@@ -506,13 +580,88 @@ ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head)
|
|
506
580
|
ngx_str_null(&name);
|
507
581
|
cf->cycle->log_use_stderr = 1;
|
508
582
|
|
509
|
-
|
510
|
-
|
511
|
-
|
583
|
+
new_log->file = ngx_conf_open_file(cf->cycle, &name);
|
584
|
+
if (new_log->file == NULL) {
|
585
|
+
return NGX_CONF_ERROR;
|
586
|
+
}
|
587
|
+
|
588
|
+
} else if (ngx_strncmp(value[1].data, "memory:", 7) == 0) {
|
589
|
+
|
590
|
+
#if (NGX_DEBUG)
|
591
|
+
size_t size, needed;
|
592
|
+
ngx_pool_cleanup_t *cln;
|
593
|
+
ngx_log_memory_buf_t *buf;
|
594
|
+
|
595
|
+
value[1].len -= 7;
|
596
|
+
value[1].data += 7;
|
597
|
+
|
598
|
+
needed = sizeof("MEMLOG :" NGX_LINEFEED)
|
599
|
+
+ cf->conf_file->file.name.len
|
600
|
+
+ NGX_SIZE_T_LEN
|
601
|
+
+ NGX_INT_T_LEN
|
602
|
+
+ NGX_MAX_ERROR_STR;
|
603
|
+
|
604
|
+
size = ngx_parse_size(&value[1]);
|
605
|
+
|
606
|
+
if (size == (size_t) NGX_ERROR || size < needed) {
|
607
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
608
|
+
"invalid buffer size \"%V\"", &value[1]);
|
609
|
+
return NGX_CONF_ERROR;
|
610
|
+
}
|
611
|
+
|
612
|
+
buf = ngx_palloc(cf->pool, sizeof(ngx_log_memory_buf_t));
|
613
|
+
if (buf == NULL) {
|
614
|
+
return NGX_CONF_ERROR;
|
615
|
+
}
|
616
|
+
|
617
|
+
buf->start = ngx_pnalloc(cf->pool, size);
|
618
|
+
if (buf->start == NULL) {
|
619
|
+
return NGX_CONF_ERROR;
|
620
|
+
}
|
621
|
+
|
622
|
+
buf->end = buf->start + size;
|
623
|
+
|
624
|
+
buf->pos = ngx_slprintf(buf->start, buf->end, "MEMLOG %uz %V:%ui%N",
|
625
|
+
size, &cf->conf_file->file.name,
|
626
|
+
cf->conf_file->line);
|
627
|
+
|
628
|
+
ngx_memset(buf->pos, ' ', buf->end - buf->pos);
|
629
|
+
|
630
|
+
cln = ngx_pool_cleanup_add(cf->pool, 0);
|
631
|
+
if (cln == NULL) {
|
632
|
+
return NGX_CONF_ERROR;
|
633
|
+
}
|
634
|
+
|
635
|
+
cln->data = new_log;
|
636
|
+
cln->handler = ngx_log_memory_cleanup;
|
637
|
+
|
638
|
+
new_log->writer = ngx_log_memory_writer;
|
639
|
+
new_log->wdata = buf;
|
512
640
|
|
513
|
-
|
514
|
-
|
641
|
+
#else
|
642
|
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
|
643
|
+
"nginx was built without debug support");
|
515
644
|
return NGX_CONF_ERROR;
|
645
|
+
#endif
|
646
|
+
|
647
|
+
} else if (ngx_strncmp(value[1].data, "syslog:", 7) == 0) {
|
648
|
+
peer = ngx_pcalloc(cf->pool, sizeof(ngx_syslog_peer_t));
|
649
|
+
if (peer == NULL) {
|
650
|
+
return NGX_CONF_ERROR;
|
651
|
+
}
|
652
|
+
|
653
|
+
if (ngx_syslog_process_conf(cf, peer) != NGX_CONF_OK) {
|
654
|
+
return NGX_CONF_ERROR;
|
655
|
+
}
|
656
|
+
|
657
|
+
new_log->writer = ngx_syslog_writer;
|
658
|
+
new_log->wdata = peer;
|
659
|
+
|
660
|
+
} else {
|
661
|
+
new_log->file = ngx_conf_open_file(cf->cycle, &value[1]);
|
662
|
+
if (new_log->file == NULL) {
|
663
|
+
return NGX_CONF_ERROR;
|
664
|
+
}
|
516
665
|
}
|
517
666
|
|
518
667
|
if (ngx_log_set_levels(cf, new_log) != NGX_CONF_OK) {
|
@@ -559,3 +708,48 @@ ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log)
|
|
559
708
|
|
560
709
|
log->next = new_log;
|
561
710
|
}
|
711
|
+
|
712
|
+
|
713
|
+
#if (NGX_DEBUG)
|
714
|
+
|
715
|
+
static void
|
716
|
+
ngx_log_memory_writer(ngx_log_t *log, ngx_uint_t level, u_char *buf,
|
717
|
+
size_t len)
|
718
|
+
{
|
719
|
+
u_char *p;
|
720
|
+
size_t avail, written;
|
721
|
+
ngx_log_memory_buf_t *mem;
|
722
|
+
|
723
|
+
mem = log->wdata;
|
724
|
+
|
725
|
+
if (mem == NULL) {
|
726
|
+
return;
|
727
|
+
}
|
728
|
+
|
729
|
+
written = ngx_atomic_fetch_add(&mem->written, len);
|
730
|
+
|
731
|
+
p = mem->pos + written % (mem->end - mem->pos);
|
732
|
+
|
733
|
+
avail = mem->end - p;
|
734
|
+
|
735
|
+
if (avail >= len) {
|
736
|
+
ngx_memcpy(p, buf, len);
|
737
|
+
|
738
|
+
} else {
|
739
|
+
ngx_memcpy(p, buf, avail);
|
740
|
+
ngx_memcpy(mem->pos, buf + avail, len - avail);
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
|
745
|
+
static void
|
746
|
+
ngx_log_memory_cleanup(void *data)
|
747
|
+
{
|
748
|
+
ngx_log_t *log = data;
|
749
|
+
|
750
|
+
ngx_log_debug0(NGX_LOG_DEBUG_CORE, log, 0, "destroy memory log buffer");
|
751
|
+
|
752
|
+
log->wdata = NULL;
|
753
|
+
}
|
754
|
+
|
755
|
+
#endif
|