nginxtra 1.0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (363) hide show
  1. data/VERSION +1 -0
  2. data/bin/nginxtra +5 -0
  3. data/lib/nginxtra.rb +12 -0
  4. data/lib/nginxtra/action.rb +36 -0
  5. data/lib/nginxtra/actions/compile.rb +60 -0
  6. data/lib/nginxtra/actions/install.rb +99 -0
  7. data/lib/nginxtra/actions/reload.rb +14 -0
  8. data/lib/nginxtra/actions/restart.rb +15 -0
  9. data/lib/nginxtra/actions/start.rb +53 -0
  10. data/lib/nginxtra/actions/status.rb +31 -0
  11. data/lib/nginxtra/actions/stop.rb +14 -0
  12. data/lib/nginxtra/cli.rb +77 -0
  13. data/lib/nginxtra/config.rb +339 -0
  14. data/lib/nginxtra/error.rb +13 -0
  15. data/lib/nginxtra/status.rb +57 -0
  16. data/src/nginx/CHANGES +5630 -0
  17. data/src/nginx/CHANGES.ru +5716 -0
  18. data/src/nginx/LICENSE +25 -0
  19. data/src/nginx/README +3 -0
  20. data/src/nginx/auto/cc/acc +15 -0
  21. data/src/nginx/auto/cc/bcc +72 -0
  22. data/src/nginx/auto/cc/ccc +46 -0
  23. data/src/nginx/auto/cc/conf +189 -0
  24. data/src/nginx/auto/cc/gcc +183 -0
  25. data/src/nginx/auto/cc/icc +121 -0
  26. data/src/nginx/auto/cc/msvc +138 -0
  27. data/src/nginx/auto/cc/name +101 -0
  28. data/src/nginx/auto/cc/owc +104 -0
  29. data/src/nginx/auto/cc/sunc +158 -0
  30. data/src/nginx/auto/define +12 -0
  31. data/src/nginx/auto/endianess +45 -0
  32. data/src/nginx/auto/feature +123 -0
  33. data/src/nginx/auto/have +12 -0
  34. data/src/nginx/auto/have_headers +12 -0
  35. data/src/nginx/auto/headers +13 -0
  36. data/src/nginx/auto/include +61 -0
  37. data/src/nginx/auto/init +51 -0
  38. data/src/nginx/auto/install +184 -0
  39. data/src/nginx/auto/lib/conf +83 -0
  40. data/src/nginx/auto/lib/geoip/conf +79 -0
  41. data/src/nginx/auto/lib/google-perftools/conf +45 -0
  42. data/src/nginx/auto/lib/libatomic/conf +43 -0
  43. data/src/nginx/auto/lib/libatomic/make +14 -0
  44. data/src/nginx/auto/lib/libgd/conf +83 -0
  45. data/src/nginx/auto/lib/libxslt/conf +156 -0
  46. data/src/nginx/auto/lib/make +32 -0
  47. data/src/nginx/auto/lib/md5/conf +103 -0
  48. data/src/nginx/auto/lib/md5/make +96 -0
  49. data/src/nginx/auto/lib/md5/makefile.bcc +22 -0
  50. data/src/nginx/auto/lib/md5/makefile.msvc +22 -0
  51. data/src/nginx/auto/lib/md5/makefile.owc +11 -0
  52. data/src/nginx/auto/lib/openssl/conf +74 -0
  53. data/src/nginx/auto/lib/openssl/make +67 -0
  54. data/src/nginx/auto/lib/openssl/makefile.bcc +18 -0
  55. data/src/nginx/auto/lib/openssl/makefile.msvc +14 -0
  56. data/src/nginx/auto/lib/pcre/conf +180 -0
  57. data/src/nginx/auto/lib/pcre/make +64 -0
  58. data/src/nginx/auto/lib/pcre/makefile.bcc +26 -0
  59. data/src/nginx/auto/lib/pcre/makefile.msvc +22 -0
  60. data/src/nginx/auto/lib/pcre/makefile.owc +24 -0
  61. data/src/nginx/auto/lib/perl/conf +60 -0
  62. data/src/nginx/auto/lib/perl/make +36 -0
  63. data/src/nginx/auto/lib/sha1/conf +79 -0
  64. data/src/nginx/auto/lib/sha1/make +96 -0
  65. data/src/nginx/auto/lib/sha1/makefile.bcc +22 -0
  66. data/src/nginx/auto/lib/sha1/makefile.msvc +22 -0
  67. data/src/nginx/auto/lib/sha1/makefile.owc +11 -0
  68. data/src/nginx/auto/lib/test +40 -0
  69. data/src/nginx/auto/lib/zlib/conf +76 -0
  70. data/src/nginx/auto/lib/zlib/make +114 -0
  71. data/src/nginx/auto/lib/zlib/makefile.bcc +15 -0
  72. data/src/nginx/auto/lib/zlib/makefile.msvc +14 -0
  73. data/src/nginx/auto/lib/zlib/makefile.owc +14 -0
  74. data/src/nginx/auto/lib/zlib/patch.zlib.h +10 -0
  75. data/src/nginx/auto/make +417 -0
  76. data/src/nginx/auto/modules +479 -0
  77. data/src/nginx/auto/nohave +12 -0
  78. data/src/nginx/auto/options +490 -0
  79. data/src/nginx/auto/os/conf +105 -0
  80. data/src/nginx/auto/os/darwin +116 -0
  81. data/src/nginx/auto/os/freebsd +136 -0
  82. data/src/nginx/auto/os/linux +152 -0
  83. data/src/nginx/auto/os/solaris +60 -0
  84. data/src/nginx/auto/os/win32 +29 -0
  85. data/src/nginx/auto/sources +518 -0
  86. data/src/nginx/auto/stubs +8 -0
  87. data/src/nginx/auto/summary +114 -0
  88. data/src/nginx/auto/types/sizeof +83 -0
  89. data/src/nginx/auto/types/typedef +77 -0
  90. data/src/nginx/auto/types/uintptr_t +42 -0
  91. data/src/nginx/auto/types/value +12 -0
  92. data/src/nginx/auto/unix +719 -0
  93. data/src/nginx/conf/fastcgi.conf +24 -0
  94. data/src/nginx/conf/fastcgi_params +23 -0
  95. data/src/nginx/conf/koi-utf +109 -0
  96. data/src/nginx/conf/koi-win +103 -0
  97. data/src/nginx/conf/mime.types +80 -0
  98. data/src/nginx/conf/nginx.conf +118 -0
  99. data/src/nginx/conf/scgi_params +15 -0
  100. data/src/nginx/conf/uwsgi_params +15 -0
  101. data/src/nginx/conf/win-utf +126 -0
  102. data/src/nginx/configure +108 -0
  103. data/src/nginx/contrib/README +15 -0
  104. data/src/nginx/contrib/geo2nginx.pl +58 -0
  105. data/src/nginx/contrib/unicode2nginx/koi-utf +131 -0
  106. data/src/nginx/contrib/unicode2nginx/unicode-to-nginx.pl +45 -0
  107. data/src/nginx/contrib/unicode2nginx/win-utf +130 -0
  108. data/src/nginx/html/50x.html +18 -0
  109. data/src/nginx/html/index.html +8 -0
  110. data/src/nginx/man/nginx.8 +202 -0
  111. data/src/nginx/src/core/nginx.c +1333 -0
  112. data/src/nginx/src/core/nginx.h +20 -0
  113. data/src/nginx/src/core/ngx_array.c +147 -0
  114. data/src/nginx/src/core/ngx_array.h +53 -0
  115. data/src/nginx/src/core/ngx_buf.c +218 -0
  116. data/src/nginx/src/core/ngx_buf.h +162 -0
  117. data/src/nginx/src/core/ngx_conf_file.c +1506 -0
  118. data/src/nginx/src/core/ngx_conf_file.h +348 -0
  119. data/src/nginx/src/core/ngx_config.h +134 -0
  120. data/src/nginx/src/core/ngx_connection.c +1074 -0
  121. data/src/nginx/src/core/ngx_connection.h +195 -0
  122. data/src/nginx/src/core/ngx_core.h +95 -0
  123. data/src/nginx/src/core/ngx_cpuinfo.c +139 -0
  124. data/src/nginx/src/core/ngx_crc.h +39 -0
  125. data/src/nginx/src/core/ngx_crc32.c +129 -0
  126. data/src/nginx/src/core/ngx_crc32.h +79 -0
  127. data/src/nginx/src/core/ngx_crypt.c +238 -0
  128. data/src/nginx/src/core/ngx_crypt.h +20 -0
  129. data/src/nginx/src/core/ngx_cycle.c +1379 -0
  130. data/src/nginx/src/core/ngx_cycle.h +142 -0
  131. data/src/nginx/src/core/ngx_file.c +993 -0
  132. data/src/nginx/src/core/ngx_file.h +151 -0
  133. data/src/nginx/src/core/ngx_hash.c +976 -0
  134. data/src/nginx/src/core/ngx_hash.h +122 -0
  135. data/src/nginx/src/core/ngx_inet.c +1008 -0
  136. data/src/nginx/src/core/ngx_inet.h +120 -0
  137. data/src/nginx/src/core/ngx_list.c +71 -0
  138. data/src/nginx/src/core/ngx_list.h +83 -0
  139. data/src/nginx/src/core/ngx_log.c +459 -0
  140. data/src/nginx/src/core/ngx_log.h +250 -0
  141. data/src/nginx/src/core/ngx_md5.c +289 -0
  142. data/src/nginx/src/core/ngx_md5.h +60 -0
  143. data/src/nginx/src/core/ngx_murmurhash.c +50 -0
  144. data/src/nginx/src/core/ngx_murmurhash.h +19 -0
  145. data/src/nginx/src/core/ngx_open_file_cache.c +882 -0
  146. data/src/nginx/src/core/ngx_open_file_cache.h +119 -0
  147. data/src/nginx/src/core/ngx_output_chain.c +673 -0
  148. data/src/nginx/src/core/ngx_palloc.c +433 -0
  149. data/src/nginx/src/core/ngx_palloc.h +95 -0
  150. data/src/nginx/src/core/ngx_parse.c +249 -0
  151. data/src/nginx/src/core/ngx_parse.h +24 -0
  152. data/src/nginx/src/core/ngx_queue.c +80 -0
  153. data/src/nginx/src/core/ngx_queue.h +112 -0
  154. data/src/nginx/src/core/ngx_radix_tree.c +291 -0
  155. data/src/nginx/src/core/ngx_radix_tree.h +46 -0
  156. data/src/nginx/src/core/ngx_rbtree.c +383 -0
  157. data/src/nginx/src/core/ngx_rbtree.h +84 -0
  158. data/src/nginx/src/core/ngx_regex.c +206 -0
  159. data/src/nginx/src/core/ngx_regex.h +56 -0
  160. data/src/nginx/src/core/ngx_resolver.c +2201 -0
  161. data/src/nginx/src/core/ngx_resolver.h +149 -0
  162. data/src/nginx/src/core/ngx_sha1.h +31 -0
  163. data/src/nginx/src/core/ngx_shmtx.c +284 -0
  164. data/src/nginx/src/core/ngx_shmtx.h +38 -0
  165. data/src/nginx/src/core/ngx_slab.c +701 -0
  166. data/src/nginx/src/core/ngx_slab.h +54 -0
  167. data/src/nginx/src/core/ngx_spinlock.c +53 -0
  168. data/src/nginx/src/core/ngx_string.c +1837 -0
  169. data/src/nginx/src/core/ngx_string.h +231 -0
  170. data/src/nginx/src/core/ngx_times.c +407 -0
  171. data/src/nginx/src/core/ngx_times.h +51 -0
  172. data/src/nginx/src/event/modules/ngx_aio_module.c +171 -0
  173. data/src/nginx/src/event/modules/ngx_devpoll_module.c +569 -0
  174. data/src/nginx/src/event/modules/ngx_epoll_module.c +833 -0
  175. data/src/nginx/src/event/modules/ngx_eventport_module.c +602 -0
  176. data/src/nginx/src/event/modules/ngx_kqueue_module.c +785 -0
  177. data/src/nginx/src/event/modules/ngx_poll_module.c +443 -0
  178. data/src/nginx/src/event/modules/ngx_rtsig_module.c +735 -0
  179. data/src/nginx/src/event/modules/ngx_select_module.c +435 -0
  180. data/src/nginx/src/event/modules/ngx_win32_select_module.c +400 -0
  181. data/src/nginx/src/event/ngx_event.c +1275 -0
  182. data/src/nginx/src/event/ngx_event.h +573 -0
  183. data/src/nginx/src/event/ngx_event_accept.c +428 -0
  184. data/src/nginx/src/event/ngx_event_busy_lock.c +286 -0
  185. data/src/nginx/src/event/ngx_event_busy_lock.h +65 -0
  186. data/src/nginx/src/event/ngx_event_connect.c +258 -0
  187. data/src/nginx/src/event/ngx_event_connect.h +76 -0
  188. data/src/nginx/src/event/ngx_event_mutex.c +70 -0
  189. data/src/nginx/src/event/ngx_event_openssl.c +2382 -0
  190. data/src/nginx/src/event/ngx_event_openssl.h +162 -0
  191. data/src/nginx/src/event/ngx_event_pipe.c +996 -0
  192. data/src/nginx/src/event/ngx_event_pipe.h +95 -0
  193. data/src/nginx/src/event/ngx_event_posted.c +173 -0
  194. data/src/nginx/src/event/ngx_event_posted.h +75 -0
  195. data/src/nginx/src/event/ngx_event_timer.c +159 -0
  196. data/src/nginx/src/event/ngx_event_timer.h +102 -0
  197. data/src/nginx/src/http/modules/ngx_http_access_module.c +384 -0
  198. data/src/nginx/src/http/modules/ngx_http_addition_filter_module.c +250 -0
  199. data/src/nginx/src/http/modules/ngx_http_auth_basic_module.c +478 -0
  200. data/src/nginx/src/http/modules/ngx_http_autoindex_module.c +701 -0
  201. data/src/nginx/src/http/modules/ngx_http_browser_module.c +713 -0
  202. data/src/nginx/src/http/modules/ngx_http_charset_filter_module.c +1681 -0
  203. data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +242 -0
  204. data/src/nginx/src/http/modules/ngx_http_dav_module.c +1141 -0
  205. data/src/nginx/src/http/modules/ngx_http_degradation_module.c +243 -0
  206. data/src/nginx/src/http/modules/ngx_http_empty_gif_module.c +140 -0
  207. data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +2916 -0
  208. data/src/nginx/src/http/modules/ngx_http_flv_module.c +254 -0
  209. data/src/nginx/src/http/modules/ngx_http_geo_module.c +1441 -0
  210. data/src/nginx/src/http/modules/ngx_http_geoip_module.c +671 -0
  211. data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +1206 -0
  212. data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +299 -0
  213. data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +616 -0
  214. data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1489 -0
  215. data/src/nginx/src/http/modules/ngx_http_index_module.c +516 -0
  216. data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +809 -0
  217. data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +553 -0
  218. data/src/nginx/src/http/modules/ngx_http_log_module.c +1357 -0
  219. data/src/nginx/src/http/modules/ngx_http_map_module.c +575 -0
  220. data/src/nginx/src/http/modules/ngx_http_memcached_module.c +624 -0
  221. data/src/nginx/src/http/modules/ngx_http_mp4_module.c +3000 -0
  222. data/src/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +143 -0
  223. data/src/nginx/src/http/modules/ngx_http_proxy_module.c +2831 -0
  224. data/src/nginx/src/http/modules/ngx_http_random_index_module.c +317 -0
  225. data/src/nginx/src/http/modules/ngx_http_range_filter_module.c +855 -0
  226. data/src/nginx/src/http/modules/ngx_http_realip_module.c +476 -0
  227. data/src/nginx/src/http/modules/ngx_http_referer_module.c +613 -0
  228. data/src/nginx/src/http/modules/ngx_http_rewrite_module.c +1019 -0
  229. data/src/nginx/src/http/modules/ngx_http_scgi_module.c +1714 -0
  230. data/src/nginx/src/http/modules/ngx_http_secure_link_module.c +355 -0
  231. data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +242 -0
  232. data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +2913 -0
  233. data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.h +114 -0
  234. data/src/nginx/src/http/modules/ngx_http_ssl_module.c +652 -0
  235. data/src/nginx/src/http/modules/ngx_http_ssl_module.h +52 -0
  236. data/src/nginx/src/http/modules/ngx_http_static_module.c +278 -0
  237. data/src/nginx/src/http/modules/ngx_http_stub_status_module.c +144 -0
  238. data/src/nginx/src/http/modules/ngx_http_sub_filter_module.c +716 -0
  239. data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +237 -0
  240. data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +846 -0
  241. data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +1774 -0
  242. data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +984 -0
  243. data/src/nginx/src/http/modules/perl/Makefile.PL +42 -0
  244. data/src/nginx/src/http/modules/perl/nginx.pm +137 -0
  245. data/src/nginx/src/http/modules/perl/nginx.xs +986 -0
  246. data/src/nginx/src/http/modules/perl/ngx_http_perl_module.c +1076 -0
  247. data/src/nginx/src/http/modules/perl/ngx_http_perl_module.h +67 -0
  248. data/src/nginx/src/http/modules/perl/typemap +3 -0
  249. data/src/nginx/src/http/ngx_http.c +2073 -0
  250. data/src/nginx/src/http/ngx_http.h +160 -0
  251. data/src/nginx/src/http/ngx_http_busy_lock.c +307 -0
  252. data/src/nginx/src/http/ngx_http_busy_lock.h +54 -0
  253. data/src/nginx/src/http/ngx_http_cache.h +148 -0
  254. data/src/nginx/src/http/ngx_http_config.h +75 -0
  255. data/src/nginx/src/http/ngx_http_copy_filter_module.c +300 -0
  256. data/src/nginx/src/http/ngx_http_core_module.c +4736 -0
  257. data/src/nginx/src/http/ngx_http_core_module.h +541 -0
  258. data/src/nginx/src/http/ngx_http_file_cache.c +1715 -0
  259. data/src/nginx/src/http/ngx_http_header_filter_module.c +623 -0
  260. data/src/nginx/src/http/ngx_http_parse.c +1734 -0
  261. data/src/nginx/src/http/ngx_http_parse_time.c +276 -0
  262. data/src/nginx/src/http/ngx_http_postpone_filter_module.c +178 -0
  263. data/src/nginx/src/http/ngx_http_request.c +3181 -0
  264. data/src/nginx/src/http/ngx_http_request.h +573 -0
  265. data/src/nginx/src/http/ngx_http_request_body.c +644 -0
  266. data/src/nginx/src/http/ngx_http_script.c +1752 -0
  267. data/src/nginx/src/http/ngx_http_script.h +257 -0
  268. data/src/nginx/src/http/ngx_http_special_response.c +789 -0
  269. data/src/nginx/src/http/ngx_http_upstream.c +4555 -0
  270. data/src/nginx/src/http/ngx_http_upstream.h +350 -0
  271. data/src/nginx/src/http/ngx_http_upstream_round_robin.c +791 -0
  272. data/src/nginx/src/http/ngx_http_upstream_round_robin.h +85 -0
  273. data/src/nginx/src/http/ngx_http_variables.c +2053 -0
  274. data/src/nginx/src/http/ngx_http_variables.h +115 -0
  275. data/src/nginx/src/http/ngx_http_write_filter_module.c +315 -0
  276. data/src/nginx/src/mail/ngx_mail.c +542 -0
  277. data/src/nginx/src/mail/ngx_mail.h +407 -0
  278. data/src/nginx/src/mail/ngx_mail_auth_http_module.c +1452 -0
  279. data/src/nginx/src/mail/ngx_mail_core_module.c +553 -0
  280. data/src/nginx/src/mail/ngx_mail_handler.c +773 -0
  281. data/src/nginx/src/mail/ngx_mail_imap_handler.c +457 -0
  282. data/src/nginx/src/mail/ngx_mail_imap_module.c +253 -0
  283. data/src/nginx/src/mail/ngx_mail_imap_module.h +39 -0
  284. data/src/nginx/src/mail/ngx_mail_parse.c +885 -0
  285. data/src/nginx/src/mail/ngx_mail_pop3_handler.c +500 -0
  286. data/src/nginx/src/mail/ngx_mail_pop3_module.c +264 -0
  287. data/src/nginx/src/mail/ngx_mail_pop3_module.h +38 -0
  288. data/src/nginx/src/mail/ngx_mail_proxy_module.c +1089 -0
  289. data/src/nginx/src/mail/ngx_mail_smtp_handler.c +872 -0
  290. data/src/nginx/src/mail/ngx_mail_smtp_module.c +308 -0
  291. data/src/nginx/src/mail/ngx_mail_smtp_module.h +45 -0
  292. data/src/nginx/src/mail/ngx_mail_ssl_module.c +491 -0
  293. data/src/nginx/src/mail/ngx_mail_ssl_module.h +52 -0
  294. data/src/nginx/src/misc/ngx_cpp_test_module.cpp +27 -0
  295. data/src/nginx/src/misc/ngx_google_perftools_module.c +126 -0
  296. data/src/nginx/src/os/unix/ngx_aio_read.c +109 -0
  297. data/src/nginx/src/os/unix/ngx_aio_read_chain.c +78 -0
  298. data/src/nginx/src/os/unix/ngx_aio_write.c +109 -0
  299. data/src/nginx/src/os/unix/ngx_aio_write_chain.c +100 -0
  300. data/src/nginx/src/os/unix/ngx_alloc.c +90 -0
  301. data/src/nginx/src/os/unix/ngx_alloc.h +45 -0
  302. data/src/nginx/src/os/unix/ngx_atomic.h +311 -0
  303. data/src/nginx/src/os/unix/ngx_channel.c +258 -0
  304. data/src/nginx/src/os/unix/ngx_channel.h +34 -0
  305. data/src/nginx/src/os/unix/ngx_daemon.c +69 -0
  306. data/src/nginx/src/os/unix/ngx_darwin.h +20 -0
  307. data/src/nginx/src/os/unix/ngx_darwin_config.h +96 -0
  308. data/src/nginx/src/os/unix/ngx_darwin_init.c +166 -0
  309. data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +366 -0
  310. data/src/nginx/src/os/unix/ngx_errno.c +87 -0
  311. data/src/nginx/src/os/unix/ngx_errno.h +68 -0
  312. data/src/nginx/src/os/unix/ngx_file_aio_read.c +208 -0
  313. data/src/nginx/src/os/unix/ngx_files.c +566 -0
  314. data/src/nginx/src/os/unix/ngx_files.h +343 -0
  315. data/src/nginx/src/os/unix/ngx_freebsd.h +24 -0
  316. data/src/nginx/src/os/unix/ngx_freebsd_config.h +119 -0
  317. data/src/nginx/src/os/unix/ngx_freebsd_init.c +259 -0
  318. data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +756 -0
  319. data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +122 -0
  320. data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +436 -0
  321. data/src/nginx/src/os/unix/ngx_gcc_atomic_amd64.h +82 -0
  322. data/src/nginx/src/os/unix/ngx_gcc_atomic_ppc.h +155 -0
  323. data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +82 -0
  324. data/src/nginx/src/os/unix/ngx_gcc_atomic_x86.h +127 -0
  325. data/src/nginx/src/os/unix/ngx_linux.h +18 -0
  326. data/src/nginx/src/os/unix/ngx_linux_aio_read.c +137 -0
  327. data/src/nginx/src/os/unix/ngx_linux_config.h +117 -0
  328. data/src/nginx/src/os/unix/ngx_linux_init.c +91 -0
  329. data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +378 -0
  330. data/src/nginx/src/os/unix/ngx_os.h +84 -0
  331. data/src/nginx/src/os/unix/ngx_posix_config.h +153 -0
  332. data/src/nginx/src/os/unix/ngx_posix_init.c +124 -0
  333. data/src/nginx/src/os/unix/ngx_process.c +590 -0
  334. data/src/nginx/src/os/unix/ngx_process.h +87 -0
  335. data/src/nginx/src/os/unix/ngx_process_cycle.c +1390 -0
  336. data/src/nginx/src/os/unix/ngx_process_cycle.h +61 -0
  337. data/src/nginx/src/os/unix/ngx_pthread_thread.c +278 -0
  338. data/src/nginx/src/os/unix/ngx_readv_chain.c +258 -0
  339. data/src/nginx/src/os/unix/ngx_recv.c +180 -0
  340. data/src/nginx/src/os/unix/ngx_send.c +73 -0
  341. data/src/nginx/src/os/unix/ngx_setproctitle.c +135 -0
  342. data/src/nginx/src/os/unix/ngx_setproctitle.h +52 -0
  343. data/src/nginx/src/os/unix/ngx_shmem.c +126 -0
  344. data/src/nginx/src/os/unix/ngx_shmem.h +29 -0
  345. data/src/nginx/src/os/unix/ngx_socket.c +116 -0
  346. data/src/nginx/src/os/unix/ngx_socket.h +64 -0
  347. data/src/nginx/src/os/unix/ngx_solaris.h +16 -0
  348. data/src/nginx/src/os/unix/ngx_solaris_config.h +107 -0
  349. data/src/nginx/src/os/unix/ngx_solaris_init.c +75 -0
  350. data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +251 -0
  351. data/src/nginx/src/os/unix/ngx_sunpro_amd64.il +43 -0
  352. data/src/nginx/src/os/unix/ngx_sunpro_atomic_sparc64.h +61 -0
  353. data/src/nginx/src/os/unix/ngx_sunpro_sparc64.il +36 -0
  354. data/src/nginx/src/os/unix/ngx_sunpro_x86.il +44 -0
  355. data/src/nginx/src/os/unix/ngx_thread.h +128 -0
  356. data/src/nginx/src/os/unix/ngx_time.c +104 -0
  357. data/src/nginx/src/os/unix/ngx_time.h +66 -0
  358. data/src/nginx/src/os/unix/ngx_udp_recv.c +115 -0
  359. data/src/nginx/src/os/unix/ngx_user.c +109 -0
  360. data/src/nginx/src/os/unix/ngx_user.h +24 -0
  361. data/src/nginx/src/os/unix/ngx_writev_chain.c +181 -0
  362. data/src/nginx/src/os/unix/rfork_thread.S +73 -0
  363. metadata +419 -0
@@ -0,0 +1,1357 @@
1
+
2
+ /*
3
+ * Copyright (C) Igor Sysoev
4
+ * Copyright (C) Nginx, Inc.
5
+ */
6
+
7
+
8
+ #include <ngx_config.h>
9
+ #include <ngx_core.h>
10
+ #include <ngx_http.h>
11
+
12
+
13
+ typedef struct ngx_http_log_op_s ngx_http_log_op_t;
14
+
15
+ typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf,
16
+ ngx_http_log_op_t *op);
17
+
18
+ typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r,
19
+ uintptr_t data);
20
+
21
+
22
+ struct ngx_http_log_op_s {
23
+ size_t len;
24
+ ngx_http_log_op_getlen_pt getlen;
25
+ ngx_http_log_op_run_pt run;
26
+ uintptr_t data;
27
+ };
28
+
29
+
30
+ typedef struct {
31
+ ngx_str_t name;
32
+ ngx_array_t *flushes;
33
+ ngx_array_t *ops; /* array of ngx_http_log_op_t */
34
+ } ngx_http_log_fmt_t;
35
+
36
+
37
+ typedef struct {
38
+ ngx_array_t formats; /* array of ngx_http_log_fmt_t */
39
+ ngx_uint_t combined_used; /* unsigned combined_used:1 */
40
+ } ngx_http_log_main_conf_t;
41
+
42
+
43
+ typedef struct {
44
+ ngx_array_t *lengths;
45
+ ngx_array_t *values;
46
+ } ngx_http_log_script_t;
47
+
48
+
49
+ typedef struct {
50
+ ngx_open_file_t *file;
51
+ ngx_http_log_script_t *script;
52
+ time_t disk_full_time;
53
+ time_t error_log_time;
54
+ ngx_http_log_fmt_t *format;
55
+ } ngx_http_log_t;
56
+
57
+
58
+ typedef struct {
59
+ ngx_array_t *logs; /* array of ngx_http_log_t */
60
+
61
+ ngx_open_file_cache_t *open_file_cache;
62
+ time_t open_file_cache_valid;
63
+ ngx_uint_t open_file_cache_min_uses;
64
+
65
+ ngx_uint_t off; /* unsigned off:1 */
66
+ } ngx_http_log_loc_conf_t;
67
+
68
+
69
+ typedef struct {
70
+ ngx_str_t name;
71
+ size_t len;
72
+ ngx_http_log_op_run_pt run;
73
+ } ngx_http_log_var_t;
74
+
75
+
76
+ static void ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log,
77
+ u_char *buf, size_t len);
78
+ static ssize_t ngx_http_log_script_write(ngx_http_request_t *r,
79
+ ngx_http_log_script_t *script, u_char **name, u_char *buf, size_t len);
80
+
81
+ static u_char *ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
82
+ ngx_http_log_op_t *op);
83
+ static u_char *ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf,
84
+ ngx_http_log_op_t *op);
85
+ static u_char *ngx_http_log_time(ngx_http_request_t *r, u_char *buf,
86
+ ngx_http_log_op_t *op);
87
+ static u_char *ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf,
88
+ ngx_http_log_op_t *op);
89
+ static u_char *ngx_http_log_msec(ngx_http_request_t *r, u_char *buf,
90
+ ngx_http_log_op_t *op);
91
+ static u_char *ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
92
+ ngx_http_log_op_t *op);
93
+ static u_char *ngx_http_log_status(ngx_http_request_t *r, u_char *buf,
94
+ ngx_http_log_op_t *op);
95
+ static u_char *ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
96
+ ngx_http_log_op_t *op);
97
+ static u_char *ngx_http_log_body_bytes_sent(ngx_http_request_t *r,
98
+ u_char *buf, ngx_http_log_op_t *op);
99
+ static u_char *ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
100
+ ngx_http_log_op_t *op);
101
+
102
+ static ngx_int_t ngx_http_log_variable_compile(ngx_conf_t *cf,
103
+ ngx_http_log_op_t *op, ngx_str_t *value);
104
+ static size_t ngx_http_log_variable_getlen(ngx_http_request_t *r,
105
+ uintptr_t data);
106
+ static u_char *ngx_http_log_variable(ngx_http_request_t *r, u_char *buf,
107
+ ngx_http_log_op_t *op);
108
+ static uintptr_t ngx_http_log_escape(u_char *dst, u_char *src, size_t size);
109
+
110
+
111
+ static void *ngx_http_log_create_main_conf(ngx_conf_t *cf);
112
+ static void *ngx_http_log_create_loc_conf(ngx_conf_t *cf);
113
+ static char *ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent,
114
+ void *child);
115
+ static char *ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd,
116
+ void *conf);
117
+ static char *ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd,
118
+ void *conf);
119
+ static char *ngx_http_log_compile_format(ngx_conf_t *cf,
120
+ ngx_array_t *flushes, ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s);
121
+ static char *ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd,
122
+ void *conf);
123
+ static ngx_int_t ngx_http_log_init(ngx_conf_t *cf);
124
+
125
+
126
+ static ngx_command_t ngx_http_log_commands[] = {
127
+
128
+ { ngx_string("log_format"),
129
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_2MORE,
130
+ ngx_http_log_set_format,
131
+ NGX_HTTP_MAIN_CONF_OFFSET,
132
+ 0,
133
+ NULL },
134
+
135
+ { ngx_string("access_log"),
136
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
137
+ |NGX_HTTP_LMT_CONF|NGX_CONF_TAKE123,
138
+ ngx_http_log_set_log,
139
+ NGX_HTTP_LOC_CONF_OFFSET,
140
+ 0,
141
+ NULL },
142
+
143
+ { ngx_string("open_log_file_cache"),
144
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1234,
145
+ ngx_http_log_open_file_cache,
146
+ NGX_HTTP_LOC_CONF_OFFSET,
147
+ 0,
148
+ NULL },
149
+
150
+ ngx_null_command
151
+ };
152
+
153
+
154
+ static ngx_http_module_t ngx_http_log_module_ctx = {
155
+ NULL, /* preconfiguration */
156
+ ngx_http_log_init, /* postconfiguration */
157
+
158
+ ngx_http_log_create_main_conf, /* create main configuration */
159
+ NULL, /* init main configuration */
160
+
161
+ NULL, /* create server configuration */
162
+ NULL, /* merge server configuration */
163
+
164
+ ngx_http_log_create_loc_conf, /* create location configuration */
165
+ ngx_http_log_merge_loc_conf /* merge location configuration */
166
+ };
167
+
168
+
169
+ ngx_module_t ngx_http_log_module = {
170
+ NGX_MODULE_V1,
171
+ &ngx_http_log_module_ctx, /* module context */
172
+ ngx_http_log_commands, /* module directives */
173
+ NGX_HTTP_MODULE, /* module type */
174
+ NULL, /* init master */
175
+ NULL, /* init module */
176
+ NULL, /* init process */
177
+ NULL, /* init thread */
178
+ NULL, /* exit thread */
179
+ NULL, /* exit process */
180
+ NULL, /* exit master */
181
+ NGX_MODULE_V1_PADDING
182
+ };
183
+
184
+
185
+ static ngx_str_t ngx_http_access_log = ngx_string(NGX_HTTP_LOG_PATH);
186
+
187
+
188
+ static ngx_str_t ngx_http_combined_fmt =
189
+ ngx_string("$remote_addr - $remote_user [$time_local] "
190
+ "\"$request\" $status $body_bytes_sent "
191
+ "\"$http_referer\" \"$http_user_agent\"");
192
+
193
+
194
+ static ngx_http_log_var_t ngx_http_log_vars[] = {
195
+ { ngx_string("connection"), NGX_ATOMIC_T_LEN, ngx_http_log_connection },
196
+ { ngx_string("pipe"), 1, ngx_http_log_pipe },
197
+ { ngx_string("time_local"), sizeof("28/Sep/1970:12:00:00 +0600") - 1,
198
+ ngx_http_log_time },
199
+ { ngx_string("time_iso8601"), sizeof("1970-09-28T12:00:00+06:00") - 1,
200
+ ngx_http_log_iso8601 },
201
+ { ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
202
+ { ngx_string("request_time"), NGX_TIME_T_LEN + 4,
203
+ ngx_http_log_request_time },
204
+ { ngx_string("status"), 3, ngx_http_log_status },
205
+ { ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
206
+ { ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
207
+ ngx_http_log_body_bytes_sent },
208
+ { ngx_string("apache_bytes_sent"), NGX_OFF_T_LEN,
209
+ ngx_http_log_body_bytes_sent },
210
+ { ngx_string("request_length"), NGX_SIZE_T_LEN,
211
+ ngx_http_log_request_length },
212
+
213
+ { ngx_null_string, 0, NULL }
214
+ };
215
+
216
+
217
+ ngx_int_t
218
+ ngx_http_log_handler(ngx_http_request_t *r)
219
+ {
220
+ u_char *line, *p;
221
+ size_t len;
222
+ ngx_uint_t i, l;
223
+ ngx_http_log_t *log;
224
+ ngx_open_file_t *file;
225
+ ngx_http_log_op_t *op;
226
+ ngx_http_log_loc_conf_t *lcf;
227
+
228
+ ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
229
+ "http log handler");
230
+
231
+ lcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
232
+
233
+ if (lcf->off) {
234
+ return NGX_OK;
235
+ }
236
+
237
+ log = lcf->logs->elts;
238
+ for (l = 0; l < lcf->logs->nelts; l++) {
239
+
240
+ if (ngx_time() == log[l].disk_full_time) {
241
+
242
+ /*
243
+ * on FreeBSD writing to a full filesystem with enabled softupdates
244
+ * may block process for much longer time than writing to non-full
245
+ * filesystem, so we skip writing to a log for one second
246
+ */
247
+
248
+ continue;
249
+ }
250
+
251
+ ngx_http_script_flush_no_cacheable_variables(r, log[l].format->flushes);
252
+
253
+ len = 0;
254
+ op = log[l].format->ops->elts;
255
+ for (i = 0; i < log[l].format->ops->nelts; i++) {
256
+ if (op[i].len == 0) {
257
+ len += op[i].getlen(r, op[i].data);
258
+
259
+ } else {
260
+ len += op[i].len;
261
+ }
262
+ }
263
+
264
+ len += NGX_LINEFEED_SIZE;
265
+
266
+ file = log[l].file;
267
+
268
+ if (file && file->buffer) {
269
+
270
+ if (len > (size_t) (file->last - file->pos)) {
271
+
272
+ ngx_http_log_write(r, &log[l], file->buffer,
273
+ file->pos - file->buffer);
274
+
275
+ file->pos = file->buffer;
276
+ }
277
+
278
+ if (len <= (size_t) (file->last - file->pos)) {
279
+
280
+ p = file->pos;
281
+
282
+ for (i = 0; i < log[l].format->ops->nelts; i++) {
283
+ p = op[i].run(r, p, &op[i]);
284
+ }
285
+
286
+ ngx_linefeed(p);
287
+
288
+ file->pos = p;
289
+
290
+ continue;
291
+ }
292
+ }
293
+
294
+ line = ngx_pnalloc(r->pool, len);
295
+ if (line == NULL) {
296
+ return NGX_ERROR;
297
+ }
298
+
299
+ p = line;
300
+
301
+ for (i = 0; i < log[l].format->ops->nelts; i++) {
302
+ p = op[i].run(r, p, &op[i]);
303
+ }
304
+
305
+ ngx_linefeed(p);
306
+
307
+ ngx_http_log_write(r, &log[l], line, p - line);
308
+ }
309
+
310
+ return NGX_OK;
311
+ }
312
+
313
+
314
+ static void
315
+ ngx_http_log_write(ngx_http_request_t *r, ngx_http_log_t *log, u_char *buf,
316
+ size_t len)
317
+ {
318
+ u_char *name;
319
+ time_t now;
320
+ ssize_t n;
321
+ ngx_err_t err;
322
+
323
+ if (log->script == NULL) {
324
+ name = log->file->name.data;
325
+ n = ngx_write_fd(log->file->fd, buf, len);
326
+
327
+ } else {
328
+ name = NULL;
329
+ n = ngx_http_log_script_write(r, log->script, &name, buf, len);
330
+ }
331
+
332
+ if (n == (ssize_t) len) {
333
+ return;
334
+ }
335
+
336
+ now = ngx_time();
337
+
338
+ if (n == -1) {
339
+ err = ngx_errno;
340
+
341
+ if (err == NGX_ENOSPC) {
342
+ log->disk_full_time = now;
343
+ }
344
+
345
+ if (now - log->error_log_time > 59) {
346
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, err,
347
+ ngx_write_fd_n " to \"%s\" failed", name);
348
+
349
+ log->error_log_time = now;
350
+ }
351
+
352
+ return;
353
+ }
354
+
355
+ if (now - log->error_log_time > 59) {
356
+ ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
357
+ ngx_write_fd_n " to \"%s\" was incomplete: %z of %uz",
358
+ name, n, len);
359
+
360
+ log->error_log_time = now;
361
+ }
362
+ }
363
+
364
+
365
+ static ssize_t
366
+ ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
367
+ u_char **name, u_char *buf, size_t len)
368
+ {
369
+ size_t root;
370
+ ssize_t n;
371
+ ngx_str_t log, path;
372
+ ngx_open_file_info_t of;
373
+ ngx_http_log_loc_conf_t *llcf;
374
+ ngx_http_core_loc_conf_t *clcf;
375
+
376
+ if (!r->root_tested) {
377
+
378
+ /* test root directory existence */
379
+
380
+ if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
381
+ /* simulate successful logging */
382
+ return len;
383
+ }
384
+
385
+ path.data[root] = '\0';
386
+
387
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
388
+
389
+ ngx_memzero(&of, sizeof(ngx_open_file_info_t));
390
+
391
+ of.valid = clcf->open_file_cache_valid;
392
+ of.min_uses = clcf->open_file_cache_min_uses;
393
+ of.test_dir = 1;
394
+ of.test_only = 1;
395
+ of.errors = clcf->open_file_cache_errors;
396
+ of.events = clcf->open_file_cache_events;
397
+
398
+ if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
399
+ != NGX_OK)
400
+ {
401
+ if (of.err == 0) {
402
+ /* simulate successful logging */
403
+ return len;
404
+ }
405
+
406
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, of.err,
407
+ "testing \"%s\" existence failed", path.data);
408
+
409
+ /* simulate successful logging */
410
+ return len;
411
+ }
412
+
413
+ if (!of.is_dir) {
414
+ ngx_log_error(NGX_LOG_ERR, r->connection->log, NGX_ENOTDIR,
415
+ "testing \"%s\" existence failed", path.data);
416
+
417
+ /* simulate successful logging */
418
+ return len;
419
+ }
420
+ }
421
+
422
+ if (ngx_http_script_run(r, &log, script->lengths->elts, 1,
423
+ script->values->elts)
424
+ == NULL)
425
+ {
426
+ /* simulate successful logging */
427
+ return len;
428
+ }
429
+
430
+ log.data[log.len - 1] = '\0';
431
+ *name = log.data;
432
+
433
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
434
+ "http log \"%s\"", log.data);
435
+
436
+ llcf = ngx_http_get_module_loc_conf(r, ngx_http_log_module);
437
+
438
+ ngx_memzero(&of, sizeof(ngx_open_file_info_t));
439
+
440
+ of.log = 1;
441
+ of.valid = llcf->open_file_cache_valid;
442
+ of.min_uses = llcf->open_file_cache_min_uses;
443
+ of.directio = NGX_OPEN_FILE_DIRECTIO_OFF;
444
+
445
+ if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
446
+ != NGX_OK)
447
+ {
448
+ ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
449
+ "%s \"%s\" failed", of.failed, log.data);
450
+ /* simulate successful logging */
451
+ return len;
452
+ }
453
+
454
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
455
+ "http log #%d", of.fd);
456
+
457
+ n = ngx_write_fd(of.fd, buf, len);
458
+
459
+ return n;
460
+ }
461
+
462
+
463
+ static u_char *
464
+ ngx_http_log_copy_short(ngx_http_request_t *r, u_char *buf,
465
+ ngx_http_log_op_t *op)
466
+ {
467
+ size_t len;
468
+ uintptr_t data;
469
+
470
+ len = op->len;
471
+ data = op->data;
472
+
473
+ while (len--) {
474
+ *buf++ = (u_char) (data & 0xff);
475
+ data >>= 8;
476
+ }
477
+
478
+ return buf;
479
+ }
480
+
481
+
482
+ static u_char *
483
+ ngx_http_log_copy_long(ngx_http_request_t *r, u_char *buf,
484
+ ngx_http_log_op_t *op)
485
+ {
486
+ return ngx_cpymem(buf, (u_char *) op->data, op->len);
487
+ }
488
+
489
+
490
+ static u_char *
491
+ ngx_http_log_connection(ngx_http_request_t *r, u_char *buf,
492
+ ngx_http_log_op_t *op)
493
+ {
494
+ return ngx_sprintf(buf, "%ui", r->connection->number);
495
+ }
496
+
497
+
498
+ static u_char *
499
+ ngx_http_log_pipe(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
500
+ {
501
+ if (r->pipeline) {
502
+ *buf = 'p';
503
+ } else {
504
+ *buf = '.';
505
+ }
506
+
507
+ return buf + 1;
508
+ }
509
+
510
+
511
+ static u_char *
512
+ ngx_http_log_time(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
513
+ {
514
+ return ngx_cpymem(buf, ngx_cached_http_log_time.data,
515
+ ngx_cached_http_log_time.len);
516
+ }
517
+
518
+ static u_char *
519
+ ngx_http_log_iso8601(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
520
+ {
521
+ return ngx_cpymem(buf, ngx_cached_http_log_iso8601.data,
522
+ ngx_cached_http_log_iso8601.len);
523
+ }
524
+
525
+ static u_char *
526
+ ngx_http_log_msec(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
527
+ {
528
+ ngx_time_t *tp;
529
+
530
+ tp = ngx_timeofday();
531
+
532
+ return ngx_sprintf(buf, "%T.%03M", tp->sec, tp->msec);
533
+ }
534
+
535
+
536
+ static u_char *
537
+ ngx_http_log_request_time(ngx_http_request_t *r, u_char *buf,
538
+ ngx_http_log_op_t *op)
539
+ {
540
+ ngx_time_t *tp;
541
+ ngx_msec_int_t ms;
542
+
543
+ tp = ngx_timeofday();
544
+
545
+ ms = (ngx_msec_int_t)
546
+ ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec));
547
+ ms = ngx_max(ms, 0);
548
+
549
+ return ngx_sprintf(buf, "%T.%03M", ms / 1000, ms % 1000);
550
+ }
551
+
552
+
553
+ static u_char *
554
+ ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
555
+ {
556
+ ngx_uint_t status;
557
+
558
+ if (r->err_status) {
559
+ status = r->err_status;
560
+
561
+ } else if (r->headers_out.status) {
562
+ status = r->headers_out.status;
563
+
564
+ } else if (r->http_version == NGX_HTTP_VERSION_9) {
565
+ *buf++ = '0';
566
+ *buf++ = '0';
567
+ *buf++ = '9';
568
+ return buf;
569
+
570
+ } else {
571
+ status = 0;
572
+ }
573
+
574
+ return ngx_sprintf(buf, "%ui", status);
575
+ }
576
+
577
+
578
+ static u_char *
579
+ ngx_http_log_bytes_sent(ngx_http_request_t *r, u_char *buf,
580
+ ngx_http_log_op_t *op)
581
+ {
582
+ return ngx_sprintf(buf, "%O", r->connection->sent);
583
+ }
584
+
585
+
586
+ /*
587
+ * although there is a real $body_bytes_sent variable,
588
+ * this log operation code function is more optimized for logging
589
+ */
590
+
591
+ static u_char *
592
+ ngx_http_log_body_bytes_sent(ngx_http_request_t *r, u_char *buf,
593
+ ngx_http_log_op_t *op)
594
+ {
595
+ off_t length;
596
+
597
+ length = r->connection->sent - r->header_size;
598
+
599
+ if (length > 0) {
600
+ return ngx_sprintf(buf, "%O", length);
601
+ }
602
+
603
+ *buf = '0';
604
+
605
+ return buf + 1;
606
+ }
607
+
608
+
609
+ static u_char *
610
+ ngx_http_log_request_length(ngx_http_request_t *r, u_char *buf,
611
+ ngx_http_log_op_t *op)
612
+ {
613
+ return ngx_sprintf(buf, "%O", r->request_length);
614
+ }
615
+
616
+
617
+ static ngx_int_t
618
+ ngx_http_log_variable_compile(ngx_conf_t *cf, ngx_http_log_op_t *op,
619
+ ngx_str_t *value)
620
+ {
621
+ ngx_int_t index;
622
+
623
+ index = ngx_http_get_variable_index(cf, value);
624
+ if (index == NGX_ERROR) {
625
+ return NGX_ERROR;
626
+ }
627
+
628
+ op->len = 0;
629
+ op->getlen = ngx_http_log_variable_getlen;
630
+ op->run = ngx_http_log_variable;
631
+ op->data = index;
632
+
633
+ return NGX_OK;
634
+ }
635
+
636
+
637
+ static size_t
638
+ ngx_http_log_variable_getlen(ngx_http_request_t *r, uintptr_t data)
639
+ {
640
+ uintptr_t len;
641
+ ngx_http_variable_value_t *value;
642
+
643
+ value = ngx_http_get_indexed_variable(r, data);
644
+
645
+ if (value == NULL || value->not_found) {
646
+ return 1;
647
+ }
648
+
649
+ len = ngx_http_log_escape(NULL, value->data, value->len);
650
+
651
+ value->escape = len ? 1 : 0;
652
+
653
+ return value->len + len * 3;
654
+ }
655
+
656
+
657
+ static u_char *
658
+ ngx_http_log_variable(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
659
+ {
660
+ ngx_http_variable_value_t *value;
661
+
662
+ value = ngx_http_get_indexed_variable(r, op->data);
663
+
664
+ if (value == NULL || value->not_found) {
665
+ *buf = '-';
666
+ return buf + 1;
667
+ }
668
+
669
+ if (value->escape == 0) {
670
+ return ngx_cpymem(buf, value->data, value->len);
671
+
672
+ } else {
673
+ return (u_char *) ngx_http_log_escape(buf, value->data, value->len);
674
+ }
675
+ }
676
+
677
+
678
+ static uintptr_t
679
+ ngx_http_log_escape(u_char *dst, u_char *src, size_t size)
680
+ {
681
+ ngx_uint_t n;
682
+ static u_char hex[] = "0123456789ABCDEF";
683
+
684
+ static uint32_t escape[] = {
685
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
686
+
687
+ /* ?>=< ;:98 7654 3210 /.-, +*)( '&%$ #"! */
688
+ 0x00000004, /* 0000 0000 0000 0000 0000 0000 0000 0100 */
689
+
690
+ /* _^]\ [ZYX WVUT SRQP ONML KJIH GFED CBA@ */
691
+ 0x10000000, /* 0001 0000 0000 0000 0000 0000 0000 0000 */
692
+
693
+ /* ~}| {zyx wvut srqp onml kjih gfed cba` */
694
+ 0x80000000, /* 1000 0000 0000 0000 0000 0000 0000 0000 */
695
+
696
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
697
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
698
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
699
+ 0xffffffff, /* 1111 1111 1111 1111 1111 1111 1111 1111 */
700
+ };
701
+
702
+
703
+ if (dst == NULL) {
704
+
705
+ /* find the number of the characters to be escaped */
706
+
707
+ n = 0;
708
+
709
+ while (size) {
710
+ if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
711
+ n++;
712
+ }
713
+ src++;
714
+ size--;
715
+ }
716
+
717
+ return (uintptr_t) n;
718
+ }
719
+
720
+ while (size) {
721
+ if (escape[*src >> 5] & (1 << (*src & 0x1f))) {
722
+ *dst++ = '\\';
723
+ *dst++ = 'x';
724
+ *dst++ = hex[*src >> 4];
725
+ *dst++ = hex[*src & 0xf];
726
+ src++;
727
+
728
+ } else {
729
+ *dst++ = *src++;
730
+ }
731
+ size--;
732
+ }
733
+
734
+ return (uintptr_t) dst;
735
+ }
736
+
737
+
738
+ static void *
739
+ ngx_http_log_create_main_conf(ngx_conf_t *cf)
740
+ {
741
+ ngx_http_log_main_conf_t *conf;
742
+
743
+ ngx_http_log_fmt_t *fmt;
744
+
745
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_main_conf_t));
746
+ if (conf == NULL) {
747
+ return NULL;
748
+ }
749
+
750
+ if (ngx_array_init(&conf->formats, cf->pool, 4, sizeof(ngx_http_log_fmt_t))
751
+ != NGX_OK)
752
+ {
753
+ return NULL;
754
+ }
755
+
756
+ fmt = ngx_array_push(&conf->formats);
757
+ if (fmt == NULL) {
758
+ return NULL;
759
+ }
760
+
761
+ ngx_str_set(&fmt->name, "combined");
762
+
763
+ fmt->flushes = NULL;
764
+
765
+ fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t));
766
+ if (fmt->ops == NULL) {
767
+ return NULL;
768
+ }
769
+
770
+ return conf;
771
+ }
772
+
773
+
774
+ static void *
775
+ ngx_http_log_create_loc_conf(ngx_conf_t *cf)
776
+ {
777
+ ngx_http_log_loc_conf_t *conf;
778
+
779
+ conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_loc_conf_t));
780
+ if (conf == NULL) {
781
+ return NULL;
782
+ }
783
+
784
+ conf->open_file_cache = NGX_CONF_UNSET_PTR;
785
+
786
+ return conf;
787
+ }
788
+
789
+
790
+ static char *
791
+ ngx_http_log_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
792
+ {
793
+ ngx_http_log_loc_conf_t *prev = parent;
794
+ ngx_http_log_loc_conf_t *conf = child;
795
+
796
+ ngx_http_log_t *log;
797
+ ngx_http_log_fmt_t *fmt;
798
+ ngx_http_log_main_conf_t *lmcf;
799
+
800
+ if (conf->open_file_cache == NGX_CONF_UNSET_PTR) {
801
+
802
+ conf->open_file_cache = prev->open_file_cache;
803
+ conf->open_file_cache_valid = prev->open_file_cache_valid;
804
+ conf->open_file_cache_min_uses = prev->open_file_cache_min_uses;
805
+
806
+ if (conf->open_file_cache == NGX_CONF_UNSET_PTR) {
807
+ conf->open_file_cache = NULL;
808
+ }
809
+ }
810
+
811
+ if (conf->logs || conf->off) {
812
+ return NGX_CONF_OK;
813
+ }
814
+
815
+ conf->logs = prev->logs;
816
+ conf->off = prev->off;
817
+
818
+ if (conf->logs || conf->off) {
819
+ return NGX_CONF_OK;
820
+ }
821
+
822
+ conf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
823
+ if (conf->logs == NULL) {
824
+ return NGX_CONF_ERROR;
825
+ }
826
+
827
+ log = ngx_array_push(conf->logs);
828
+ if (log == NULL) {
829
+ return NGX_CONF_ERROR;
830
+ }
831
+
832
+ log->file = ngx_conf_open_file(cf->cycle, &ngx_http_access_log);
833
+ if (log->file == NULL) {
834
+ return NGX_CONF_ERROR;
835
+ }
836
+
837
+ log->script = NULL;
838
+ log->disk_full_time = 0;
839
+ log->error_log_time = 0;
840
+
841
+ lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
842
+ fmt = lmcf->formats.elts;
843
+
844
+ /* the default "combined" format */
845
+ log->format = &fmt[0];
846
+ lmcf->combined_used = 1;
847
+
848
+ return NGX_CONF_OK;
849
+ }
850
+
851
+
852
+ static char *
853
+ ngx_http_log_set_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
854
+ {
855
+ ngx_http_log_loc_conf_t *llcf = conf;
856
+
857
+ ssize_t buf;
858
+ ngx_uint_t i, n;
859
+ ngx_str_t *value, name;
860
+ ngx_http_log_t *log;
861
+ ngx_http_log_fmt_t *fmt;
862
+ ngx_http_log_main_conf_t *lmcf;
863
+ ngx_http_script_compile_t sc;
864
+
865
+ value = cf->args->elts;
866
+
867
+ if (ngx_strcmp(value[1].data, "off") == 0) {
868
+ llcf->off = 1;
869
+ if (cf->args->nelts == 2) {
870
+ return NGX_CONF_OK;
871
+ }
872
+
873
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
874
+ "invalid parameter \"%V\"", &value[2]);
875
+ return NGX_CONF_ERROR;
876
+ }
877
+
878
+ if (llcf->logs == NULL) {
879
+ llcf->logs = ngx_array_create(cf->pool, 2, sizeof(ngx_http_log_t));
880
+ if (llcf->logs == NULL) {
881
+ return NGX_CONF_ERROR;
882
+ }
883
+ }
884
+
885
+ lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
886
+
887
+ log = ngx_array_push(llcf->logs);
888
+ if (log == NULL) {
889
+ return NGX_CONF_ERROR;
890
+ }
891
+
892
+ ngx_memzero(log, sizeof(ngx_http_log_t));
893
+
894
+ n = ngx_http_script_variables_count(&value[1]);
895
+
896
+ if (n == 0) {
897
+ log->file = ngx_conf_open_file(cf->cycle, &value[1]);
898
+ if (log->file == NULL) {
899
+ return NGX_CONF_ERROR;
900
+ }
901
+
902
+ } else {
903
+ if (ngx_conf_full_name(cf->cycle, &value[1], 0) != NGX_OK) {
904
+ return NGX_CONF_ERROR;
905
+ }
906
+
907
+ log->script = ngx_pcalloc(cf->pool, sizeof(ngx_http_log_script_t));
908
+ if (log->script == NULL) {
909
+ return NGX_CONF_ERROR;
910
+ }
911
+
912
+ ngx_memzero(&sc, sizeof(ngx_http_script_compile_t));
913
+
914
+ sc.cf = cf;
915
+ sc.source = &value[1];
916
+ sc.lengths = &log->script->lengths;
917
+ sc.values = &log->script->values;
918
+ sc.variables = n;
919
+ sc.complete_lengths = 1;
920
+ sc.complete_values = 1;
921
+
922
+ if (ngx_http_script_compile(&sc) != NGX_OK) {
923
+ return NGX_CONF_ERROR;
924
+ }
925
+ }
926
+
927
+ if (cf->args->nelts >= 3) {
928
+ name = value[2];
929
+
930
+ if (ngx_strcmp(name.data, "combined") == 0) {
931
+ lmcf->combined_used = 1;
932
+ }
933
+
934
+ } else {
935
+ ngx_str_set(&name, "combined");
936
+ lmcf->combined_used = 1;
937
+ }
938
+
939
+ fmt = lmcf->formats.elts;
940
+ for (i = 0; i < lmcf->formats.nelts; i++) {
941
+ if (fmt[i].name.len == name.len
942
+ && ngx_strcasecmp(fmt[i].name.data, name.data) == 0)
943
+ {
944
+ log->format = &fmt[i];
945
+ goto buffer;
946
+ }
947
+ }
948
+
949
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
950
+ "unknown log format \"%V\"", &name);
951
+ return NGX_CONF_ERROR;
952
+
953
+ buffer:
954
+
955
+ if (cf->args->nelts == 4) {
956
+ if (ngx_strncmp(value[3].data, "buffer=", 7) != 0) {
957
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
958
+ "invalid parameter \"%V\"", &value[3]);
959
+ return NGX_CONF_ERROR;
960
+ }
961
+
962
+ if (log->script) {
963
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
964
+ "buffered logs cannot have variables in name");
965
+ return NGX_CONF_ERROR;
966
+ }
967
+
968
+ name.len = value[3].len - 7;
969
+ name.data = value[3].data + 7;
970
+
971
+ buf = ngx_parse_size(&name);
972
+
973
+ if (buf == NGX_ERROR) {
974
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
975
+ "invalid parameter \"%V\"", &value[3]);
976
+ return NGX_CONF_ERROR;
977
+ }
978
+
979
+ if (log->file->buffer && log->file->last - log->file->pos != buf) {
980
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
981
+ "access_log \"%V\" already defined "
982
+ "with different buffer size", &value[1]);
983
+ return NGX_CONF_ERROR;
984
+ }
985
+
986
+ log->file->buffer = ngx_palloc(cf->pool, buf);
987
+ if (log->file->buffer == NULL) {
988
+ return NGX_CONF_ERROR;
989
+ }
990
+
991
+ log->file->pos = log->file->buffer;
992
+ log->file->last = log->file->buffer + buf;
993
+ }
994
+
995
+ return NGX_CONF_OK;
996
+ }
997
+
998
+
999
+ static char *
1000
+ ngx_http_log_set_format(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1001
+ {
1002
+ ngx_http_log_main_conf_t *lmcf = conf;
1003
+
1004
+ ngx_str_t *value;
1005
+ ngx_uint_t i;
1006
+ ngx_http_log_fmt_t *fmt;
1007
+
1008
+ value = cf->args->elts;
1009
+
1010
+ fmt = lmcf->formats.elts;
1011
+ for (i = 0; i < lmcf->formats.nelts; i++) {
1012
+ if (fmt[i].name.len == value[1].len
1013
+ && ngx_strcmp(fmt[i].name.data, value[1].data) == 0)
1014
+ {
1015
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1016
+ "duplicate \"log_format\" name \"%V\"",
1017
+ &value[1]);
1018
+ return NGX_CONF_ERROR;
1019
+ }
1020
+ }
1021
+
1022
+ fmt = ngx_array_push(&lmcf->formats);
1023
+ if (fmt == NULL) {
1024
+ return NGX_CONF_ERROR;
1025
+ }
1026
+
1027
+ fmt->name = value[1];
1028
+
1029
+ fmt->flushes = ngx_array_create(cf->pool, 4, sizeof(ngx_int_t));
1030
+ if (fmt->flushes == NULL) {
1031
+ return NGX_CONF_ERROR;
1032
+ }
1033
+
1034
+ fmt->ops = ngx_array_create(cf->pool, 16, sizeof(ngx_http_log_op_t));
1035
+ if (fmt->ops == NULL) {
1036
+ return NGX_CONF_ERROR;
1037
+ }
1038
+
1039
+ return ngx_http_log_compile_format(cf, fmt->flushes, fmt->ops, cf->args, 2);
1040
+ }
1041
+
1042
+
1043
+ static char *
1044
+ ngx_http_log_compile_format(ngx_conf_t *cf, ngx_array_t *flushes,
1045
+ ngx_array_t *ops, ngx_array_t *args, ngx_uint_t s)
1046
+ {
1047
+ u_char *data, *p, ch;
1048
+ size_t i, len;
1049
+ ngx_str_t *value, var;
1050
+ ngx_int_t *flush;
1051
+ ngx_uint_t bracket;
1052
+ ngx_http_log_op_t *op;
1053
+ ngx_http_log_var_t *v;
1054
+
1055
+ value = args->elts;
1056
+
1057
+ for ( /* void */ ; s < args->nelts; s++) {
1058
+
1059
+ i = 0;
1060
+
1061
+ while (i < value[s].len) {
1062
+
1063
+ op = ngx_array_push(ops);
1064
+ if (op == NULL) {
1065
+ return NGX_CONF_ERROR;
1066
+ }
1067
+
1068
+ data = &value[s].data[i];
1069
+
1070
+ if (value[s].data[i] == '$') {
1071
+
1072
+ if (++i == value[s].len) {
1073
+ goto invalid;
1074
+ }
1075
+
1076
+ if (value[s].data[i] == '{') {
1077
+ bracket = 1;
1078
+
1079
+ if (++i == value[s].len) {
1080
+ goto invalid;
1081
+ }
1082
+
1083
+ var.data = &value[s].data[i];
1084
+
1085
+ } else {
1086
+ bracket = 0;
1087
+ var.data = &value[s].data[i];
1088
+ }
1089
+
1090
+ for (var.len = 0; i < value[s].len; i++, var.len++) {
1091
+ ch = value[s].data[i];
1092
+
1093
+ if (ch == '}' && bracket) {
1094
+ i++;
1095
+ bracket = 0;
1096
+ break;
1097
+ }
1098
+
1099
+ if ((ch >= 'A' && ch <= 'Z')
1100
+ || (ch >= 'a' && ch <= 'z')
1101
+ || (ch >= '0' && ch <= '9')
1102
+ || ch == '_')
1103
+ {
1104
+ continue;
1105
+ }
1106
+
1107
+ break;
1108
+ }
1109
+
1110
+ if (bracket) {
1111
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1112
+ "the closing bracket in \"%V\" "
1113
+ "variable is missing", &var);
1114
+ return NGX_CONF_ERROR;
1115
+ }
1116
+
1117
+ if (var.len == 0) {
1118
+ goto invalid;
1119
+ }
1120
+
1121
+ if (ngx_strncmp(var.data, "apache_bytes_sent", 17) == 0) {
1122
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1123
+ "use \"$body_bytes_sent\" instead of "
1124
+ "\"$apache_bytes_sent\"");
1125
+ }
1126
+
1127
+ for (v = ngx_http_log_vars; v->name.len; v++) {
1128
+
1129
+ if (v->name.len == var.len
1130
+ && ngx_strncmp(v->name.data, var.data, var.len) == 0)
1131
+ {
1132
+ op->len = v->len;
1133
+ op->getlen = NULL;
1134
+ op->run = v->run;
1135
+ op->data = 0;
1136
+
1137
+ goto found;
1138
+ }
1139
+ }
1140
+
1141
+ if (ngx_http_log_variable_compile(cf, op, &var) != NGX_OK) {
1142
+ return NGX_CONF_ERROR;
1143
+ }
1144
+
1145
+ if (flushes) {
1146
+
1147
+ flush = ngx_array_push(flushes);
1148
+ if (flush == NULL) {
1149
+ return NGX_CONF_ERROR;
1150
+ }
1151
+
1152
+ *flush = op->data; /* variable index */
1153
+ }
1154
+
1155
+ found:
1156
+
1157
+ continue;
1158
+ }
1159
+
1160
+ i++;
1161
+
1162
+ while (i < value[s].len && value[s].data[i] != '$') {
1163
+ i++;
1164
+ }
1165
+
1166
+ len = &value[s].data[i] - data;
1167
+
1168
+ if (len) {
1169
+
1170
+ op->len = len;
1171
+ op->getlen = NULL;
1172
+
1173
+ if (len <= sizeof(uintptr_t)) {
1174
+ op->run = ngx_http_log_copy_short;
1175
+ op->data = 0;
1176
+
1177
+ while (len--) {
1178
+ op->data <<= 8;
1179
+ op->data |= data[len];
1180
+ }
1181
+
1182
+ } else {
1183
+ op->run = ngx_http_log_copy_long;
1184
+
1185
+ p = ngx_pnalloc(cf->pool, len);
1186
+ if (p == NULL) {
1187
+ return NGX_CONF_ERROR;
1188
+ }
1189
+
1190
+ ngx_memcpy(p, data, len);
1191
+ op->data = (uintptr_t) p;
1192
+ }
1193
+ }
1194
+ }
1195
+ }
1196
+
1197
+ return NGX_CONF_OK;
1198
+
1199
+ invalid:
1200
+
1201
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameter \"%s\"", data);
1202
+
1203
+ return NGX_CONF_ERROR;
1204
+ }
1205
+
1206
+
1207
+ static char *
1208
+ ngx_http_log_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
1209
+ {
1210
+ ngx_http_log_loc_conf_t *llcf = conf;
1211
+
1212
+ time_t inactive, valid;
1213
+ ngx_str_t *value, s;
1214
+ ngx_int_t max, min_uses;
1215
+ ngx_uint_t i;
1216
+
1217
+ if (llcf->open_file_cache != NGX_CONF_UNSET_PTR) {
1218
+ return "is duplicate";
1219
+ }
1220
+
1221
+ value = cf->args->elts;
1222
+
1223
+ max = 0;
1224
+ inactive = 10;
1225
+ valid = 60;
1226
+ min_uses = 1;
1227
+
1228
+ for (i = 1; i < cf->args->nelts; i++) {
1229
+
1230
+ if (ngx_strncmp(value[i].data, "max=", 4) == 0) {
1231
+
1232
+ max = ngx_atoi(value[i].data + 4, value[i].len - 4);
1233
+ if (max == NGX_ERROR) {
1234
+ goto failed;
1235
+ }
1236
+
1237
+ continue;
1238
+ }
1239
+
1240
+ if (ngx_strncmp(value[i].data, "inactive=", 9) == 0) {
1241
+
1242
+ s.len = value[i].len - 9;
1243
+ s.data = value[i].data + 9;
1244
+
1245
+ inactive = ngx_parse_time(&s, 1);
1246
+ if (inactive < 0) {
1247
+ goto failed;
1248
+ }
1249
+
1250
+ continue;
1251
+ }
1252
+
1253
+ if (ngx_strncmp(value[i].data, "min_uses=", 9) == 0) {
1254
+
1255
+ min_uses = ngx_atoi(value[i].data + 9, value[i].len - 9);
1256
+ if (min_uses == NGX_ERROR) {
1257
+ goto failed;
1258
+ }
1259
+
1260
+ continue;
1261
+ }
1262
+
1263
+ if (ngx_strncmp(value[i].data, "valid=", 6) == 0) {
1264
+
1265
+ s.len = value[i].len - 6;
1266
+ s.data = value[i].data + 6;
1267
+
1268
+ valid = ngx_parse_time(&s, 1);
1269
+ if (valid < 0) {
1270
+ goto failed;
1271
+ }
1272
+
1273
+ continue;
1274
+ }
1275
+
1276
+ if (ngx_strcmp(value[i].data, "off") == 0) {
1277
+
1278
+ llcf->open_file_cache = NULL;
1279
+
1280
+ continue;
1281
+ }
1282
+
1283
+ failed:
1284
+
1285
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1286
+ "invalid \"open_log_file_cache\" parameter \"%V\"",
1287
+ &value[i]);
1288
+ return NGX_CONF_ERROR;
1289
+ }
1290
+
1291
+ if (llcf->open_file_cache == NULL) {
1292
+ return NGX_CONF_OK;
1293
+ }
1294
+
1295
+ if (max == 0) {
1296
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
1297
+ "\"open_log_file_cache\" must have \"max\" parameter");
1298
+ return NGX_CONF_ERROR;
1299
+ }
1300
+
1301
+ llcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
1302
+
1303
+ if (llcf->open_file_cache) {
1304
+
1305
+ llcf->open_file_cache_valid = valid;
1306
+ llcf->open_file_cache_min_uses = min_uses;
1307
+
1308
+ return NGX_CONF_OK;
1309
+ }
1310
+
1311
+ return NGX_CONF_ERROR;
1312
+ }
1313
+
1314
+
1315
+ static ngx_int_t
1316
+ ngx_http_log_init(ngx_conf_t *cf)
1317
+ {
1318
+ ngx_str_t *value;
1319
+ ngx_array_t a;
1320
+ ngx_http_handler_pt *h;
1321
+ ngx_http_log_fmt_t *fmt;
1322
+ ngx_http_log_main_conf_t *lmcf;
1323
+ ngx_http_core_main_conf_t *cmcf;
1324
+
1325
+ lmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_log_module);
1326
+
1327
+ if (lmcf->combined_used) {
1328
+ if (ngx_array_init(&a, cf->pool, 1, sizeof(ngx_str_t)) != NGX_OK) {
1329
+ return NGX_ERROR;
1330
+ }
1331
+
1332
+ value = ngx_array_push(&a);
1333
+ if (value == NULL) {
1334
+ return NGX_ERROR;
1335
+ }
1336
+
1337
+ *value = ngx_http_combined_fmt;
1338
+ fmt = lmcf->formats.elts;
1339
+
1340
+ if (ngx_http_log_compile_format(cf, NULL, fmt->ops, &a, 0)
1341
+ != NGX_CONF_OK)
1342
+ {
1343
+ return NGX_ERROR;
1344
+ }
1345
+ }
1346
+
1347
+ cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
1348
+
1349
+ h = ngx_array_push(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers);
1350
+ if (h == NULL) {
1351
+ return NGX_ERROR;
1352
+ }
1353
+
1354
+ *h = ngx_http_log_handler;
1355
+
1356
+ return NGX_OK;
1357
+ }