Mercurial > hg > nginx
comparison src/http/modules/ngx_http_log_module.c @ 5833:e3016ee8dba3
Access log: fixed the "if=" parameter with buffering (ticket #625).
It might not work if there were more than one "access_log" directives
pointed to the same file and duplicate buffer parameters.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Sat, 13 Sep 2014 21:47:13 +0400 |
parents | b1f8285297a7 |
children | dff86e2246a5 |
comparison
equal
deleted
inserted
replaced
5832:d09b689911ac | 5833:e3016ee8dba3 |
---|---|
1134 | 1134 |
1135 ssize_t size; | 1135 ssize_t size; |
1136 ngx_int_t gzip; | 1136 ngx_int_t gzip; |
1137 ngx_uint_t i, n; | 1137 ngx_uint_t i, n; |
1138 ngx_msec_t flush; | 1138 ngx_msec_t flush; |
1139 ngx_str_t *value, name, s, filter; | 1139 ngx_str_t *value, name, s; |
1140 ngx_http_log_t *log; | 1140 ngx_http_log_t *log; |
1141 ngx_syslog_peer_t *peer; | 1141 ngx_syslog_peer_t *peer; |
1142 ngx_http_log_buf_t *buffer; | 1142 ngx_http_log_buf_t *buffer; |
1143 ngx_http_log_fmt_t *fmt; | 1143 ngx_http_log_fmt_t *fmt; |
1144 ngx_http_log_main_conf_t *lmcf; | 1144 ngx_http_log_main_conf_t *lmcf; |
1255 } | 1255 } |
1256 | 1256 |
1257 size = 0; | 1257 size = 0; |
1258 flush = 0; | 1258 flush = 0; |
1259 gzip = 0; | 1259 gzip = 0; |
1260 filter.len = 0; | |
1261 | 1260 |
1262 for (i = 3; i < cf->args->nelts; i++) { | 1261 for (i = 3; i < cf->args->nelts; i++) { |
1263 | 1262 |
1264 if (ngx_strncmp(value[i].data, "buffer=", 7) == 0) { | 1263 if (ngx_strncmp(value[i].data, "buffer=", 7) == 0) { |
1265 s.len = value[i].len - 7; | 1264 s.len = value[i].len - 7; |
1323 return NGX_CONF_ERROR; | 1322 return NGX_CONF_ERROR; |
1324 #endif | 1323 #endif |
1325 } | 1324 } |
1326 | 1325 |
1327 if (ngx_strncmp(value[i].data, "if=", 3) == 0) { | 1326 if (ngx_strncmp(value[i].data, "if=", 3) == 0) { |
1328 filter.len = value[i].len - 3; | 1327 s.len = value[i].len - 3; |
1329 filter.data = value[i].data + 3; | 1328 s.data = value[i].data + 3; |
1329 | |
1330 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
1331 | |
1332 ccv.cf = cf; | |
1333 ccv.value = &s; | |
1334 ccv.complex_value = ngx_palloc(cf->pool, | |
1335 sizeof(ngx_http_complex_value_t)); | |
1336 if (ccv.complex_value == NULL) { | |
1337 return NGX_CONF_ERROR; | |
1338 } | |
1339 | |
1340 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
1341 return NGX_CONF_ERROR; | |
1342 } | |
1343 | |
1344 log->filter = ccv.complex_value; | |
1345 | |
1330 continue; | 1346 continue; |
1331 } | 1347 } |
1332 | 1348 |
1333 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 1349 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
1334 "invalid parameter \"%V\"", &value[i]); | 1350 "invalid parameter \"%V\"", &value[i]); |
1403 | 1419 |
1404 log->file->flush = ngx_http_log_flush; | 1420 log->file->flush = ngx_http_log_flush; |
1405 log->file->data = buffer; | 1421 log->file->data = buffer; |
1406 } | 1422 } |
1407 | 1423 |
1408 if (filter.len) { | |
1409 log->filter = ngx_palloc(cf->pool, sizeof(ngx_http_complex_value_t)); | |
1410 if (log->filter == NULL) { | |
1411 return NGX_CONF_ERROR; | |
1412 } | |
1413 | |
1414 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
1415 | |
1416 ccv.cf = cf; | |
1417 ccv.value = &filter; | |
1418 ccv.complex_value = log->filter; | |
1419 | |
1420 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
1421 return NGX_CONF_ERROR; | |
1422 } | |
1423 } | |
1424 | |
1425 return NGX_CONF_OK; | 1424 return NGX_CONF_OK; |
1426 } | 1425 } |
1427 | 1426 |
1428 | 1427 |
1429 static char * | 1428 static char * |