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,142 @@
1
+
2
+ /*
3
+ * Copyright (C) Igor Sysoev
4
+ * Copyright (C) Nginx, Inc.
5
+ */
6
+
7
+
8
+ #ifndef _NGX_CYCLE_H_INCLUDED_
9
+ #define _NGX_CYCLE_H_INCLUDED_
10
+
11
+
12
+ #include <ngx_config.h>
13
+ #include <ngx_core.h>
14
+
15
+
16
+ #ifndef NGX_CYCLE_POOL_SIZE
17
+ #define NGX_CYCLE_POOL_SIZE 16384
18
+ #endif
19
+
20
+
21
+ #define NGX_DEBUG_POINTS_STOP 1
22
+ #define NGX_DEBUG_POINTS_ABORT 2
23
+
24
+
25
+ typedef struct ngx_shm_zone_s ngx_shm_zone_t;
26
+
27
+ typedef ngx_int_t (*ngx_shm_zone_init_pt) (ngx_shm_zone_t *zone, void *data);
28
+
29
+ struct ngx_shm_zone_s {
30
+ void *data;
31
+ ngx_shm_t shm;
32
+ ngx_shm_zone_init_pt init;
33
+ void *tag;
34
+ };
35
+
36
+
37
+ struct ngx_cycle_s {
38
+ void ****conf_ctx;
39
+ ngx_pool_t *pool;
40
+
41
+ ngx_log_t *log;
42
+ ngx_log_t new_log;
43
+
44
+ ngx_connection_t **files;
45
+ ngx_connection_t *free_connections;
46
+ ngx_uint_t free_connection_n;
47
+
48
+ ngx_queue_t reusable_connections_queue;
49
+
50
+ ngx_array_t listening;
51
+ ngx_array_t pathes;
52
+ ngx_list_t open_files;
53
+ ngx_list_t shared_memory;
54
+
55
+ ngx_uint_t connection_n;
56
+ ngx_uint_t files_n;
57
+
58
+ ngx_connection_t *connections;
59
+ ngx_event_t *read_events;
60
+ ngx_event_t *write_events;
61
+
62
+ ngx_cycle_t *old_cycle;
63
+
64
+ ngx_str_t conf_file;
65
+ ngx_str_t conf_param;
66
+ ngx_str_t conf_prefix;
67
+ ngx_str_t prefix;
68
+ ngx_str_t lock_file;
69
+ ngx_str_t hostname;
70
+ };
71
+
72
+
73
+ typedef struct {
74
+ ngx_flag_t daemon;
75
+ ngx_flag_t master;
76
+
77
+ ngx_msec_t timer_resolution;
78
+
79
+ ngx_int_t worker_processes;
80
+ ngx_int_t debug_points;
81
+
82
+ ngx_int_t rlimit_nofile;
83
+ ngx_int_t rlimit_sigpending;
84
+ off_t rlimit_core;
85
+
86
+ int priority;
87
+
88
+ ngx_uint_t cpu_affinity_n;
89
+ u_long *cpu_affinity;
90
+
91
+ char *username;
92
+ ngx_uid_t user;
93
+ ngx_gid_t group;
94
+
95
+ ngx_str_t working_directory;
96
+ ngx_str_t lock_file;
97
+
98
+ ngx_str_t pid;
99
+ ngx_str_t oldpid;
100
+
101
+ ngx_array_t env;
102
+ char **environment;
103
+
104
+ #if (NGX_THREADS)
105
+ ngx_int_t worker_threads;
106
+ size_t thread_stack_size;
107
+ #endif
108
+
109
+ } ngx_core_conf_t;
110
+
111
+
112
+ typedef struct {
113
+ ngx_pool_t *pool; /* pcre's malloc() pool */
114
+ } ngx_core_tls_t;
115
+
116
+
117
+ #define ngx_is_init_cycle(cycle) (cycle->conf_ctx == NULL)
118
+
119
+
120
+ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle);
121
+ ngx_int_t ngx_create_pidfile(ngx_str_t *name, ngx_log_t *log);
122
+ void ngx_delete_pidfile(ngx_cycle_t *cycle);
123
+ ngx_int_t ngx_signal_process(ngx_cycle_t *cycle, char *sig);
124
+ void ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user);
125
+ char **ngx_set_environment(ngx_cycle_t *cycle, ngx_uint_t *last);
126
+ ngx_pid_t ngx_exec_new_binary(ngx_cycle_t *cycle, char *const *argv);
127
+ u_long ngx_get_cpu_affinity(ngx_uint_t n);
128
+ ngx_shm_zone_t *ngx_shared_memory_add(ngx_conf_t *cf, ngx_str_t *name,
129
+ size_t size, void *tag);
130
+
131
+
132
+ extern volatile ngx_cycle_t *ngx_cycle;
133
+ extern ngx_array_t ngx_old_cycles;
134
+ extern ngx_module_t ngx_core_module;
135
+ extern ngx_uint_t ngx_test_config;
136
+ extern ngx_uint_t ngx_quiet_mode;
137
+ #if (NGX_THREADS)
138
+ extern ngx_tls_key_t ngx_core_tls_key;
139
+ #endif
140
+
141
+
142
+ #endif /* _NGX_CYCLE_H_INCLUDED_ */
@@ -0,0 +1,993 @@
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
+
11
+
12
+ static ngx_atomic_t temp_number = 0;
13
+ ngx_atomic_t *ngx_temp_number = &temp_number;
14
+ ngx_atomic_int_t ngx_random_number = 123456;
15
+
16
+
17
+ ssize_t
18
+ ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain)
19
+ {
20
+ ngx_int_t rc;
21
+
22
+ if (tf->file.fd == NGX_INVALID_FILE) {
23
+ rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool,
24
+ tf->persistent, tf->clean, tf->access);
25
+
26
+ if (rc == NGX_ERROR || rc == NGX_AGAIN) {
27
+ return rc;
28
+ }
29
+
30
+ if (tf->log_level) {
31
+ ngx_log_error(tf->log_level, tf->file.log, 0, "%s %V",
32
+ tf->warn, &tf->file.name);
33
+ }
34
+ }
35
+
36
+ return ngx_write_chain_to_file(&tf->file, chain, tf->offset, tf->pool);
37
+ }
38
+
39
+
40
+ ngx_int_t
41
+ ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool,
42
+ ngx_uint_t persistent, ngx_uint_t clean, ngx_uint_t access)
43
+ {
44
+ uint32_t n;
45
+ ngx_err_t err;
46
+ ngx_pool_cleanup_t *cln;
47
+ ngx_pool_cleanup_file_t *clnf;
48
+
49
+ file->name.len = path->name.len + 1 + path->len + 10;
50
+
51
+ file->name.data = ngx_pnalloc(pool, file->name.len + 1);
52
+ if (file->name.data == NULL) {
53
+ return NGX_ERROR;
54
+ }
55
+
56
+ #if 0
57
+ for (i = 0; i < file->name.len; i++) {
58
+ file->name.data[i] = 'X';
59
+ }
60
+ #endif
61
+
62
+ ngx_memcpy(file->name.data, path->name.data, path->name.len);
63
+
64
+ n = (uint32_t) ngx_next_temp_number(0);
65
+
66
+ cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t));
67
+ if (cln == NULL) {
68
+ return NGX_ERROR;
69
+ }
70
+
71
+ for ( ;; ) {
72
+ (void) ngx_sprintf(file->name.data + path->name.len + 1 + path->len,
73
+ "%010uD%Z", n);
74
+
75
+ ngx_create_hashed_filename(path, file->name.data, file->name.len);
76
+
77
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
78
+ "hashed path: %s", file->name.data);
79
+
80
+ file->fd = ngx_open_tempfile(file->name.data, persistent, access);
81
+
82
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
83
+ "temp fd:%d", file->fd);
84
+
85
+ if (file->fd != NGX_INVALID_FILE) {
86
+
87
+ cln->handler = clean ? ngx_pool_delete_file : ngx_pool_cleanup_file;
88
+ clnf = cln->data;
89
+
90
+ clnf->fd = file->fd;
91
+ clnf->name = file->name.data;
92
+ clnf->log = pool->log;
93
+
94
+ return NGX_OK;
95
+ }
96
+
97
+ err = ngx_errno;
98
+
99
+ if (err == NGX_EEXIST) {
100
+ n = (uint32_t) ngx_next_temp_number(1);
101
+ continue;
102
+ }
103
+
104
+ if ((path->level[0] == 0) || (err != NGX_ENOPATH)) {
105
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
106
+ ngx_open_tempfile_n " \"%s\" failed",
107
+ file->name.data);
108
+ return NGX_ERROR;
109
+ }
110
+
111
+ if (ngx_create_path(file, path) == NGX_ERROR) {
112
+ return NGX_ERROR;
113
+ }
114
+ }
115
+ }
116
+
117
+
118
+ void
119
+ ngx_create_hashed_filename(ngx_path_t *path, u_char *file, size_t len)
120
+ {
121
+ size_t i, level;
122
+ ngx_uint_t n;
123
+
124
+ i = path->name.len + 1;
125
+
126
+ file[path->name.len + path->len] = '/';
127
+
128
+ for (n = 0; n < 3; n++) {
129
+ level = path->level[n];
130
+
131
+ if (level == 0) {
132
+ break;
133
+ }
134
+
135
+ len -= level;
136
+ file[i - 1] = '/';
137
+ ngx_memcpy(&file[i], &file[len], level);
138
+ i += level + 1;
139
+ }
140
+ }
141
+
142
+
143
+ ngx_int_t
144
+ ngx_create_path(ngx_file_t *file, ngx_path_t *path)
145
+ {
146
+ size_t pos;
147
+ ngx_err_t err;
148
+ ngx_uint_t i;
149
+
150
+ pos = path->name.len;
151
+
152
+ for (i = 0; i < 3; i++) {
153
+ if (path->level[i] == 0) {
154
+ break;
155
+ }
156
+
157
+ pos += path->level[i] + 1;
158
+
159
+ file->name.data[pos] = '\0';
160
+
161
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0,
162
+ "temp file: \"%s\"", file->name.data);
163
+
164
+ if (ngx_create_dir(file->name.data, 0700) == NGX_FILE_ERROR) {
165
+ err = ngx_errno;
166
+ if (err != NGX_EEXIST) {
167
+ ngx_log_error(NGX_LOG_CRIT, file->log, err,
168
+ ngx_create_dir_n " \"%s\" failed",
169
+ file->name.data);
170
+ return NGX_ERROR;
171
+ }
172
+ }
173
+
174
+ file->name.data[pos] = '/';
175
+ }
176
+
177
+ return NGX_OK;
178
+ }
179
+
180
+
181
+ ngx_err_t
182
+ ngx_create_full_path(u_char *dir, ngx_uint_t access)
183
+ {
184
+ u_char *p, ch;
185
+ ngx_err_t err;
186
+
187
+ err = 0;
188
+
189
+ #if (NGX_WIN32)
190
+ p = dir + 3;
191
+ #else
192
+ p = dir + 1;
193
+ #endif
194
+
195
+ for ( /* void */ ; *p; p++) {
196
+ ch = *p;
197
+
198
+ if (ch != '/') {
199
+ continue;
200
+ }
201
+
202
+ *p = '\0';
203
+
204
+ if (ngx_create_dir(dir, access) == NGX_FILE_ERROR) {
205
+ err = ngx_errno;
206
+
207
+ switch (err) {
208
+ case NGX_EEXIST:
209
+ err = 0;
210
+ case NGX_EACCES:
211
+ break;
212
+
213
+ default:
214
+ return err;
215
+ }
216
+ }
217
+
218
+ *p = '/';
219
+ }
220
+
221
+ return err;
222
+ }
223
+
224
+
225
+ ngx_atomic_uint_t
226
+ ngx_next_temp_number(ngx_uint_t collision)
227
+ {
228
+ ngx_atomic_uint_t n, add;
229
+
230
+ add = collision ? ngx_random_number : 1;
231
+
232
+ n = ngx_atomic_fetch_add(ngx_temp_number, add);
233
+
234
+ return n + add;
235
+ }
236
+
237
+
238
+ char *
239
+ ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
240
+ {
241
+ char *p = conf;
242
+
243
+ ssize_t level;
244
+ ngx_str_t *value;
245
+ ngx_uint_t i, n;
246
+ ngx_path_t *path, **slot;
247
+
248
+ slot = (ngx_path_t **) (p + cmd->offset);
249
+
250
+ if (*slot) {
251
+ return "is duplicate";
252
+ }
253
+
254
+ path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t));
255
+ if (path == NULL) {
256
+ return NGX_CONF_ERROR;
257
+ }
258
+
259
+ value = cf->args->elts;
260
+
261
+ path->name = value[1];
262
+
263
+ if (path->name.data[path->name.len - 1] == '/') {
264
+ path->name.len--;
265
+ }
266
+
267
+ if (ngx_conf_full_name(cf->cycle, &path->name, 0) != NGX_OK) {
268
+ return NULL;
269
+ }
270
+
271
+ path->len = 0;
272
+ path->manager = NULL;
273
+ path->loader = NULL;
274
+ path->conf_file = cf->conf_file->file.name.data;
275
+ path->line = cf->conf_file->line;
276
+
277
+ for (i = 0, n = 2; n < cf->args->nelts; i++, n++) {
278
+ level = ngx_atoi(value[n].data, value[n].len);
279
+ if (level == NGX_ERROR || level == 0) {
280
+ return "invalid value";
281
+ }
282
+
283
+ path->level[i] = level;
284
+ path->len += level + 1;
285
+ }
286
+
287
+ while (i < 3) {
288
+ path->level[i++] = 0;
289
+ }
290
+
291
+ *slot = path;
292
+
293
+ if (ngx_add_path(cf, slot) == NGX_ERROR) {
294
+ return NGX_CONF_ERROR;
295
+ }
296
+
297
+ return NGX_CONF_OK;
298
+ }
299
+
300
+
301
+ char *
302
+ ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path, ngx_path_t *prev,
303
+ ngx_path_init_t *init)
304
+ {
305
+ if (*path) {
306
+ return NGX_CONF_OK;
307
+ }
308
+
309
+ if (prev) {
310
+ *path = prev;
311
+ return NGX_CONF_OK;
312
+ }
313
+
314
+ *path = ngx_palloc(cf->pool, sizeof(ngx_path_t));
315
+ if (*path == NULL) {
316
+ return NGX_CONF_ERROR;
317
+ }
318
+
319
+ (*path)->name = init->name;
320
+
321
+ if (ngx_conf_full_name(cf->cycle, &(*path)->name, 0) != NGX_OK) {
322
+ return NGX_CONF_ERROR;
323
+ }
324
+
325
+ (*path)->level[0] = init->level[0];
326
+ (*path)->level[1] = init->level[1];
327
+ (*path)->level[2] = init->level[2];
328
+
329
+ (*path)->len = init->level[0] + (init->level[0] ? 1 : 0)
330
+ + init->level[1] + (init->level[1] ? 1 : 0)
331
+ + init->level[2] + (init->level[2] ? 1 : 0);
332
+
333
+ (*path)->manager = NULL;
334
+ (*path)->loader = NULL;
335
+ (*path)->conf_file = NULL;
336
+
337
+ if (ngx_add_path(cf, path) != NGX_OK) {
338
+ return NGX_CONF_ERROR;
339
+ }
340
+
341
+ return NGX_CONF_OK;
342
+ }
343
+
344
+
345
+ char *
346
+ ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
347
+ {
348
+ char *confp = conf;
349
+
350
+ u_char *p;
351
+ ngx_str_t *value;
352
+ ngx_uint_t i, right, shift, *access;
353
+
354
+ access = (ngx_uint_t *) (confp + cmd->offset);
355
+
356
+ if (*access != NGX_CONF_UNSET_UINT) {
357
+ return "is duplicate";
358
+ }
359
+
360
+ value = cf->args->elts;
361
+
362
+ *access = 0600;
363
+
364
+ for (i = 1; i < cf->args->nelts; i++) {
365
+
366
+ p = value[i].data;
367
+
368
+ if (ngx_strncmp(p, "user:", sizeof("user:") - 1) == 0) {
369
+ shift = 6;
370
+ p += sizeof("user:") - 1;
371
+
372
+ } else if (ngx_strncmp(p, "group:", sizeof("group:") - 1) == 0) {
373
+ shift = 3;
374
+ p += sizeof("group:") - 1;
375
+
376
+ } else if (ngx_strncmp(p, "all:", sizeof("all:") - 1) == 0) {
377
+ shift = 0;
378
+ p += sizeof("all:") - 1;
379
+
380
+ } else {
381
+ goto invalid;
382
+ }
383
+
384
+ if (ngx_strcmp(p, "rw") == 0) {
385
+ right = 6;
386
+
387
+ } else if (ngx_strcmp(p, "r") == 0) {
388
+ right = 4;
389
+
390
+ } else {
391
+ goto invalid;
392
+ }
393
+
394
+ *access |= right << shift;
395
+ }
396
+
397
+ return NGX_CONF_OK;
398
+
399
+ invalid:
400
+
401
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid value \"%V\"", &value[i]);
402
+
403
+ return NGX_CONF_ERROR;
404
+ }
405
+
406
+
407
+ ngx_int_t
408
+ ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot)
409
+ {
410
+ ngx_uint_t i, n;
411
+ ngx_path_t *path, **p;
412
+
413
+ path = *slot;
414
+
415
+ p = cf->cycle->pathes.elts;
416
+ for (i = 0; i < cf->cycle->pathes.nelts; i++) {
417
+ if (p[i]->name.len == path->name.len
418
+ && ngx_strcmp(p[i]->name.data, path->name.data) == 0)
419
+ {
420
+ for (n = 0; n < 3; n++) {
421
+ if (p[i]->level[n] != path->level[n]) {
422
+ if (path->conf_file == NULL) {
423
+ if (p[i]->conf_file == NULL) {
424
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
425
+ "the default path name \"%V\" has "
426
+ "the same name as another default path, "
427
+ "but the different levels, you need to "
428
+ "redefine one of them in http section",
429
+ &p[i]->name);
430
+ return NGX_ERROR;
431
+ }
432
+
433
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
434
+ "the path name \"%V\" in %s:%ui has "
435
+ "the same name as default path, but "
436
+ "the different levels, you need to "
437
+ "define default path in http section",
438
+ &p[i]->name, p[i]->conf_file, p[i]->line);
439
+ return NGX_ERROR;
440
+ }
441
+
442
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
443
+ "the same path name \"%V\" in %s:%ui "
444
+ "has the different levels than",
445
+ &p[i]->name, p[i]->conf_file, p[i]->line);
446
+ return NGX_ERROR;
447
+ }
448
+
449
+ if (p[i]->level[n] == 0) {
450
+ break;
451
+ }
452
+ }
453
+
454
+ *slot = p[i];
455
+
456
+ return NGX_OK;
457
+ }
458
+ }
459
+
460
+ p = ngx_array_push(&cf->cycle->pathes);
461
+ if (p == NULL) {
462
+ return NGX_ERROR;
463
+ }
464
+
465
+ *p = path;
466
+
467
+ return NGX_OK;
468
+ }
469
+
470
+
471
+ ngx_int_t
472
+ ngx_create_pathes(ngx_cycle_t *cycle, ngx_uid_t user)
473
+ {
474
+ ngx_err_t err;
475
+ ngx_uint_t i;
476
+ ngx_path_t **path;
477
+
478
+ path = cycle->pathes.elts;
479
+ for (i = 0; i < cycle->pathes.nelts; i++) {
480
+
481
+ if (ngx_create_dir(path[i]->name.data, 0700) == NGX_FILE_ERROR) {
482
+ err = ngx_errno;
483
+ if (err != NGX_EEXIST) {
484
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, err,
485
+ ngx_create_dir_n " \"%s\" failed",
486
+ path[i]->name.data);
487
+ return NGX_ERROR;
488
+ }
489
+ }
490
+
491
+ if (user == (ngx_uid_t) NGX_CONF_UNSET_UINT) {
492
+ continue;
493
+ }
494
+
495
+ #if !(NGX_WIN32)
496
+ {
497
+ ngx_file_info_t fi;
498
+
499
+ if (ngx_file_info((const char *) path[i]->name.data, &fi)
500
+ == NGX_FILE_ERROR)
501
+ {
502
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
503
+ ngx_file_info_n " \"%s\" failed", path[i]->name.data);
504
+ return NGX_ERROR;
505
+ }
506
+
507
+ if (fi.st_uid != user) {
508
+ if (chown((const char *) path[i]->name.data, user, -1) == -1) {
509
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
510
+ "chown(\"%s\", %d) failed",
511
+ path[i]->name.data, user);
512
+ return NGX_ERROR;
513
+ }
514
+ }
515
+
516
+ if ((fi.st_mode & (S_IRUSR|S_IWUSR|S_IXUSR))
517
+ != (S_IRUSR|S_IWUSR|S_IXUSR))
518
+ {
519
+ fi.st_mode |= (S_IRUSR|S_IWUSR|S_IXUSR);
520
+
521
+ if (chmod((const char *) path[i]->name.data, fi.st_mode) == -1) {
522
+ ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
523
+ "chmod() \"%s\" failed", path[i]->name.data);
524
+ return NGX_ERROR;
525
+ }
526
+ }
527
+ }
528
+ #endif
529
+ }
530
+
531
+ return NGX_OK;
532
+ }
533
+
534
+
535
+ ngx_int_t
536
+ ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to, ngx_ext_rename_file_t *ext)
537
+ {
538
+ u_char *name;
539
+ ngx_err_t err;
540
+ ngx_copy_file_t cf;
541
+
542
+ #if !(NGX_WIN32)
543
+
544
+ if (ext->access) {
545
+ if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) {
546
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
547
+ ngx_change_file_access_n " \"%s\" failed", src->data);
548
+ err = 0;
549
+ goto failed;
550
+ }
551
+ }
552
+
553
+ #endif
554
+
555
+ if (ext->time != -1) {
556
+ if (ngx_set_file_time(src->data, ext->fd, ext->time) != NGX_OK) {
557
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
558
+ ngx_set_file_time_n " \"%s\" failed", src->data);
559
+ err = 0;
560
+ goto failed;
561
+ }
562
+ }
563
+
564
+ if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) {
565
+ return NGX_OK;
566
+ }
567
+
568
+ err = ngx_errno;
569
+
570
+ if (err == NGX_ENOPATH) {
571
+
572
+ if (!ext->create_path) {
573
+ goto failed;
574
+ }
575
+
576
+ err = ngx_create_full_path(to->data, ngx_dir_access(ext->path_access));
577
+
578
+ if (err) {
579
+ ngx_log_error(NGX_LOG_CRIT, ext->log, err,
580
+ ngx_create_dir_n " \"%s\" failed", to->data);
581
+ err = 0;
582
+ goto failed;
583
+ }
584
+
585
+ if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) {
586
+ return NGX_OK;
587
+ }
588
+
589
+ err = ngx_errno;
590
+ }
591
+
592
+ #if (NGX_WIN32)
593
+
594
+ if (err == NGX_EEXIST) {
595
+ err = ngx_win32_rename_file(src, to, ext->log);
596
+
597
+ if (err == 0) {
598
+ return NGX_OK;
599
+ }
600
+ }
601
+
602
+ #endif
603
+
604
+ if (err == NGX_EXDEV) {
605
+
606
+ cf.size = -1;
607
+ cf.buf_size = 0;
608
+ cf.access = ext->access;
609
+ cf.time = ext->time;
610
+ cf.log = ext->log;
611
+
612
+ name = ngx_alloc(to->len + 1 + 10 + 1, ext->log);
613
+ if (name == NULL) {
614
+ return NGX_ERROR;
615
+ }
616
+
617
+ (void) ngx_sprintf(name, "%*s.%010uD%Z", to->len, to->data,
618
+ (uint32_t) ngx_next_temp_number(0));
619
+
620
+ if (ngx_copy_file(src->data, name, &cf) == NGX_OK) {
621
+
622
+ if (ngx_rename_file(name, to->data) != NGX_FILE_ERROR) {
623
+ ngx_free(name);
624
+
625
+ if (ngx_delete_file(src->data) == NGX_FILE_ERROR) {
626
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
627
+ ngx_delete_file_n " \"%s\" failed",
628
+ src->data);
629
+ return NGX_ERROR;
630
+ }
631
+
632
+ return NGX_OK;
633
+ }
634
+
635
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
636
+ ngx_rename_file_n " \"%s\" to \"%s\" failed",
637
+ name, to->data);
638
+
639
+ if (ngx_delete_file(name) == NGX_FILE_ERROR) {
640
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
641
+ ngx_delete_file_n " \"%s\" failed", name);
642
+
643
+ }
644
+ }
645
+
646
+ ngx_free(name);
647
+
648
+ err = 0;
649
+ }
650
+
651
+ failed:
652
+
653
+ if (ext->delete_file) {
654
+ if (ngx_delete_file(src->data) == NGX_FILE_ERROR) {
655
+ ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno,
656
+ ngx_delete_file_n " \"%s\" failed", src->data);
657
+ }
658
+ }
659
+
660
+ if (err) {
661
+ ngx_log_error(NGX_LOG_CRIT, ext->log, err,
662
+ ngx_rename_file_n " \"%s\" to \"%s\" failed",
663
+ src->data, to->data);
664
+ }
665
+
666
+ return NGX_ERROR;
667
+ }
668
+
669
+
670
+ ngx_int_t
671
+ ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf)
672
+ {
673
+ char *buf;
674
+ off_t size;
675
+ size_t len;
676
+ ssize_t n;
677
+ ngx_fd_t fd, nfd;
678
+ ngx_int_t rc;
679
+ ngx_file_info_t fi;
680
+
681
+ rc = NGX_ERROR;
682
+ buf = NULL;
683
+ nfd = NGX_INVALID_FILE;
684
+
685
+ fd = ngx_open_file(from, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
686
+
687
+ if (fd == NGX_INVALID_FILE) {
688
+ ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno,
689
+ ngx_open_file_n " \"%s\" failed", from);
690
+ goto failed;
691
+ }
692
+
693
+ if (cf->size != -1) {
694
+ size = cf->size;
695
+
696
+ } else {
697
+ if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
698
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
699
+ ngx_fd_info_n " \"%s\" failed", from);
700
+
701
+ goto failed;
702
+ }
703
+
704
+ size = ngx_file_size(&fi);
705
+ }
706
+
707
+ len = cf->buf_size ? cf->buf_size : 65536;
708
+
709
+ if ((off_t) len > size) {
710
+ len = (size_t) size;
711
+ }
712
+
713
+ buf = ngx_alloc(len, cf->log);
714
+ if (buf == NULL) {
715
+ goto failed;
716
+ }
717
+
718
+ nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_CREATE_OR_OPEN,
719
+ cf->access);
720
+
721
+ if (nfd == NGX_INVALID_FILE) {
722
+ ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno,
723
+ ngx_open_file_n " \"%s\" failed", to);
724
+ goto failed;
725
+ }
726
+
727
+ while (size > 0) {
728
+
729
+ if ((off_t) len > size) {
730
+ len = (size_t) size;
731
+ }
732
+
733
+ n = ngx_read_fd(fd, buf, len);
734
+
735
+ if (n == NGX_FILE_ERROR) {
736
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
737
+ ngx_read_fd_n " \"%s\" failed", from);
738
+ goto failed;
739
+ }
740
+
741
+ if ((size_t) n != len) {
742
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
743
+ ngx_read_fd_n " has read only %z of %uz from %s",
744
+ n, size, from);
745
+ goto failed;
746
+ }
747
+
748
+ n = ngx_write_fd(nfd, buf, len);
749
+
750
+ if (n == NGX_FILE_ERROR) {
751
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
752
+ ngx_write_fd_n " \"%s\" failed", to);
753
+ goto failed;
754
+ }
755
+
756
+ if ((size_t) n != len) {
757
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
758
+ ngx_write_fd_n " has written only %z of %uz to %s",
759
+ n, size, to);
760
+ goto failed;
761
+ }
762
+
763
+ size -= n;
764
+ }
765
+
766
+ if (cf->time != -1) {
767
+ if (ngx_set_file_time(to, nfd, cf->time) != NGX_OK) {
768
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
769
+ ngx_set_file_time_n " \"%s\" failed", to);
770
+ goto failed;
771
+ }
772
+ }
773
+
774
+ rc = NGX_OK;
775
+
776
+ failed:
777
+
778
+ if (nfd != NGX_INVALID_FILE) {
779
+ if (ngx_close_file(nfd) == NGX_FILE_ERROR) {
780
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
781
+ ngx_close_file_n " \"%s\" failed", to);
782
+ }
783
+ }
784
+
785
+ if (fd != NGX_INVALID_FILE) {
786
+ if (ngx_close_file(fd) == NGX_FILE_ERROR) {
787
+ ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
788
+ ngx_close_file_n " \"%s\" failed", from);
789
+ }
790
+ }
791
+
792
+ if (buf) {
793
+ ngx_free(buf);
794
+ }
795
+
796
+ return rc;
797
+ }
798
+
799
+
800
+ /*
801
+ * ctx->init_handler() - see ctx->alloc
802
+ * ctx->file_handler() - file handler
803
+ * ctx->pre_tree_handler() - handler is called before entering directory
804
+ * ctx->post_tree_handler() - handler is called after leaving directory
805
+ * ctx->spec_handler() - special (socket, FIFO, etc.) file handler
806
+ *
807
+ * ctx->data - some data structure, it may be the same on all levels, or
808
+ * reallocated if ctx->alloc is nonzero
809
+ *
810
+ * ctx->alloc - a size of data structure that is allocated at every level
811
+ * and is initilialized by ctx->init_handler()
812
+ *
813
+ * ctx->log - a log
814
+ *
815
+ * on fatal (memory) error handler must return NGX_ABORT to stop walking tree
816
+ */
817
+
818
+ ngx_int_t
819
+ ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree)
820
+ {
821
+ void *data, *prev;
822
+ u_char *p, *name;
823
+ size_t len;
824
+ ngx_int_t rc;
825
+ ngx_err_t err;
826
+ ngx_str_t file, buf;
827
+ ngx_dir_t dir;
828
+
829
+ ngx_str_null(&buf);
830
+
831
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
832
+ "walk tree \"%V\"", tree);
833
+
834
+ if (ngx_open_dir(tree, &dir) == NGX_ERROR) {
835
+ ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
836
+ ngx_open_dir_n " \"%s\" failed", tree->data);
837
+ return NGX_ERROR;
838
+ }
839
+
840
+ prev = ctx->data;
841
+
842
+ if (ctx->alloc) {
843
+ data = ngx_alloc(ctx->alloc, ctx->log);
844
+ if (data == NULL) {
845
+ goto failed;
846
+ }
847
+
848
+ if (ctx->init_handler(data, prev) == NGX_ABORT) {
849
+ goto failed;
850
+ }
851
+
852
+ ctx->data = data;
853
+
854
+ } else {
855
+ data = NULL;
856
+ }
857
+
858
+ for ( ;; ) {
859
+
860
+ ngx_set_errno(0);
861
+
862
+ if (ngx_read_dir(&dir) == NGX_ERROR) {
863
+ err = ngx_errno;
864
+
865
+ if (err == NGX_ENOMOREFILES) {
866
+ rc = NGX_OK;
867
+
868
+ } else {
869
+ ngx_log_error(NGX_LOG_CRIT, ctx->log, err,
870
+ ngx_read_dir_n " \"%s\" failed", tree->data);
871
+ rc = NGX_ERROR;
872
+ }
873
+
874
+ goto done;
875
+ }
876
+
877
+ len = ngx_de_namelen(&dir);
878
+ name = ngx_de_name(&dir);
879
+
880
+ ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0,
881
+ "tree name %uz:\"%s\"", len, name);
882
+
883
+ if (len == 1 && name[0] == '.') {
884
+ continue;
885
+ }
886
+
887
+ if (len == 2 && name[0] == '.' && name[1] == '.') {
888
+ continue;
889
+ }
890
+
891
+ file.len = tree->len + 1 + len;
892
+
893
+ if (file.len + NGX_DIR_MASK_LEN > buf.len) {
894
+
895
+ if (buf.len) {
896
+ ngx_free(buf.data);
897
+ }
898
+
899
+ buf.len = tree->len + 1 + len + NGX_DIR_MASK_LEN;
900
+
901
+ buf.data = ngx_alloc(buf.len + 1, ctx->log);
902
+ if (buf.data == NULL) {
903
+ goto failed;
904
+ }
905
+ }
906
+
907
+ p = ngx_cpymem(buf.data, tree->data, tree->len);
908
+ *p++ = '/';
909
+ ngx_memcpy(p, name, len + 1);
910
+
911
+ file.data = buf.data;
912
+
913
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
914
+ "tree path \"%s\"", file.data);
915
+
916
+ if (!dir.valid_info) {
917
+ if (ngx_de_info(file.data, &dir) == NGX_FILE_ERROR) {
918
+ ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
919
+ ngx_de_info_n " \"%s\" failed", file.data);
920
+ continue;
921
+ }
922
+ }
923
+
924
+ if (ngx_de_is_file(&dir)) {
925
+
926
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
927
+ "tree file \"%s\"", file.data);
928
+
929
+ ctx->size = ngx_de_size(&dir);
930
+ ctx->fs_size = ngx_de_fs_size(&dir);
931
+ ctx->access = ngx_de_access(&dir);
932
+ ctx->mtime = ngx_de_mtime(&dir);
933
+
934
+ if (ctx->file_handler(ctx, &file) == NGX_ABORT) {
935
+ goto failed;
936
+ }
937
+
938
+ } else if (ngx_de_is_dir(&dir)) {
939
+
940
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
941
+ "tree enter dir \"%s\"", file.data);
942
+
943
+ ctx->access = ngx_de_access(&dir);
944
+ ctx->mtime = ngx_de_mtime(&dir);
945
+
946
+ if (ctx->pre_tree_handler(ctx, &file) == NGX_ABORT) {
947
+ goto failed;
948
+ }
949
+
950
+ if (ngx_walk_tree(ctx, &file) == NGX_ABORT) {
951
+ goto failed;
952
+ }
953
+
954
+ ctx->access = ngx_de_access(&dir);
955
+ ctx->mtime = ngx_de_mtime(&dir);
956
+
957
+ if (ctx->post_tree_handler(ctx, &file) == NGX_ABORT) {
958
+ goto failed;
959
+ }
960
+
961
+ } else {
962
+
963
+ ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0,
964
+ "tree special \"%s\"", file.data);
965
+
966
+ if (ctx->spec_handler(ctx, &file) == NGX_ABORT) {
967
+ goto failed;
968
+ }
969
+ }
970
+ }
971
+
972
+ failed:
973
+
974
+ rc = NGX_ABORT;
975
+
976
+ done:
977
+
978
+ if (buf.len) {
979
+ ngx_free(buf.data);
980
+ }
981
+
982
+ if (data) {
983
+ ngx_free(data);
984
+ ctx->data = prev;
985
+ }
986
+
987
+ if (ngx_close_dir(&dir) == NGX_ERROR) {
988
+ ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno,
989
+ ngx_close_dir_n " \"%s\" failed", tree->data);
990
+ }
991
+
992
+ return rc;
993
+ }