nginxtra 1.8.1.12 → 1.10.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. checksums.yaml +4 -4
  2. data/bin/nginxtra +1 -1
  3. data/bin/nginxtra_rails +1 -1
  4. data/lib/nginxtra/version.rb +1 -1
  5. data/vendor/nginx/CHANGES +363 -25
  6. data/vendor/nginx/CHANGES.ru +365 -21
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/conf +32 -0
  9. data/vendor/nginx/auto/cc/gcc +1 -1
  10. data/vendor/nginx/auto/cc/icc +2 -2
  11. data/vendor/nginx/auto/cc/msvc +29 -8
  12. data/vendor/nginx/auto/cc/name +2 -25
  13. data/vendor/nginx/auto/cc/sunc +3 -0
  14. data/vendor/nginx/auto/endianness +7 -2
  15. data/vendor/nginx/auto/install +60 -26
  16. data/vendor/nginx/auto/lib/conf +4 -4
  17. data/vendor/nginx/auto/lib/geoip/conf +6 -1
  18. data/vendor/nginx/auto/lib/libgd/conf +6 -1
  19. data/vendor/nginx/auto/lib/libxslt/conf +11 -2
  20. data/vendor/nginx/auto/lib/make +1 -1
  21. data/vendor/nginx/auto/lib/md5/conf +2 -2
  22. data/vendor/nginx/auto/lib/md5/make +2 -2
  23. data/vendor/nginx/auto/lib/openssl/conf +52 -3
  24. data/vendor/nginx/auto/lib/openssl/make +1 -1
  25. data/vendor/nginx/auto/lib/pcre/conf +2 -2
  26. data/vendor/nginx/auto/lib/pcre/make +2 -2
  27. data/vendor/nginx/auto/lib/perl/conf +6 -3
  28. data/vendor/nginx/auto/lib/perl/make +4 -1
  29. data/vendor/nginx/auto/lib/sha1/conf +2 -2
  30. data/vendor/nginx/auto/lib/sha1/make +2 -2
  31. data/vendor/nginx/auto/lib/zlib/conf +2 -2
  32. data/vendor/nginx/auto/lib/zlib/make +2 -2
  33. data/vendor/nginx/auto/make +281 -16
  34. data/vendor/nginx/auto/module +122 -0
  35. data/vendor/nginx/auto/modules +909 -178
  36. data/vendor/nginx/auto/options +81 -19
  37. data/vendor/nginx/auto/os/conf +9 -0
  38. data/vendor/nginx/auto/os/darwin +3 -0
  39. data/vendor/nginx/auto/os/freebsd +0 -20
  40. data/vendor/nginx/auto/os/linux +0 -12
  41. data/vendor/nginx/auto/os/win32 +5 -1
  42. data/vendor/nginx/auto/sources +11 -311
  43. data/vendor/nginx/auto/summary +1 -0
  44. data/vendor/nginx/auto/types/sizeof +5 -3
  45. data/vendor/nginx/auto/types/typedef +9 -4
  46. data/vendor/nginx/auto/types/uintptr_t +7 -2
  47. data/vendor/nginx/auto/unix +72 -12
  48. data/vendor/nginx/conf/fastcgi.conf +1 -0
  49. data/vendor/nginx/conf/fastcgi_params +1 -0
  50. data/vendor/nginx/conf/scgi_params +1 -0
  51. data/vendor/nginx/conf/uwsgi_params +1 -0
  52. data/vendor/nginx/configure +1 -1
  53. data/vendor/nginx/contrib/vim/syntax/nginx.vim +2 -2
  54. data/vendor/nginx/man/nginx.8 +6 -2
  55. data/vendor/nginx/src/core/nginx.c +281 -114
  56. data/vendor/nginx/src/core/nginx.h +2 -2
  57. data/vendor/nginx/src/core/ngx_conf_file.c +54 -13
  58. data/vendor/nginx/src/core/ngx_conf_file.h +8 -52
  59. data/vendor/nginx/src/core/ngx_config.h +0 -5
  60. data/vendor/nginx/src/core/ngx_connection.c +270 -37
  61. data/vendor/nginx/src/core/ngx_connection.h +35 -12
  62. data/vendor/nginx/src/core/ngx_core.h +4 -0
  63. data/vendor/nginx/src/core/ngx_crypt.c +2 -2
  64. data/vendor/nginx/src/core/ngx_cycle.c +72 -25
  65. data/vendor/nginx/src/core/ngx_cycle.h +28 -39
  66. data/vendor/nginx/src/core/ngx_file.c +14 -5
  67. data/vendor/nginx/src/core/ngx_file.h +2 -0
  68. data/vendor/nginx/src/core/ngx_hash.c +13 -1
  69. data/vendor/nginx/src/core/ngx_inet.c +20 -18
  70. data/vendor/nginx/src/core/ngx_log.c +12 -12
  71. data/vendor/nginx/src/core/ngx_log.h +13 -6
  72. data/vendor/nginx/src/core/ngx_module.c +360 -0
  73. data/vendor/nginx/src/core/ngx_module.h +307 -0
  74. data/vendor/nginx/src/core/ngx_open_file_cache.c +2 -2
  75. data/vendor/nginx/src/core/ngx_output_chain.c +8 -4
  76. data/vendor/nginx/src/core/ngx_palloc.c +42 -44
  77. data/vendor/nginx/src/{http/ngx_http_parse_time.c → core/ngx_parse_time.c} +2 -3
  78. data/vendor/nginx/src/core/ngx_parse_time.h +22 -0
  79. data/vendor/nginx/src/core/ngx_proxy_protocol.c +50 -1
  80. data/vendor/nginx/src/core/ngx_proxy_protocol.h +3 -1
  81. data/vendor/nginx/src/core/ngx_regex.c +1 -38
  82. data/vendor/nginx/src/core/ngx_resolver.c +1814 -320
  83. data/vendor/nginx/src/core/ngx_resolver.h +67 -10
  84. data/vendor/nginx/src/core/ngx_rwlock.c +120 -0
  85. data/vendor/nginx/src/core/ngx_rwlock.h +21 -0
  86. data/vendor/nginx/src/core/ngx_slab.c +6 -5
  87. data/vendor/nginx/src/core/ngx_string.c +1 -1
  88. data/vendor/nginx/src/core/ngx_syslog.c +11 -3
  89. data/vendor/nginx/src/core/ngx_syslog.h +2 -1
  90. data/vendor/nginx/src/core/ngx_thread_pool.c +4 -0
  91. data/vendor/nginx/src/core/ngx_times.c +2 -2
  92. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +3 -1
  93. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +5 -2
  94. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +5 -5
  95. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +15 -8
  96. data/vendor/nginx/src/event/modules/ngx_poll_module.c +0 -10
  97. data/vendor/nginx/src/event/modules/ngx_select_module.c +0 -10
  98. data/vendor/nginx/src/event/ngx_event.c +60 -103
  99. data/vendor/nginx/src/event/ngx_event.h +22 -26
  100. data/vendor/nginx/src/event/ngx_event_accept.c +414 -88
  101. data/vendor/nginx/src/event/ngx_event_connect.c +27 -18
  102. data/vendor/nginx/src/event/ngx_event_connect.h +1 -0
  103. data/vendor/nginx/src/event/ngx_event_openssl.c +65 -25
  104. data/vendor/nginx/src/event/ngx_event_openssl.h +17 -0
  105. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +73 -7
  106. data/vendor/nginx/src/event/ngx_event_pipe.c +85 -27
  107. data/vendor/nginx/src/event/ngx_event_pipe.h +10 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +2 -2
  110. data/vendor/nginx/src/http/modules/ngx_http_chunked_filter_module.c +2 -2
  111. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +6 -6
  112. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +17 -11
  113. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +2 -2
  114. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +9 -9
  115. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +2 -2
  116. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +2 -2
  117. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +0 -7
  118. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +6 -6
  119. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +2 -1
  120. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +13 -13
  121. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +2 -2
  122. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +26 -21
  123. data/vendor/nginx/src/http/modules/ngx_http_random_index_module.c +1 -1
  124. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +26 -8
  125. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +73 -3
  126. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +1 -1
  127. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +6 -6
  128. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +5 -3
  129. data/vendor/nginx/src/http/modules/ngx_http_slice_filter_module.c +526 -0
  130. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +7 -7
  131. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +19 -16
  132. data/vendor/nginx/src/http/modules/ngx_http_static_module.c +1 -1
  133. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +1 -1
  134. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +373 -173
  135. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +72 -46
  136. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +18 -30
  137. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +50 -39
  138. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +38 -129
  139. data/vendor/nginx/src/http/modules/ngx_http_upstream_zone_module.c +246 -0
  140. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +6 -5
  141. data/vendor/nginx/src/http/modules/perl/nginx.xs +9 -9
  142. data/vendor/nginx/src/http/ngx_http.c +46 -43
  143. data/vendor/nginx/src/http/ngx_http.h +4 -9
  144. data/vendor/nginx/src/http/ngx_http_cache.h +4 -0
  145. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +13 -5
  146. data/vendor/nginx/src/http/ngx_http_core_module.c +92 -91
  147. data/vendor/nginx/src/http/ngx_http_core_module.h +12 -8
  148. data/vendor/nginx/src/http/ngx_http_file_cache.c +61 -10
  149. data/vendor/nginx/src/http/ngx_http_request.c +37 -50
  150. data/vendor/nginx/src/http/ngx_http_request.h +10 -15
  151. data/vendor/nginx/src/http/ngx_http_request_body.c +64 -88
  152. data/vendor/nginx/src/http/ngx_http_script.c +3 -3
  153. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -4
  154. data/vendor/nginx/src/http/ngx_http_upstream.c +245 -109
  155. data/vendor/nginx/src/http/ngx_http_upstream.h +11 -5
  156. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +212 -65
  157. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +66 -5
  158. data/vendor/nginx/src/http/ngx_http_variables.c +28 -15
  159. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +1 -1
  160. data/vendor/nginx/src/http/v2/ngx_http_v2.c +4349 -0
  161. data/vendor/nginx/src/http/v2/ngx_http_v2.h +337 -0
  162. data/vendor/nginx/src/http/v2/ngx_http_v2_filter_module.c +1391 -0
  163. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_decode.c +2714 -0
  164. data/vendor/nginx/src/http/v2/ngx_http_v2_huff_encode.c +254 -0
  165. data/vendor/nginx/src/http/v2/ngx_http_v2_module.c +469 -0
  166. data/vendor/nginx/src/http/{ngx_http_spdy_module.h → v2/ngx_http_v2_module.h} +10 -9
  167. data/vendor/nginx/src/http/v2/ngx_http_v2_table.c +349 -0
  168. data/vendor/nginx/src/mail/ngx_mail.c +49 -82
  169. data/vendor/nginx/src/mail/ngx_mail.h +16 -23
  170. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +1 -1
  171. data/vendor/nginx/src/mail/ngx_mail_core_module.c +60 -34
  172. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -12
  173. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +1 -14
  174. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +1 -1
  175. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +5 -5
  176. data/vendor/nginx/src/os/unix/ngx_atomic.h +10 -10
  177. data/vendor/nginx/src/os/unix/ngx_channel.h +4 -4
  178. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +2 -0
  179. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -0
  180. data/vendor/nginx/src/os/unix/ngx_dlopen.c +28 -0
  181. data/vendor/nginx/src/os/unix/ngx_dlopen.h +31 -0
  182. data/vendor/nginx/src/os/unix/ngx_errno.h +1 -0
  183. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +1 -1
  184. data/vendor/nginx/src/os/unix/ngx_files.c +313 -80
  185. data/vendor/nginx/src/os/unix/ngx_files.h +5 -2
  186. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +3 -1
  187. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -0
  188. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +13 -0
  189. data/vendor/nginx/src/os/unix/ngx_linux.h +0 -2
  190. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +1 -1
  191. data/vendor/nginx/src/os/unix/ngx_linux_config.h +2 -6
  192. data/vendor/nginx/src/os/unix/ngx_linux_init.c +1 -33
  193. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +55 -12
  194. data/vendor/nginx/src/os/unix/ngx_os.h +3 -9
  195. data/vendor/nginx/src/os/unix/ngx_posix_config.h +14 -1
  196. data/vendor/nginx/src/os/unix/ngx_posix_init.c +2 -1
  197. data/vendor/nginx/src/os/unix/ngx_process.c +1 -1
  198. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +25 -51
  199. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +1 -0
  200. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +24 -28
  201. data/vendor/nginx/src/os/unix/ngx_recv.c +30 -79
  202. data/vendor/nginx/src/os/unix/ngx_send.c +1 -1
  203. data/vendor/nginx/src/os/unix/ngx_setaffinity.c +14 -30
  204. data/vendor/nginx/src/os/unix/ngx_setaffinity.h +15 -1
  205. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +2 -0
  206. data/vendor/nginx/src/os/unix/ngx_solaris_init.c +1 -0
  207. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +23 -0
  208. data/vendor/nginx/src/os/unix/ngx_sunpro_amd64.il +3 -3
  209. data/vendor/nginx/src/os/unix/ngx_sunpro_x86.il +3 -3
  210. data/vendor/nginx/src/os/unix/ngx_udp_recv.c +5 -48
  211. data/vendor/nginx/src/os/unix/ngx_udp_send.c +56 -0
  212. data/vendor/nginx/src/stream/ngx_stream.c +564 -0
  213. data/vendor/nginx/src/stream/ngx_stream.h +212 -0
  214. data/vendor/nginx/src/stream/ngx_stream_access_module.c +451 -0
  215. data/vendor/nginx/src/stream/ngx_stream_core_module.c +562 -0
  216. data/vendor/nginx/src/stream/ngx_stream_handler.c +344 -0
  217. data/vendor/nginx/src/stream/ngx_stream_limit_conn_module.c +632 -0
  218. data/vendor/nginx/src/stream/ngx_stream_proxy_module.c +1674 -0
  219. data/vendor/nginx/src/stream/ngx_stream_ssl_module.c +460 -0
  220. data/vendor/nginx/src/stream/ngx_stream_ssl_module.h +49 -0
  221. data/vendor/nginx/src/stream/ngx_stream_upstream.c +464 -0
  222. data/vendor/nginx/src/stream/ngx_stream_upstream.h +107 -0
  223. data/vendor/nginx/src/stream/ngx_stream_upstream_hash_module.c +656 -0
  224. data/vendor/nginx/src/stream/ngx_stream_upstream_least_conn_module.c +307 -0
  225. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.c +702 -0
  226. data/vendor/nginx/src/stream/ngx_stream_upstream_round_robin.h +139 -0
  227. data/vendor/nginx/src/stream/ngx_stream_upstream_zone_module.c +242 -0
  228. metadata +39 -15
  229. data/vendor/nginx/src/event/modules/ngx_aio_module.c +0 -171
  230. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +0 -735
  231. data/vendor/nginx/src/http/ngx_http_spdy.c +0 -3701
  232. data/vendor/nginx/src/http/ngx_http_spdy.h +0 -261
  233. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +0 -1222
  234. data/vendor/nginx/src/http/ngx_http_spdy_module.c +0 -408
  235. data/vendor/nginx/src/os/unix/ngx_aio_read.c +0 -109
  236. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +0 -78
  237. data/vendor/nginx/src/os/unix/ngx_aio_write.c +0 -109
  238. data/vendor/nginx/src/os/unix/ngx_aio_write_chain.c +0 -100
@@ -34,7 +34,7 @@ struct ngx_event_s {
34
34
 
35
35
  unsigned accept:1;
36
36
 
37
- /* used to detect the stale events in kqueue, rtsig, and epoll */
37
+ /* used to detect the stale events in kqueue and epoll */
38
38
  unsigned instance:1;
39
39
 
40
40
  /*
@@ -68,6 +68,14 @@ struct ngx_event_s {
68
68
 
69
69
  unsigned posted:1;
70
70
 
71
+ unsigned closed:1;
72
+
73
+ /* to test on worker exit */
74
+ unsigned channel:1;
75
+ unsigned resolver:1;
76
+
77
+ unsigned cancelable:1;
78
+
71
79
  #if (NGX_WIN32)
72
80
  /* setsockopt(SO_UPDATE_ACCEPT_CONTEXT) was successful */
73
81
  unsigned accept_context_updated:1;
@@ -103,14 +111,8 @@ struct ngx_event_s {
103
111
  ngx_event_handler_pt handler;
104
112
 
105
113
 
106
- #if (NGX_HAVE_AIO)
107
-
108
114
  #if (NGX_HAVE_IOCP)
109
115
  ngx_event_ovlp_t ovlp;
110
- #else
111
- struct aiocb aiocb;
112
- #endif
113
-
114
116
  #endif
115
117
 
116
118
  ngx_uint_t index;
@@ -122,15 +124,6 @@ struct ngx_event_s {
122
124
  /* the posted queue */
123
125
  ngx_queue_t queue;
124
126
 
125
- unsigned closed:1;
126
-
127
- /* to test on worker exit */
128
- unsigned channel:1;
129
- unsigned resolver:1;
130
-
131
- unsigned cancelable:1;
132
-
133
-
134
127
  #if 0
135
128
 
136
129
  /* the threads support */
@@ -195,7 +188,7 @@ typedef struct {
195
188
  ngx_int_t (*notify)(ngx_event_handler_pt handler);
196
189
 
197
190
  ngx_int_t (*process_events)(ngx_cycle_t *cycle, ngx_msec_t timer,
198
- ngx_uint_t flags);
191
+ ngx_uint_t flags);
199
192
 
200
193
  ngx_int_t (*init)(ngx_cycle_t *cycle, ngx_msec_t timer);
201
194
  void (*done)(ngx_cycle_t *cycle);
@@ -236,7 +229,7 @@ extern ngx_event_actions_t ngx_event_actions;
236
229
  #define NGX_USE_LOWAT_EVENT 0x00000010
237
230
 
238
231
  /*
239
- * The event filter requires to do i/o operation until EAGAIN: epoll, rtsig.
232
+ * The event filter requires to do i/o operation until EAGAIN: epoll.
240
233
  */
241
234
  #define NGX_USE_GREEDY_EVENT 0x00000020
242
235
 
@@ -246,25 +239,23 @@ extern ngx_event_actions_t ngx_event_actions;
246
239
  #define NGX_USE_EPOLL_EVENT 0x00000040
247
240
 
248
241
  /*
249
- * No need to add or delete the event filters: rtsig.
242
+ * Obsolete.
250
243
  */
251
244
  #define NGX_USE_RTSIG_EVENT 0x00000080
252
245
 
253
246
  /*
254
- * No need to add or delete the event filters: overlapped, aio_read,
255
- * aioread, io_submit.
247
+ * Obsolete.
256
248
  */
257
249
  #define NGX_USE_AIO_EVENT 0x00000100
258
250
 
259
251
  /*
260
252
  * Need to add socket or handle only once: i/o completion port.
261
- * It also requires NGX_HAVE_AIO and NGX_USE_AIO_EVENT to be set.
262
253
  */
263
254
  #define NGX_USE_IOCP_EVENT 0x00000200
264
255
 
265
256
  /*
266
257
  * The event filter has no opaque data and requires file descriptors table:
267
- * poll, /dev/poll, rtsig.
258
+ * poll, /dev/poll.
268
259
  */
269
260
  #define NGX_USE_FD_EVENT 0x00000400
270
261
 
@@ -289,7 +280,7 @@ extern ngx_event_actions_t ngx_event_actions;
289
280
  /*
290
281
  * The event filter is deleted just before the closing file.
291
282
  * Has no meaning for select and poll.
292
- * kqueue, epoll, rtsig, eventport: allows to avoid explicit delete,
283
+ * kqueue, epoll, eventport: allows to avoid explicit delete,
293
284
  * because filter automatically is deleted
294
285
  * on file close,
295
286
  *
@@ -352,7 +343,8 @@ extern ngx_event_actions_t ngx_event_actions;
352
343
  #define NGX_DISABLE_EVENT EV_DISABLE
353
344
 
354
345
 
355
- #elif (NGX_HAVE_DEVPOLL || NGX_HAVE_EVENTPORT)
346
+ #elif (NGX_HAVE_DEVPOLL && !(NGX_TEST_BUILD_DEVPOLL)) \
347
+ || (NGX_HAVE_EVENTPORT && !(NGX_TEST_BUILD_EVENTPORT))
356
348
 
357
349
  #define NGX_READ_EVENT POLLIN
358
350
  #define NGX_WRITE_EVENT POLLOUT
@@ -361,7 +353,7 @@ extern ngx_event_actions_t ngx_event_actions;
361
353
  #define NGX_ONESHOT_EVENT 1
362
354
 
363
355
 
364
- #elif (NGX_HAVE_EPOLL)
356
+ #elif (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
365
357
 
366
358
  #define NGX_READ_EVENT (EPOLLIN|EPOLLRDHUP)
367
359
  #define NGX_WRITE_EVENT EPOLLOUT
@@ -427,6 +419,7 @@ extern ngx_os_io_t ngx_io;
427
419
  #define ngx_udp_recv ngx_io.udp_recv
428
420
  #define ngx_send ngx_io.send
429
421
  #define ngx_send_chain ngx_io.send_chain
422
+ #define ngx_udp_send ngx_io.udp_send
430
423
 
431
424
 
432
425
  #define NGX_EVENT_MODULE 0x544E5645 /* "EVNT" */
@@ -500,6 +493,9 @@ extern ngx_module_t ngx_event_core_module;
500
493
 
501
494
 
502
495
  void ngx_event_accept(ngx_event_t *ev);
496
+ #if !(NGX_WIN32)
497
+ void ngx_event_recvmsg(ngx_event_t *ev);
498
+ #endif
503
499
  ngx_int_t ngx_trylock_accept_mutex(ngx_cycle_t *cycle);
504
500
  u_char *ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len);
505
501
 
@@ -11,8 +11,12 @@
11
11
 
12
12
 
13
13
  static ngx_int_t ngx_enable_accept_events(ngx_cycle_t *cycle);
14
- static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle);
14
+ static ngx_int_t ngx_disable_accept_events(ngx_cycle_t *cycle, ngx_uint_t all);
15
15
  static void ngx_close_accepted_connection(ngx_connection_t *c);
16
+ #if (NGX_DEBUG)
17
+ static void ngx_debug_accepted_connection(ngx_event_conf_t *ecf,
18
+ ngx_connection_t *c);
19
+ #endif
16
20
 
17
21
 
18
22
  void
@@ -42,10 +46,7 @@ ngx_event_accept(ngx_event_t *ev)
42
46
 
43
47
  ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
44
48
 
45
- if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
46
- ev->available = 1;
47
-
48
- } else if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
49
+ if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
49
50
  ev->available = ecf->multi_accept;
50
51
  }
51
52
 
@@ -112,7 +113,7 @@ ngx_event_accept(ngx_event_t *ev)
112
113
  }
113
114
 
114
115
  if (err == NGX_EMFILE || err == NGX_ENFILE) {
115
- if (ngx_disable_accept_events((ngx_cycle_t *) ngx_cycle)
116
+ if (ngx_disable_accept_events((ngx_cycle_t *) ngx_cycle, 1)
116
117
  != NGX_OK)
117
118
  {
118
119
  return;
@@ -152,6 +153,8 @@ ngx_event_accept(ngx_event_t *ev)
152
153
  return;
153
154
  }
154
155
 
156
+ c->type = SOCK_STREAM;
157
+
155
158
  #if (NGX_STAT_STUB)
156
159
  (void) ngx_atomic_fetch_add(ngx_stat_active, 1);
157
160
  #endif
@@ -176,10 +179,10 @@ ngx_event_accept(ngx_event_t *ev)
176
179
  return;
177
180
  }
178
181
 
179
- /* set a blocking mode for aio and non-blocking mode for others */
182
+ /* set a blocking mode for iocp and non-blocking mode for others */
180
183
 
181
184
  if (ngx_inherited_nonblocking) {
182
- if (ngx_event_flags & NGX_USE_AIO_EVENT) {
185
+ if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
183
186
  if (ngx_blocking(s) == -1) {
184
187
  ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
185
188
  ngx_blocking_n " failed");
@@ -189,7 +192,7 @@ ngx_event_accept(ngx_event_t *ev)
189
192
  }
190
193
 
191
194
  } else {
192
- if (!(ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT))) {
195
+ if (!(ngx_event_flags & NGX_USE_IOCP_EVENT)) {
193
196
  if (ngx_nonblocking(s) == -1) {
194
197
  ngx_log_error(NGX_LOG_ALERT, ev->log, ngx_socket_errno,
195
198
  ngx_nonblocking_n " failed");
@@ -232,8 +235,7 @@ ngx_event_accept(ngx_event_t *ev)
232
235
 
233
236
  wev->ready = 1;
234
237
 
235
- if (ngx_event_flags & (NGX_USE_AIO_EVENT|NGX_USE_RTSIG_EVENT)) {
236
- /* rtsig, aio, iocp */
238
+ if (ngx_event_flags & NGX_USE_IOCP_EVENT) {
237
239
  rev->ready = 1;
238
240
  }
239
241
 
@@ -280,92 +282,360 @@ ngx_event_accept(ngx_event_t *ev)
280
282
 
281
283
  #if (NGX_DEBUG)
282
284
  {
285
+ ngx_str_t addr;
286
+ u_char text[NGX_SOCKADDR_STRLEN];
283
287
 
284
- ngx_str_t addr;
285
- struct sockaddr_in *sin;
286
- ngx_cidr_t *cidr;
287
- ngx_uint_t i;
288
- u_char text[NGX_SOCKADDR_STRLEN];
289
- #if (NGX_HAVE_INET6)
290
- struct sockaddr_in6 *sin6;
291
- ngx_uint_t n;
288
+ ngx_debug_accepted_connection(ecf, c);
289
+
290
+ if (log->log_level & NGX_LOG_DEBUG_EVENT) {
291
+ addr.data = text;
292
+ addr.len = ngx_sock_ntop(c->sockaddr, c->socklen, text,
293
+ NGX_SOCKADDR_STRLEN, 1);
294
+
295
+ ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
296
+ "*%uA accept: %V fd:%d", c->number, &addr, s);
297
+ }
298
+
299
+ }
292
300
  #endif
293
301
 
294
- cidr = ecf->debug_connection.elts;
295
- for (i = 0; i < ecf->debug_connection.nelts; i++) {
296
- if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) {
297
- goto next;
302
+ if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
303
+ if (ngx_add_conn(c) == NGX_ERROR) {
304
+ ngx_close_accepted_connection(c);
305
+ return;
298
306
  }
307
+ }
299
308
 
300
- switch (cidr[i].family) {
309
+ log->data = NULL;
310
+ log->handler = NULL;
301
311
 
302
- #if (NGX_HAVE_INET6)
303
- case AF_INET6:
304
- sin6 = (struct sockaddr_in6 *) c->sockaddr;
305
- for (n = 0; n < 16; n++) {
306
- if ((sin6->sin6_addr.s6_addr[n]
307
- & cidr[i].u.in6.mask.s6_addr[n])
308
- != cidr[i].u.in6.addr.s6_addr[n])
309
- {
310
- goto next;
311
- }
312
- }
313
- break;
312
+ ls->handler(c);
313
+
314
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
315
+ ev->available--;
316
+ }
317
+
318
+ } while (ev->available);
319
+ }
320
+
321
+
322
+ #if !(NGX_WIN32)
323
+
324
+ void
325
+ ngx_event_recvmsg(ngx_event_t *ev)
326
+ {
327
+ ssize_t n;
328
+ ngx_log_t *log;
329
+ ngx_err_t err;
330
+ ngx_event_t *rev, *wev;
331
+ struct iovec iov[1];
332
+ struct msghdr msg;
333
+ ngx_listening_t *ls;
334
+ ngx_event_conf_t *ecf;
335
+ ngx_connection_t *c, *lc;
336
+ u_char sa[NGX_SOCKADDRLEN];
337
+ static u_char buffer[65535];
338
+
339
+ #if (NGX_HAVE_MSGHDR_MSG_CONTROL)
340
+
341
+ #if (NGX_HAVE_IP_RECVDSTADDR)
342
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_addr))];
343
+ #elif (NGX_HAVE_IP_PKTINFO)
344
+ u_char msg_control[CMSG_SPACE(sizeof(struct in_pktinfo))];
314
345
  #endif
315
346
 
316
- #if (NGX_HAVE_UNIX_DOMAIN)
317
- case AF_UNIX:
318
- break;
347
+ #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
348
+ u_char msg_control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
319
349
  #endif
320
350
 
321
- default: /* AF_INET */
322
- sin = (struct sockaddr_in *) c->sockaddr;
323
- if ((sin->sin_addr.s_addr & cidr[i].u.in.mask)
324
- != cidr[i].u.in.addr)
325
- {
326
- goto next;
327
- }
328
- break;
351
+ #endif
352
+
353
+ if (ev->timedout) {
354
+ if (ngx_enable_accept_events((ngx_cycle_t *) ngx_cycle) != NGX_OK) {
355
+ return;
356
+ }
357
+
358
+ ev->timedout = 0;
359
+ }
360
+
361
+ ecf = ngx_event_get_conf(ngx_cycle->conf_ctx, ngx_event_core_module);
362
+
363
+ if (!(ngx_event_flags & NGX_USE_KQUEUE_EVENT)) {
364
+ ev->available = ecf->multi_accept;
365
+ }
366
+
367
+ lc = ev->data;
368
+ ls = lc->listening;
369
+ ev->ready = 0;
370
+
371
+ ngx_log_debug2(NGX_LOG_DEBUG_EVENT, ev->log, 0,
372
+ "recvmsg on %V, ready: %d", &ls->addr_text, ev->available);
373
+
374
+ do {
375
+ ngx_memzero(&msg, sizeof(struct msghdr));
376
+
377
+ iov[0].iov_base = (void *) buffer;
378
+ iov[0].iov_len = sizeof(buffer);
379
+
380
+ msg.msg_name = &sa;
381
+ msg.msg_namelen = sizeof(sa);
382
+ msg.msg_iov = iov;
383
+ msg.msg_iovlen = 1;
384
+
385
+ #if (NGX_HAVE_MSGHDR_MSG_CONTROL)
386
+
387
+ if (ls->wildcard) {
388
+
389
+ #if (NGX_HAVE_IP_RECVDSTADDR || NGX_HAVE_IP_PKTINFO)
390
+ if (ls->sockaddr->sa_family == AF_INET) {
391
+ msg.msg_control = &msg_control;
392
+ msg.msg_controllen = sizeof(msg_control);
329
393
  }
394
+ #endif
330
395
 
331
- log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
332
- break;
396
+ #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
397
+ if (ls->sockaddr->sa_family == AF_INET6) {
398
+ msg.msg_control = &msg_control6;
399
+ msg.msg_controllen = sizeof(msg_control6);
400
+ }
401
+ #endif
402
+ }
403
+
404
+ #endif
333
405
 
334
- next:
406
+ n = recvmsg(lc->fd, &msg, 0);
407
+
408
+ if (n == -1) {
409
+ err = ngx_socket_errno;
410
+
411
+ if (err == NGX_EAGAIN) {
412
+ ngx_log_debug0(NGX_LOG_DEBUG_EVENT, ev->log, err,
413
+ "recvmsg() not ready");
414
+ return;
415
+ }
416
+
417
+ ngx_log_error(NGX_LOG_ALERT, ev->log, err, "recvmsg() failed");
418
+
419
+ return;
420
+ }
421
+
422
+ #if (NGX_STAT_STUB)
423
+ (void) ngx_atomic_fetch_add(ngx_stat_accepted, 1);
424
+ #endif
425
+
426
+ #if (NGX_HAVE_MSGHDR_MSG_CONTROL)
427
+ if (msg.msg_flags & (MSG_TRUNC|MSG_CTRUNC)) {
428
+ ngx_log_error(NGX_LOG_ALERT, ev->log, 0,
429
+ "recvmsg() truncated data");
335
430
  continue;
336
431
  }
432
+ #endif
337
433
 
338
- if (log->log_level & NGX_LOG_DEBUG_EVENT) {
339
- addr.data = text;
340
- addr.len = ngx_sock_ntop(c->sockaddr, c->socklen, text,
341
- NGX_SOCKADDR_STRLEN, 1);
434
+ ngx_accept_disabled = ngx_cycle->connection_n / 8
435
+ - ngx_cycle->free_connection_n;
342
436
 
343
- ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
344
- "*%uA accept: %V fd:%d", c->number, &addr, s);
437
+ c = ngx_get_connection(lc->fd, ev->log);
438
+ if (c == NULL) {
439
+ return;
345
440
  }
346
441
 
442
+ c->shared = 1;
443
+ c->type = SOCK_DGRAM;
444
+ c->socklen = msg.msg_namelen;
445
+
446
+ #if (NGX_STAT_STUB)
447
+ (void) ngx_atomic_fetch_add(ngx_stat_active, 1);
448
+ #endif
449
+
450
+ c->pool = ngx_create_pool(ls->pool_size, ev->log);
451
+ if (c->pool == NULL) {
452
+ ngx_close_accepted_connection(c);
453
+ return;
347
454
  }
455
+
456
+ c->sockaddr = ngx_palloc(c->pool, c->socklen);
457
+ if (c->sockaddr == NULL) {
458
+ ngx_close_accepted_connection(c);
459
+ return;
460
+ }
461
+
462
+ ngx_memcpy(c->sockaddr, msg.msg_name, c->socklen);
463
+
464
+ log = ngx_palloc(c->pool, sizeof(ngx_log_t));
465
+ if (log == NULL) {
466
+ ngx_close_accepted_connection(c);
467
+ return;
468
+ }
469
+
470
+ *log = ls->log;
471
+
472
+ c->send = ngx_udp_send;
473
+
474
+ c->log = log;
475
+ c->pool->log = log;
476
+
477
+ c->listening = ls;
478
+ c->local_sockaddr = ls->sockaddr;
479
+ c->local_socklen = ls->socklen;
480
+
481
+ #if (NGX_HAVE_MSGHDR_MSG_CONTROL)
482
+
483
+ if (ls->wildcard) {
484
+ struct cmsghdr *cmsg;
485
+ struct sockaddr *sockaddr;
486
+
487
+ sockaddr = ngx_palloc(c->pool, c->local_socklen);
488
+ if (sockaddr == NULL) {
489
+ ngx_close_accepted_connection(c);
490
+ return;
491
+ }
492
+
493
+ ngx_memcpy(sockaddr, c->local_sockaddr, c->local_socklen);
494
+ c->local_sockaddr = sockaddr;
495
+
496
+ for (cmsg = CMSG_FIRSTHDR(&msg);
497
+ cmsg != NULL;
498
+ cmsg = CMSG_NXTHDR(&msg, cmsg))
499
+ {
500
+
501
+ #if (NGX_HAVE_IP_RECVDSTADDR)
502
+
503
+ if (cmsg->cmsg_level == IPPROTO_IP
504
+ && cmsg->cmsg_type == IP_RECVDSTADDR
505
+ && sockaddr->sa_family == AF_INET)
506
+ {
507
+ struct in_addr *addr;
508
+ struct sockaddr_in *sin;
509
+
510
+ addr = (struct in_addr *) CMSG_DATA(cmsg);
511
+ sin = (struct sockaddr_in *) sockaddr;
512
+ sin->sin_addr = *addr;
513
+
514
+ break;
515
+ }
516
+
517
+ #elif (NGX_HAVE_IP_PKTINFO)
518
+
519
+ if (cmsg->cmsg_level == IPPROTO_IP
520
+ && cmsg->cmsg_type == IP_PKTINFO
521
+ && sockaddr->sa_family == AF_INET)
522
+ {
523
+ struct in_pktinfo *pkt;
524
+ struct sockaddr_in *sin;
525
+
526
+ pkt = (struct in_pktinfo *) CMSG_DATA(cmsg);
527
+ sin = (struct sockaddr_in *) sockaddr;
528
+ sin->sin_addr = pkt->ipi_addr;
529
+
530
+ break;
531
+ }
532
+
348
533
  #endif
349
534
 
350
- if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
351
- if (ngx_add_conn(c) == NGX_ERROR) {
535
+ #if (NGX_HAVE_INET6 && NGX_HAVE_IPV6_RECVPKTINFO)
536
+
537
+ if (cmsg->cmsg_level == IPPROTO_IPV6
538
+ && cmsg->cmsg_type == IPV6_PKTINFO
539
+ && sockaddr->sa_family == AF_INET6)
540
+ {
541
+ struct in6_pktinfo *pkt6;
542
+ struct sockaddr_in6 *sin6;
543
+
544
+ pkt6 = (struct in6_pktinfo *) CMSG_DATA(cmsg);
545
+ sin6 = (struct sockaddr_in6 *) sockaddr;
546
+ sin6->sin6_addr = pkt6->ipi6_addr;
547
+
548
+ break;
549
+ }
550
+
551
+ #endif
552
+
553
+ }
554
+ }
555
+
556
+ #endif
557
+
558
+ c->buffer = ngx_create_temp_buf(c->pool, n);
559
+ if (c->buffer == NULL) {
560
+ ngx_close_accepted_connection(c);
561
+ return;
562
+ }
563
+
564
+ c->buffer->last = ngx_cpymem(c->buffer->last, buffer, n);
565
+
566
+ rev = c->read;
567
+ wev = c->write;
568
+
569
+ wev->ready = 1;
570
+
571
+ rev->log = log;
572
+ wev->log = log;
573
+
574
+ /*
575
+ * TODO: MT: - ngx_atomic_fetch_add()
576
+ * or protection by critical section or light mutex
577
+ *
578
+ * TODO: MP: - allocated in a shared memory
579
+ * - ngx_atomic_fetch_add()
580
+ * or protection by critical section or light mutex
581
+ */
582
+
583
+ c->number = ngx_atomic_fetch_add(ngx_connection_counter, 1);
584
+
585
+ #if (NGX_STAT_STUB)
586
+ (void) ngx_atomic_fetch_add(ngx_stat_handled, 1);
587
+ #endif
588
+
589
+ if (ls->addr_ntop) {
590
+ c->addr_text.data = ngx_pnalloc(c->pool, ls->addr_text_max_len);
591
+ if (c->addr_text.data == NULL) {
592
+ ngx_close_accepted_connection(c);
593
+ return;
594
+ }
595
+
596
+ c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen,
597
+ c->addr_text.data,
598
+ ls->addr_text_max_len, 0);
599
+ if (c->addr_text.len == 0) {
352
600
  ngx_close_accepted_connection(c);
353
601
  return;
354
602
  }
355
603
  }
356
604
 
605
+ #if (NGX_DEBUG)
606
+ {
607
+ ngx_str_t addr;
608
+ u_char text[NGX_SOCKADDR_STRLEN];
609
+
610
+ ngx_debug_accepted_connection(ecf, c);
611
+
612
+ if (log->log_level & NGX_LOG_DEBUG_EVENT) {
613
+ addr.data = text;
614
+ addr.len = ngx_sock_ntop(c->sockaddr, c->socklen, text,
615
+ NGX_SOCKADDR_STRLEN, 1);
616
+
617
+ ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0,
618
+ "*%uA recvmsg: %V fd:%d n:%z",
619
+ c->number, &addr, c->fd, n);
620
+ }
621
+
622
+ }
623
+ #endif
624
+
357
625
  log->data = NULL;
358
626
  log->handler = NULL;
359
627
 
360
628
  ls->handler(c);
361
629
 
362
630
  if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
363
- ev->available--;
631
+ ev->available -= n;
364
632
  }
365
633
 
366
634
  } while (ev->available);
367
635
  }
368
636
 
637
+ #endif
638
+
369
639
 
370
640
  ngx_int_t
371
641
  ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
@@ -375,10 +645,7 @@ ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
375
645
  ngx_log_debug0(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
376
646
  "accept mutex locked");
377
647
 
378
- if (ngx_accept_mutex_held
379
- && ngx_accept_events == 0
380
- && !(ngx_event_flags & NGX_USE_RTSIG_EVENT))
381
- {
648
+ if (ngx_accept_mutex_held && ngx_accept_events == 0) {
382
649
  return NGX_OK;
383
650
  }
384
651
 
@@ -397,7 +664,7 @@ ngx_trylock_accept_mutex(ngx_cycle_t *cycle)
397
664
  "accept mutex lock failed: %ui", ngx_accept_mutex_held);
398
665
 
399
666
  if (ngx_accept_mutex_held) {
400
- if (ngx_disable_accept_events(cycle) == NGX_ERROR) {
667
+ if (ngx_disable_accept_events(cycle, 0) == NGX_ERROR) {
401
668
  return NGX_ERROR;
402
669
  }
403
670
 
@@ -420,20 +687,12 @@ ngx_enable_accept_events(ngx_cycle_t *cycle)
420
687
 
421
688
  c = ls[i].connection;
422
689
 
423
- if (c->read->active) {
690
+ if (c == NULL || c->read->active) {
424
691
  continue;
425
692
  }
426
693
 
427
- if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
428
-
429
- if (ngx_add_conn(c) == NGX_ERROR) {
430
- return NGX_ERROR;
431
- }
432
-
433
- } else {
434
- if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) {
435
- return NGX_ERROR;
436
- }
694
+ if (ngx_add_event(c->read, NGX_READ_EVENT, 0) == NGX_ERROR) {
695
+ return NGX_ERROR;
437
696
  }
438
697
  }
439
698
 
@@ -442,7 +701,7 @@ ngx_enable_accept_events(ngx_cycle_t *cycle)
442
701
 
443
702
 
444
703
  static ngx_int_t
445
- ngx_disable_accept_events(ngx_cycle_t *cycle)
704
+ ngx_disable_accept_events(ngx_cycle_t *cycle, ngx_uint_t all)
446
705
  {
447
706
  ngx_uint_t i;
448
707
  ngx_listening_t *ls;
@@ -453,21 +712,27 @@ ngx_disable_accept_events(ngx_cycle_t *cycle)
453
712
 
454
713
  c = ls[i].connection;
455
714
 
456
- if (!c->read->active) {
715
+ if (c == NULL || !c->read->active) {
457
716
  continue;
458
717
  }
459
718
 
460
- if (ngx_event_flags & NGX_USE_RTSIG_EVENT) {
461
- if (ngx_del_conn(c, NGX_DISABLE_EVENT) == NGX_ERROR) {
462
- return NGX_ERROR;
463
- }
719
+ #if (NGX_HAVE_REUSEPORT)
464
720
 
465
- } else {
466
- if (ngx_del_event(c->read, NGX_READ_EVENT, NGX_DISABLE_EVENT)
467
- == NGX_ERROR)
468
- {
469
- return NGX_ERROR;
470
- }
721
+ /*
722
+ * do not disable accept on worker's own sockets
723
+ * when disabling accept events due to accept mutex
724
+ */
725
+
726
+ if (ls[i].reuseport && !all) {
727
+ continue;
728
+ }
729
+
730
+ #endif
731
+
732
+ if (ngx_del_event(c->read, NGX_READ_EVENT, NGX_DISABLE_EVENT)
733
+ == NGX_ERROR)
734
+ {
735
+ return NGX_ERROR;
471
736
  }
472
737
  }
473
738
 
@@ -485,7 +750,7 @@ ngx_close_accepted_connection(ngx_connection_t *c)
485
750
  fd = c->fd;
486
751
  c->fd = (ngx_socket_t) -1;
487
752
 
488
- if (ngx_close_socket(fd) == -1) {
753
+ if (!c->shared && ngx_close_socket(fd) == -1) {
489
754
  ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno,
490
755
  ngx_close_socket_n " failed");
491
756
  }
@@ -506,3 +771,64 @@ ngx_accept_log_error(ngx_log_t *log, u_char *buf, size_t len)
506
771
  return ngx_snprintf(buf, len, " while accepting new connection on %V",
507
772
  log->data);
508
773
  }
774
+
775
+
776
+ #if (NGX_DEBUG)
777
+
778
+ static void
779
+ ngx_debug_accepted_connection(ngx_event_conf_t *ecf, ngx_connection_t *c)
780
+ {
781
+ struct sockaddr_in *sin;
782
+ ngx_cidr_t *cidr;
783
+ ngx_uint_t i;
784
+ #if (NGX_HAVE_INET6)
785
+ struct sockaddr_in6 *sin6;
786
+ ngx_uint_t n;
787
+ #endif
788
+
789
+ cidr = ecf->debug_connection.elts;
790
+ for (i = 0; i < ecf->debug_connection.nelts; i++) {
791
+ if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) {
792
+ goto next;
793
+ }
794
+
795
+ switch (cidr[i].family) {
796
+
797
+ #if (NGX_HAVE_INET6)
798
+ case AF_INET6:
799
+ sin6 = (struct sockaddr_in6 *) c->sockaddr;
800
+ for (n = 0; n < 16; n++) {
801
+ if ((sin6->sin6_addr.s6_addr[n]
802
+ & cidr[i].u.in6.mask.s6_addr[n])
803
+ != cidr[i].u.in6.addr.s6_addr[n])
804
+ {
805
+ goto next;
806
+ }
807
+ }
808
+ break;
809
+ #endif
810
+
811
+ #if (NGX_HAVE_UNIX_DOMAIN)
812
+ case AF_UNIX:
813
+ break;
814
+ #endif
815
+
816
+ default: /* AF_INET */
817
+ sin = (struct sockaddr_in *) c->sockaddr;
818
+ if ((sin->sin_addr.s_addr & cidr[i].u.in.mask)
819
+ != cidr[i].u.in.addr)
820
+ {
821
+ goto next;
822
+ }
823
+ break;
824
+ }
825
+
826
+ c->log->log_level = NGX_LOG_DEBUG_CONNECTION|NGX_LOG_DEBUG_ALL;
827
+ break;
828
+
829
+ next:
830
+ continue;
831
+ }
832
+ }
833
+
834
+ #endif