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
@@ -39,6 +39,7 @@ void ngx_single_process_cycle(ngx_cycle_t *cycle);
39
39
 
40
40
 
41
41
  extern ngx_uint_t ngx_process;
42
+ extern ngx_uint_t ngx_worker;
42
43
  extern ngx_pid_t ngx_pid;
43
44
  extern ngx_pid_t ngx_new_binary;
44
45
  extern ngx_uint_t ngx_inherited;
@@ -101,12 +101,32 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
101
101
  }
102
102
 
103
103
  ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
104
- "readv: %d, last:%d", vec.nelts, iov->iov_len);
104
+ "readv: %ui, last:%uz", vec.nelts, iov->iov_len);
105
105
 
106
106
  do {
107
107
  n = readv(c->fd, (struct iovec *) vec.elts, vec.nelts);
108
108
 
109
- if (n >= 0) {
109
+ if (n == 0) {
110
+ rev->ready = 0;
111
+ rev->eof = 1;
112
+
113
+ #if (NGX_HAVE_KQUEUE)
114
+
115
+ /*
116
+ * on FreeBSD readv() may return 0 on closed socket
117
+ * even if kqueue reported about available data
118
+ */
119
+
120
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
121
+ rev->available = 0;
122
+ }
123
+
124
+ #endif
125
+
126
+ return 0;
127
+ }
128
+
129
+ if (n > 0) {
110
130
 
111
131
  #if (NGX_HAVE_KQUEUE)
112
132
 
@@ -115,7 +135,7 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
115
135
 
116
136
  /*
117
137
  * rev->available may be negative here because some additional
118
- * bytes may be received between kevent() and recv()
138
+ * bytes may be received between kevent() and readv()
119
139
  */
120
140
 
121
141
  if (rev->available <= 0) {
@@ -123,42 +143,18 @@ ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *chain, off_t limit)
123
143
  rev->ready = 0;
124
144
  }
125
145
 
126
- if (rev->available < 0) {
127
- rev->available = 0;
128
- }
129
- }
130
-
131
- if (n == 0) {
132
-
133
- /*
134
- * on FreeBSD recv() may return 0 on closed socket
135
- * even if kqueue reported about available data
136
- */
137
-
138
- #if 0
139
- ngx_log_error(NGX_LOG_ALERT, c->log, 0,
140
- "readv() returned 0 while kevent() reported "
141
- "%d available bytes", rev->available);
142
- #endif
143
-
144
- rev->ready = 0;
145
- rev->eof = 1;
146
146
  rev->available = 0;
147
147
  }
148
148
 
149
149
  return n;
150
150
  }
151
151
 
152
- #endif /* NGX_HAVE_KQUEUE */
152
+ #endif
153
153
 
154
154
  if (n < size && !(ngx_event_flags & NGX_USE_GREEDY_EVENT)) {
155
155
  rev->ready = 0;
156
156
  }
157
157
 
158
- if (n == 0) {
159
- rev->eof = 1;
160
- }
161
-
162
158
  return n;
163
159
  }
164
160
 
@@ -10,8 +10,6 @@
10
10
  #include <ngx_event.h>
11
11
 
12
12
 
13
- #if (NGX_HAVE_KQUEUE)
14
-
15
13
  ssize_t
16
14
  ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
17
15
  {
@@ -21,6 +19,8 @@ ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
21
19
 
22
20
  rev = c->read;
23
21
 
22
+ #if (NGX_HAVE_KQUEUE)
23
+
24
24
  if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
25
25
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
26
26
  "recv: eof:%d, avail:%d, err:%d",
@@ -48,13 +48,38 @@ ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
48
48
  }
49
49
  }
50
50
 
51
+ #endif
52
+
51
53
  do {
52
54
  n = recv(c->fd, buf, size, 0);
53
55
 
54
56
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
55
- "recv: fd:%d %d of %d", c->fd, n, size);
57
+ "recv: fd:%d %z of %uz", c->fd, n, size);
58
+
59
+ if (n == 0) {
60
+ rev->ready = 0;
61
+ rev->eof = 1;
62
+
63
+ #if (NGX_HAVE_KQUEUE)
64
+
65
+ /*
66
+ * on FreeBSD recv() may return 0 on closed socket
67
+ * even if kqueue reported about available data
68
+ */
69
+
70
+ if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
71
+ rev->available = 0;
72
+ }
73
+
74
+ #endif
75
+
76
+ return 0;
77
+ }
78
+
79
+ if (n > 0) {
80
+
81
+ #if (NGX_HAVE_KQUEUE)
56
82
 
57
- if (n >= 0) {
58
83
  if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
59
84
  rev->available -= n;
60
85
 
@@ -68,85 +93,13 @@ ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
68
93
  rev->ready = 0;
69
94
  }
70
95
 
71
- if (rev->available < 0) {
72
- rev->available = 0;
73
- }
74
- }
75
-
76
- if (n == 0) {
77
-
78
- /*
79
- * on FreeBSD recv() may return 0 on closed socket
80
- * even if kqueue reported about available data
81
- */
82
-
83
- rev->ready = 0;
84
- rev->eof = 1;
85
96
  rev->available = 0;
86
97
  }
87
98
 
88
99
  return n;
89
100
  }
90
101
 
91
- if ((size_t) n < size
92
- && !(ngx_event_flags & NGX_USE_GREEDY_EVENT))
93
- {
94
- rev->ready = 0;
95
- }
96
-
97
- if (n == 0) {
98
- rev->eof = 1;
99
- }
100
-
101
- return n;
102
- }
103
-
104
- err = ngx_socket_errno;
105
-
106
- if (err == NGX_EAGAIN || err == NGX_EINTR) {
107
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
108
- "recv() not ready");
109
- n = NGX_AGAIN;
110
-
111
- } else {
112
- n = ngx_connection_error(c, err, "recv() failed");
113
- break;
114
- }
115
-
116
- } while (err == NGX_EINTR);
117
-
118
- rev->ready = 0;
119
-
120
- if (n == NGX_ERROR) {
121
- rev->error = 1;
122
- }
123
-
124
- return n;
125
- }
126
-
127
- #else /* ! NGX_HAVE_KQUEUE */
128
-
129
- ssize_t
130
- ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
131
- {
132
- ssize_t n;
133
- ngx_err_t err;
134
- ngx_event_t *rev;
135
-
136
- rev = c->read;
137
-
138
- do {
139
- n = recv(c->fd, buf, size, 0);
140
-
141
- ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
142
- "recv: fd:%d %d of %d", c->fd, n, size);
143
-
144
- if (n == 0) {
145
- rev->ready = 0;
146
- rev->eof = 1;
147
- return n;
148
-
149
- } else if (n > 0) {
102
+ #endif
150
103
 
151
104
  if ((size_t) n < size
152
105
  && !(ngx_event_flags & NGX_USE_GREEDY_EVENT))
@@ -179,5 +132,3 @@ ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
179
132
 
180
133
  return n;
181
134
  }
182
-
183
- #endif /* NGX_HAVE_KQUEUE */
@@ -34,7 +34,7 @@ ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size)
34
34
  n = send(c->fd, buf, size, 0);
35
35
 
36
36
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
37
- "send: fd:%d %d of %d", c->fd, n, size);
37
+ "send: fd:%d %z of %uz", c->fd, n, size);
38
38
 
39
39
  if (n > 0) {
40
40
  if (n < (ssize_t) size) {
@@ -10,29 +10,20 @@
10
10
 
11
11
  #if (NGX_HAVE_CPUSET_SETAFFINITY)
12
12
 
13
- #include <sys/cpuset.h>
14
-
15
13
  void
16
- ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log)
14
+ ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log)
17
15
  {
18
- cpuset_t mask;
19
16
  ngx_uint_t i;
20
17
 
21
- ngx_log_error(NGX_LOG_NOTICE, log, 0,
22
- "cpuset_setaffinity(0x%08Xl)", cpu_affinity);
23
-
24
- CPU_ZERO(&mask);
25
- i = 0;
26
- do {
27
- if (cpu_affinity & 1) {
28
- CPU_SET(i, &mask);
18
+ for (i = 0; i < CPU_SETSIZE; i++) {
19
+ if (CPU_ISSET(i, cpu_affinity)) {
20
+ ngx_log_error(NGX_LOG_NOTICE, log, 0,
21
+ "cpuset_setaffinity(): using cpu #%ui", i);
29
22
  }
30
- i++;
31
- cpu_affinity >>= 1;
32
- } while (cpu_affinity);
23
+ }
33
24
 
34
25
  if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
35
- sizeof(cpuset_t), &mask) == -1)
26
+ sizeof(cpuset_t), cpu_affinity) == -1)
36
27
  {
37
28
  ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
38
29
  "cpuset_setaffinity() failed");
@@ -42,25 +33,18 @@ ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log)
42
33
  #elif (NGX_HAVE_SCHED_SETAFFINITY)
43
34
 
44
35
  void
45
- ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log)
36
+ ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log)
46
37
  {
47
- cpu_set_t mask;
48
38
  ngx_uint_t i;
49
39
 
50
- ngx_log_error(NGX_LOG_NOTICE, log, 0,
51
- "sched_setaffinity(0x%08Xl)", cpu_affinity);
52
-
53
- CPU_ZERO(&mask);
54
- i = 0;
55
- do {
56
- if (cpu_affinity & 1) {
57
- CPU_SET(i, &mask);
40
+ for (i = 0; i < CPU_SETSIZE; i++) {
41
+ if (CPU_ISSET(i, cpu_affinity)) {
42
+ ngx_log_error(NGX_LOG_NOTICE, log, 0,
43
+ "sched_setaffinity(): using cpu #%ui", i);
58
44
  }
59
- i++;
60
- cpu_affinity >>= 1;
61
- } while (cpu_affinity);
45
+ }
62
46
 
63
- if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) == -1) {
47
+ if (sched_setaffinity(0, sizeof(cpu_set_t), cpu_affinity) == -1) {
64
48
  ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
65
49
  "sched_setaffinity() failed");
66
50
  }
@@ -11,12 +11,26 @@
11
11
 
12
12
  #define NGX_HAVE_CPU_AFFINITY 1
13
13
 
14
- void ngx_setaffinity(uint64_t cpu_affinity, ngx_log_t *log);
14
+ #if (NGX_HAVE_SCHED_SETAFFINITY)
15
+
16
+ typedef cpu_set_t ngx_cpuset_t;
17
+
18
+ #elif (NGX_HAVE_CPUSET_SETAFFINITY)
19
+
20
+ #include <sys/cpuset.h>
21
+
22
+ typedef cpuset_t ngx_cpuset_t;
23
+
24
+ #endif
25
+
26
+ void ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log);
15
27
 
16
28
  #else
17
29
 
18
30
  #define ngx_setaffinity(cpu_affinity, log)
19
31
 
32
+ typedef uint64_t ngx_cpuset_t;
33
+
20
34
  #endif
21
35
 
22
36
 
@@ -55,6 +55,8 @@
55
55
  #include <inttypes.h>
56
56
  #include <crypt.h>
57
57
 
58
+ #include <dlfcn.h>
59
+
58
60
  #define NGX_ALIGNMENT _MAX_ALIGNMENT
59
61
 
60
62
  #include <ngx_auto_config.h>
@@ -19,6 +19,7 @@ static ngx_os_io_t ngx_solaris_io = {
19
19
  ngx_readv_chain,
20
20
  ngx_udp_unix_recv,
21
21
  ngx_unix_send,
22
+ ngx_udp_unix_send,
22
23
  #if (NGX_HAVE_SENDFILE)
23
24
  ngx_solaris_sendfilev_chain,
24
25
  NGX_IO_SENDFILE
@@ -48,6 +48,7 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
48
48
  ssize_t n;
49
49
  ngx_int_t eintr;
50
50
  ngx_err_t err;
51
+ ngx_buf_t *file;
51
52
  ngx_uint_t nsfv;
52
53
  sendfilevec_t *sfv, sfvs[NGX_SENDFILEVECS];
53
54
  ngx_event_t *wev;
@@ -77,6 +78,7 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
77
78
  fd = SFV_FD_SELF;
78
79
  prev = NULL;
79
80
  fprev = 0;
81
+ file = NULL;
80
82
  sfv = NULL;
81
83
  eintr = 0;
82
84
  sent = 0;
@@ -153,6 +155,7 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
153
155
  sfv->sfv_len = (size_t) size;
154
156
  }
155
157
 
158
+ file = cl->buf;
156
159
  fprev = cl->buf->file_pos + size;
157
160
  send += size;
158
161
  }
@@ -179,6 +182,26 @@ ngx_solaris_sendfilev_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
179
182
 
180
183
  ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, err,
181
184
  "sendfilev() sent only %uz bytes", sent);
185
+
186
+ } else if (n == 0 && sent == 0) {
187
+
188
+ /*
189
+ * sendfilev() is documented to return -1 with errno
190
+ * set to EINVAL if svf_len is greater than the file size,
191
+ * but at least Solaris 11 returns 0 instead
192
+ */
193
+
194
+ if (file) {
195
+ ngx_log_error(NGX_LOG_ALERT, c->log, 0,
196
+ "sendfilev() reported that \"%s\" was truncated at %O",
197
+ file->file->name.data, file->file_pos);
198
+
199
+ } else {
200
+ ngx_log_error(NGX_LOG_ALERT, c->log, 0,
201
+ "sendfilev() returned 0 with memory buffers");
202
+ }
203
+
204
+ return NGX_CHAIN_ERROR;
182
205
  }
183
206
 
184
207
  ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
@@ -38,6 +38,6 @@
38
38
  /
39
39
  / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ]
40
40
 
41
- .inline ngx_cpu_pause,0
42
- rep; nop
43
- .end
41
+ .inline ngx_cpu_pause,0
42
+ rep; nop
43
+ .end
@@ -39,6 +39,6 @@
39
39
  /
40
40
  / ld.so.1: nginx: fatal: hardware capability unsupported: 0x2000 [ PAUSE ]
41
41
 
42
- .inline ngx_cpu_pause,0
43
- rep; nop
44
- .end
42
+ .inline ngx_cpu_pause,0
43
+ rep; nop
44
+ .end
@@ -10,8 +10,6 @@
10
10
  #include <ngx_event.h>
11
11
 
12
12
 
13
- #if (NGX_HAVE_KQUEUE)
14
-
15
13
  ssize_t
16
14
  ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
17
15
  {
@@ -25,9 +23,12 @@ ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
25
23
  n = recv(c->fd, buf, size, 0);
26
24
 
27
25
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
28
- "recv: fd:%d %d of %d", c->fd, n, size);
26
+ "recv: fd:%d %z of %uz", c->fd, n, size);
29
27
 
30
28
  if (n >= 0) {
29
+
30
+ #if (NGX_HAVE_KQUEUE)
31
+
31
32
  if (ngx_event_flags & NGX_USE_KQUEUE_EVENT) {
32
33
  rev->available -= n;
33
34
 
@@ -42,50 +43,8 @@ ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
42
43
  }
43
44
  }
44
45
 
45
- return n;
46
- }
47
-
48
- err = ngx_socket_errno;
49
-
50
- if (err == NGX_EAGAIN || err == NGX_EINTR) {
51
- ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, err,
52
- "recv() not ready");
53
- n = NGX_AGAIN;
54
-
55
- } else {
56
- n = ngx_connection_error(c, err, "recv() failed");
57
- break;
58
- }
59
-
60
- } while (err == NGX_EINTR);
61
-
62
- rev->ready = 0;
46
+ #endif
63
47
 
64
- if (n == NGX_ERROR) {
65
- rev->error = 1;
66
- }
67
-
68
- return n;
69
- }
70
-
71
- #else /* ! NGX_HAVE_KQUEUE */
72
-
73
- ssize_t
74
- ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
75
- {
76
- ssize_t n;
77
- ngx_err_t err;
78
- ngx_event_t *rev;
79
-
80
- rev = c->read;
81
-
82
- do {
83
- n = recv(c->fd, buf, size, 0);
84
-
85
- ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
86
- "recv: fd:%d %d of %d", c->fd, n, size);
87
-
88
- if (n >= 0) {
89
48
  return n;
90
49
  }
91
50
 
@@ -111,5 +70,3 @@ ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size)
111
70
 
112
71
  return n;
113
72
  }
114
-
115
- #endif /* NGX_HAVE_KQUEUE */