nginxtra 1.4.7.9 → 1.6.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (169) 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 +286 -19
  6. data/vendor/nginx/CHANGES.ru +296 -22
  7. data/vendor/nginx/auto/cc/clang +4 -3
  8. data/vendor/nginx/auto/cc/conf +23 -0
  9. data/vendor/nginx/auto/cc/msvc +1 -0
  10. data/vendor/nginx/auto/cc/name +1 -1
  11. data/vendor/nginx/auto/cc/owc +4 -4
  12. data/vendor/nginx/auto/cc/sunc +1 -1
  13. data/vendor/nginx/auto/endianness +2 -2
  14. data/vendor/nginx/auto/feature +1 -1
  15. data/vendor/nginx/auto/include +1 -1
  16. data/vendor/nginx/auto/lib/libatomic/make +3 -1
  17. data/vendor/nginx/auto/lib/openssl/conf +4 -0
  18. data/vendor/nginx/auto/lib/openssl/make +1 -1
  19. data/vendor/nginx/auto/lib/pcre/conf +5 -0
  20. data/vendor/nginx/auto/lib/pcre/make +11 -11
  21. data/vendor/nginx/auto/lib/pcre/makefile.bcc +4 -3
  22. data/vendor/nginx/auto/lib/pcre/makefile.msvc +2 -1
  23. data/vendor/nginx/auto/lib/pcre/makefile.owc +2 -1
  24. data/vendor/nginx/auto/lib/perl/make +1 -0
  25. data/vendor/nginx/auto/lib/test +1 -1
  26. data/vendor/nginx/auto/lib/zlib/make +22 -1
  27. data/vendor/nginx/auto/modules +8 -0
  28. data/vendor/nginx/auto/options +3 -0
  29. data/vendor/nginx/auto/os/darwin +1 -1
  30. data/vendor/nginx/auto/os/linux +32 -0
  31. data/vendor/nginx/auto/os/win32 +12 -1
  32. data/vendor/nginx/auto/sources +8 -2
  33. data/vendor/nginx/auto/types/sizeof +1 -1
  34. data/vendor/nginx/auto/types/typedef +1 -1
  35. data/vendor/nginx/auto/types/uintptr_t +1 -1
  36. data/vendor/nginx/auto/unix +13 -1
  37. data/vendor/nginx/conf/mime.types +11 -2
  38. data/vendor/nginx/conf/nginx.conf +3 -4
  39. data/vendor/nginx/contrib/README +6 -0
  40. data/vendor/nginx/contrib/vim/ftdetect/nginx.vim +4 -0
  41. data/vendor/nginx/contrib/vim/indent/nginx.vim +11 -0
  42. data/vendor/nginx/contrib/vim/syntax/nginx.vim +703 -0
  43. data/vendor/nginx/src/core/nginx.c +2 -7
  44. data/vendor/nginx/src/core/nginx.h +2 -2
  45. data/vendor/nginx/src/core/ngx_conf_file.c +8 -88
  46. data/vendor/nginx/src/core/ngx_conf_file.h +3 -3
  47. data/vendor/nginx/src/core/ngx_config.h +2 -2
  48. data/vendor/nginx/src/core/ngx_connection.c +100 -29
  49. data/vendor/nginx/src/core/ngx_connection.h +11 -0
  50. data/vendor/nginx/src/core/ngx_core.h +1 -0
  51. data/vendor/nginx/src/core/ngx_cycle.c +23 -99
  52. data/vendor/nginx/src/core/ngx_cycle.h +2 -0
  53. data/vendor/nginx/src/core/ngx_file.c +100 -8
  54. data/vendor/nginx/src/core/ngx_file.h +3 -0
  55. data/vendor/nginx/src/core/ngx_hash.c +6 -9
  56. data/vendor/nginx/src/core/ngx_inet.c +93 -5
  57. data/vendor/nginx/src/core/ngx_inet.h +4 -2
  58. data/vendor/nginx/src/core/ngx_list.c +1 -9
  59. data/vendor/nginx/src/core/ngx_log.c +132 -30
  60. data/vendor/nginx/src/core/ngx_log.h +5 -2
  61. data/vendor/nginx/src/core/ngx_open_file_cache.c +67 -1
  62. data/vendor/nginx/src/core/ngx_palloc.c +5 -2
  63. data/vendor/nginx/src/core/ngx_proxy_protocol.c +91 -0
  64. data/vendor/nginx/src/core/ngx_proxy_protocol.h +23 -0
  65. data/vendor/nginx/src/core/ngx_resolver.c +1080 -285
  66. data/vendor/nginx/src/core/ngx_resolver.h +33 -3
  67. data/vendor/nginx/src/core/ngx_slab.c +7 -2
  68. data/vendor/nginx/src/core/ngx_slab.h +2 -0
  69. data/vendor/nginx/src/core/ngx_string.c +78 -13
  70. data/vendor/nginx/src/core/ngx_string.h +2 -0
  71. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +2 -2
  72. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +13 -5
  73. data/vendor/nginx/src/event/modules/ngx_select_module.c +1 -1
  74. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +2 -2
  75. data/vendor/nginx/src/event/ngx_event.c +0 -1
  76. data/vendor/nginx/src/event/ngx_event.h +7 -6
  77. data/vendor/nginx/src/event/ngx_event_accept.c +6 -4
  78. data/vendor/nginx/src/event/ngx_event_connect.c +2 -2
  79. data/vendor/nginx/src/event/ngx_event_openssl.c +304 -13
  80. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -1
  81. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +35 -23
  82. data/vendor/nginx/src/event/ngx_event_pipe.c +15 -30
  83. data/vendor/nginx/src/http/modules/ngx_http_access_module.c +115 -35
  84. data/vendor/nginx/src/http/modules/ngx_http_auth_basic_module.c +1 -1
  85. data/vendor/nginx/src/http/modules/ngx_http_auth_request_module.c +444 -0
  86. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +2 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +1 -1
  88. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +1 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +251 -36
  90. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -5
  91. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +5 -3
  92. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +1 -1
  93. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +4 -0
  94. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +8 -2
  95. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +5 -1
  96. data/vendor/nginx/src/http/modules/ngx_http_map_module.c +3 -3
  97. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +21 -10
  98. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +669 -197
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +93 -60
  100. data/vendor/nginx/src/http/modules/ngx_http_range_filter_module.c +13 -6
  101. data/vendor/nginx/src/http/modules/ngx_http_realip_module.c +20 -1
  102. data/vendor/nginx/src/http/modules/ngx_http_referer_module.c +132 -74
  103. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +18 -12
  104. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +22 -20
  105. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +121 -3
  106. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +5 -0
  107. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +3 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +123 -91
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +29 -19
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +2 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +215 -19
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +32 -6
  113. data/vendor/nginx/src/http/modules/perl/nginx.xs +4 -7
  114. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -2
  115. data/vendor/nginx/src/http/ngx_http.c +17 -7
  116. data/vendor/nginx/src/http/ngx_http_cache.h +4 -2
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +4 -2
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +63 -50
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +5 -0
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +115 -3
  121. data/vendor/nginx/src/http/ngx_http_header_filter_module.c +9 -6
  122. data/vendor/nginx/src/http/ngx_http_parse.c +88 -10
  123. data/vendor/nginx/src/http/ngx_http_postpone_filter_module.c +2 -4
  124. data/vendor/nginx/src/http/ngx_http_request.c +116 -8
  125. data/vendor/nginx/src/http/ngx_http_request.h +5 -1
  126. data/vendor/nginx/src/http/ngx_http_request_body.c +7 -7
  127. data/vendor/nginx/src/http/ngx_http_script.c +6 -5
  128. data/vendor/nginx/src/http/ngx_http_spdy.c +889 -271
  129. data/vendor/nginx/src/http/ngx_http_spdy.h +51 -28
  130. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +382 -167
  131. data/vendor/nginx/src/http/ngx_http_spdy_module.c +65 -8
  132. data/vendor/nginx/src/http/ngx_http_spdy_module.h +5 -0
  133. data/vendor/nginx/src/http/ngx_http_special_response.c +1 -1
  134. data/vendor/nginx/src/http/ngx_http_upstream.c +290 -114
  135. data/vendor/nginx/src/http/ngx_http_upstream.h +9 -5
  136. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +32 -24
  137. data/vendor/nginx/src/http/ngx_http_variables.c +40 -6
  138. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +12 -5
  139. data/vendor/nginx/src/mail/ngx_mail.c +4 -2
  140. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  141. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +0 -1
  142. data/vendor/nginx/src/mail/ngx_mail_core_module.c +2 -1
  143. data/vendor/nginx/src/mail/ngx_mail_handler.c +17 -4
  144. data/vendor/nginx/src/mail/ngx_mail_parse.c +32 -2
  145. data/vendor/nginx/src/mail/ngx_mail_proxy_module.c +54 -7
  146. data/vendor/nginx/src/mail/ngx_mail_smtp_handler.c +50 -78
  147. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +48 -11
  148. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +3 -0
  149. data/vendor/nginx/src/os/unix/ngx_channel.c +3 -1
  150. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +1 -0
  151. data/vendor/nginx/src/os/unix/ngx_darwin_init.c +1 -1
  152. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +14 -16
  153. data/vendor/nginx/src/os/unix/ngx_errno.h +3 -0
  154. data/vendor/nginx/src/os/unix/ngx_files.h +10 -16
  155. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +6 -0
  156. data/vendor/nginx/src/os/unix/ngx_freebsd_init.c +1 -1
  157. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +1 -1
  158. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +2 -2
  159. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +17 -19
  160. data/vendor/nginx/src/os/unix/ngx_linux_config.h +8 -2
  161. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +20 -22
  162. data/vendor/nginx/src/os/unix/ngx_posix_config.h +1 -0
  163. data/vendor/nginx/src/os/unix/ngx_process.c +5 -0
  164. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +15 -3
  165. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +2 -1
  166. data/vendor/nginx/src/os/unix/ngx_recv.c +4 -1
  167. data/vendor/nginx/src/os/unix/ngx_solaris_config.h +1 -0
  168. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +14 -16
  169. metadata +8 -2
@@ -387,13 +387,8 @@ main(int argc, char *const *argv)
387
387
  return 1;
388
388
  }
389
389
 
390
- if (cycle->log->file->fd != ngx_stderr) {
391
-
392
- if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
393
- ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
394
- ngx_set_stderr_n " failed");
395
- return 1;
396
- }
390
+ if (ngx_log_redirect_stderr(cycle) != NGX_OK) {
391
+ return 1;
397
392
  }
398
393
 
399
394
  if (log->file->fd != ngx_stderr) {
@@ -9,8 +9,8 @@
9
9
  #define _NGINX_H_INCLUDED_
10
10
 
11
11
 
12
- #define nginx_version 1004007
13
- #define NGINX_VERSION "1.4.7"
12
+ #define nginx_version 1006000
13
+ #define NGINX_VERSION "1.6.0"
14
14
  #define NGINX_VER "nginx/" NGINX_VERSION
15
15
 
16
16
  #define NGINX_VAR "NGINX"
@@ -12,7 +12,6 @@
12
12
 
13
13
  static ngx_int_t ngx_conf_handler(ngx_conf_t *cf, ngx_int_t last);
14
14
  static ngx_int_t ngx_conf_read_token(ngx_conf_t *cf);
15
- static ngx_int_t ngx_conf_test_full_name(ngx_str_t *name);
16
15
  static void ngx_conf_flush_files(ngx_cycle_t *cycle);
17
16
 
18
17
 
@@ -225,6 +224,11 @@ ngx_conf_parse(ngx_conf_t *cf, ngx_str_t *filename)
225
224
  * "types { ... }" directive
226
225
  */
227
226
 
227
+ if (rc == NGX_CONF_BLOCK_START) {
228
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "unexpected \"{\"");
229
+ goto failed;
230
+ }
231
+
228
232
  rv = (*cf->handler)(cf, NULL, cf->handler_conf);
229
233
  if (rv == NGX_CONF_OK) {
230
234
  continue;
@@ -796,95 +800,11 @@ ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
796
800
  ngx_int_t
797
801
  ngx_conf_full_name(ngx_cycle_t *cycle, ngx_str_t *name, ngx_uint_t conf_prefix)
798
802
  {
799
- size_t len;
800
- u_char *p, *n, *prefix;
801
- ngx_int_t rc;
802
-
803
- rc = ngx_conf_test_full_name(name);
804
-
805
- if (rc == NGX_OK) {
806
- return rc;
807
- }
808
-
809
- if (conf_prefix) {
810
- len = cycle->conf_prefix.len;
811
- prefix = cycle->conf_prefix.data;
812
-
813
- } else {
814
- len = cycle->prefix.len;
815
- prefix = cycle->prefix.data;
816
- }
817
-
818
- #if (NGX_WIN32)
819
-
820
- if (rc == 2) {
821
- len = rc;
822
- }
823
-
824
- #endif
825
-
826
- n = ngx_pnalloc(cycle->pool, len + name->len + 1);
827
- if (n == NULL) {
828
- return NGX_ERROR;
829
- }
830
-
831
- p = ngx_cpymem(n, prefix, len);
832
- ngx_cpystrn(p, name->data, name->len + 1);
833
-
834
- name->len += len;
835
- name->data = n;
836
-
837
- return NGX_OK;
838
- }
839
-
840
-
841
- static ngx_int_t
842
- ngx_conf_test_full_name(ngx_str_t *name)
843
- {
844
- #if (NGX_WIN32)
845
- u_char c0, c1;
846
-
847
- c0 = name->data[0];
848
-
849
- if (name->len < 2) {
850
- if (c0 == '/') {
851
- return 2;
852
- }
803
+ ngx_str_t *prefix;
853
804
 
854
- return NGX_DECLINED;
855
- }
856
-
857
- c1 = name->data[1];
858
-
859
- if (c1 == ':') {
860
- c0 |= 0x20;
805
+ prefix = conf_prefix ? &cycle->conf_prefix : &cycle->prefix;
861
806
 
862
- if ((c0 >= 'a' && c0 <= 'z')) {
863
- return NGX_OK;
864
- }
865
-
866
- return NGX_DECLINED;
867
- }
868
-
869
- if (c1 == '/') {
870
- return NGX_OK;
871
- }
872
-
873
- if (c0 == '/') {
874
- return 2;
875
- }
876
-
877
- return NGX_DECLINED;
878
-
879
- #else
880
-
881
- if (name->data[0] == '/') {
882
- return NGX_OK;
883
- }
884
-
885
- return NGX_DECLINED;
886
-
887
- #endif
807
+ return ngx_get_full_name(cycle->pool, prefix, name);
888
808
  }
889
809
 
890
810
 
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
 
8
- #ifndef _NGX_HTTP_CONF_FILE_H_INCLUDED_
9
- #define _NGX_HTTP_CONF_FILE_H_INCLUDED_
8
+ #ifndef _NGX_CONF_FILE_H_INCLUDED_
9
+ #define _NGX_CONF_FILE_H_INCLUDED_
10
10
 
11
11
 
12
12
  #include <ngx_config.h>
@@ -337,4 +337,4 @@ extern ngx_uint_t ngx_max_module;
337
337
  extern ngx_module_t *ngx_modules[];
338
338
 
339
339
 
340
- #endif /* _NGX_HTTP_CONF_FILE_H_INCLUDED_ */
340
+ #endif /* _NGX_CONF_FILE_H_INCLUDED_ */
@@ -80,8 +80,8 @@ typedef uintptr_t ngx_uint_t;
80
80
  typedef intptr_t ngx_flag_t;
81
81
 
82
82
 
83
- #define NGX_INT32_LEN sizeof("-2147483648") - 1
84
- #define NGX_INT64_LEN sizeof("-9223372036854775808") - 1
83
+ #define NGX_INT32_LEN (sizeof("-2147483648") - 1)
84
+ #define NGX_INT64_LEN (sizeof("-9223372036854775808") - 1)
85
85
 
86
86
  #if (NGX_PTR_SIZE == 4)
87
87
  #define NGX_INT_T_LEN NGX_INT32_LEN
@@ -41,7 +41,7 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
41
41
  ls->sockaddr = sa;
42
42
  ls->socklen = socklen;
43
43
 
44
- len = ngx_sock_ntop(sa, text, NGX_SOCKADDR_STRLEN, 1);
44
+ len = ngx_sock_ntop(sa, socklen, text, NGX_SOCKADDR_STRLEN, 1);
45
45
  ls->addr_text.len = len;
46
46
 
47
47
  switch (ls->sockaddr->sa_family) {
@@ -82,6 +82,10 @@ ngx_create_listening(ngx_conf_t *cf, void *sockaddr, socklen_t socklen)
82
82
  ls->setfib = -1;
83
83
  #endif
84
84
 
85
+ #if (NGX_HAVE_TCP_FASTOPEN)
86
+ ls->fastopen = -1;
87
+ #endif
88
+
85
89
  return ls;
86
90
  }
87
91
 
@@ -93,8 +97,10 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
93
97
  ngx_uint_t i;
94
98
  ngx_listening_t *ls;
95
99
  socklen_t olen;
96
- #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
100
+ #if (NGX_HAVE_DEFERRED_ACCEPT || NGX_HAVE_TCP_FASTOPEN)
97
101
  ngx_err_t err;
102
+ #endif
103
+ #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
98
104
  struct accept_filter_arg af;
99
105
  #endif
100
106
  #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
@@ -123,7 +129,7 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
123
129
  #if (NGX_HAVE_INET6)
124
130
  case AF_INET6:
125
131
  ls[i].addr_text_max_len = NGX_INET6_ADDRSTRLEN;
126
- len = NGX_INET6_ADDRSTRLEN + sizeof(":65535") - 1;
132
+ len = NGX_INET6_ADDRSTRLEN + sizeof("[]:65535") - 1;
127
133
  break;
128
134
  #endif
129
135
 
@@ -152,7 +158,8 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
152
158
  return NGX_ERROR;
153
159
  }
154
160
 
155
- len = ngx_sock_ntop(ls[i].sockaddr, ls[i].addr_text.data, len, 1);
161
+ len = ngx_sock_ntop(ls[i].sockaddr, ls[i].socklen,
162
+ ls[i].addr_text.data, len, 1);
156
163
  if (len == 0) {
157
164
  return NGX_ERROR;
158
165
  }
@@ -192,7 +199,9 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
192
199
 
193
200
  #if (NGX_HAVE_SETFIB)
194
201
 
195
- if (getsockopt(ls[i].setfib, SOL_SOCKET, SO_SETFIB,
202
+ olen = sizeof(int);
203
+
204
+ if (getsockopt(ls[i].fd, SOL_SOCKET, SO_SETFIB,
196
205
  (void *) &ls[i].setfib, &olen)
197
206
  == -1)
198
207
  {
@@ -206,6 +215,27 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
206
215
  #endif
207
216
  #endif
208
217
 
218
+ #if (NGX_HAVE_TCP_FASTOPEN)
219
+
220
+ olen = sizeof(int);
221
+
222
+ if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_FASTOPEN,
223
+ (void *) &ls[i].fastopen, &olen)
224
+ == -1)
225
+ {
226
+ err = ngx_socket_errno;
227
+
228
+ if (err != NGX_EOPNOTSUPP && err != NGX_ENOPROTOOPT) {
229
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, err,
230
+ "getsockopt(TCP_FASTOPEN) %V failed, ignored",
231
+ &ls[i].addr_text);
232
+ }
233
+
234
+ ls[i].fastopen = -1;
235
+ }
236
+
237
+ #endif
238
+
209
239
  #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
210
240
 
211
241
  ngx_memzero(&af, sizeof(struct accept_filter_arg));
@@ -214,7 +244,7 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
214
244
  if (getsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, &af, &olen)
215
245
  == -1)
216
246
  {
217
- err = ngx_errno;
247
+ err = ngx_socket_errno;
218
248
 
219
249
  if (err == NGX_EINVAL) {
220
250
  continue;
@@ -247,7 +277,13 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
247
277
  if (getsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &timeout, &olen)
248
278
  == -1)
249
279
  {
250
- ngx_log_error(NGX_LOG_NOTICE, cycle->log, ngx_errno,
280
+ err = ngx_socket_errno;
281
+
282
+ if (err == NGX_EOPNOTSUPP) {
283
+ continue;
284
+ }
285
+
286
+ ngx_log_error(NGX_LOG_NOTICE, cycle->log, err,
251
287
  "getsockopt(TCP_DEFER_ACCEPT) for %V failed, ignored",
252
288
  &ls[i].addr_text);
253
289
  continue;
@@ -296,7 +332,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
296
332
  continue;
297
333
  }
298
334
 
299
- if (ls[i].fd != -1) {
335
+ if (ls[i].fd != (ngx_socket_t) -1) {
300
336
  continue;
301
337
  }
302
338
 
@@ -311,7 +347,7 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
311
347
 
312
348
  s = ngx_socket(ls[i].sockaddr->sa_family, ls[i].type, 0);
313
349
 
314
- if (s == -1) {
350
+ if (s == (ngx_socket_t) -1) {
315
351
  ngx_log_error(NGX_LOG_EMERG, log, ngx_socket_errno,
316
352
  ngx_socket_n " %V failed", &ls[i].addr_text);
317
353
  return NGX_ERROR;
@@ -463,16 +499,13 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
463
499
  void
464
500
  ngx_configure_listening_sockets(ngx_cycle_t *cycle)
465
501
  {
466
- int keepalive;
502
+ int value;
467
503
  ngx_uint_t i;
468
504
  ngx_listening_t *ls;
469
505
 
470
506
  #if (NGX_HAVE_DEFERRED_ACCEPT && defined SO_ACCEPTFILTER)
471
507
  struct accept_filter_arg af;
472
508
  #endif
473
- #if (NGX_HAVE_DEFERRED_ACCEPT && defined TCP_DEFER_ACCEPT)
474
- int timeout;
475
- #endif
476
509
 
477
510
  ls = cycle->listening.elts;
478
511
  for (i = 0; i < cycle->listening.nelts; i++) {
@@ -502,39 +535,51 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
502
535
  }
503
536
 
504
537
  if (ls[i].keepalive) {
505
- keepalive = (ls[i].keepalive == 1) ? 1 : 0;
538
+ value = (ls[i].keepalive == 1) ? 1 : 0;
506
539
 
507
540
  if (setsockopt(ls[i].fd, SOL_SOCKET, SO_KEEPALIVE,
508
- (const void *) &keepalive, sizeof(int))
541
+ (const void *) &value, sizeof(int))
509
542
  == -1)
510
543
  {
511
544
  ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
512
545
  "setsockopt(SO_KEEPALIVE, %d) %V failed, ignored",
513
- keepalive, &ls[i].addr_text);
546
+ value, &ls[i].addr_text);
514
547
  }
515
548
  }
516
549
 
517
550
  #if (NGX_HAVE_KEEPALIVE_TUNABLE)
518
551
 
519
552
  if (ls[i].keepidle) {
553
+ value = ls[i].keepidle;
554
+
555
+ #if (NGX_KEEPALIVE_FACTOR)
556
+ value *= NGX_KEEPALIVE_FACTOR;
557
+ #endif
558
+
520
559
  if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPIDLE,
521
- (const void *) &ls[i].keepidle, sizeof(int))
560
+ (const void *) &value, sizeof(int))
522
561
  == -1)
523
562
  {
524
563
  ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
525
564
  "setsockopt(TCP_KEEPIDLE, %d) %V failed, ignored",
526
- ls[i].keepidle, &ls[i].addr_text);
565
+ value, &ls[i].addr_text);
527
566
  }
528
567
  }
529
568
 
530
569
  if (ls[i].keepintvl) {
570
+ value = ls[i].keepintvl;
571
+
572
+ #if (NGX_KEEPALIVE_FACTOR)
573
+ value *= NGX_KEEPALIVE_FACTOR;
574
+ #endif
575
+
531
576
  if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_KEEPINTVL,
532
- (const void *) &ls[i].keepintvl, sizeof(int))
577
+ (const void *) &value, sizeof(int))
533
578
  == -1)
534
579
  {
535
580
  ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
536
581
  "setsockopt(TCP_KEEPINTVL, %d) %V failed, ignored",
537
- ls[i].keepintvl, &ls[i].addr_text);
582
+ value, &ls[i].addr_text);
538
583
  }
539
584
  }
540
585
 
@@ -564,6 +609,19 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
564
609
  }
565
610
  #endif
566
611
 
612
+ #if (NGX_HAVE_TCP_FASTOPEN)
613
+ if (ls[i].fastopen != -1) {
614
+ if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_FASTOPEN,
615
+ (const void *) &ls[i].fastopen, sizeof(int))
616
+ == -1)
617
+ {
618
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
619
+ "setsockopt(TCP_FASTOPEN, %d) %V failed, ignored",
620
+ ls[i].fastopen, &ls[i].addr_text);
621
+ }
622
+ }
623
+ #endif
624
+
567
625
  #if 0
568
626
  if (1) {
569
627
  int tcp_nodelay = 1;
@@ -603,7 +661,7 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
603
661
  if (setsockopt(ls[i].fd, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0)
604
662
  == -1)
605
663
  {
606
- ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
664
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
607
665
  "setsockopt(SO_ACCEPTFILTER, NULL) "
608
666
  "for %V failed, ignored",
609
667
  &ls[i].addr_text);
@@ -630,7 +688,7 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
630
688
  &af, sizeof(struct accept_filter_arg))
631
689
  == -1)
632
690
  {
633
- ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
691
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
634
692
  "setsockopt(SO_ACCEPTFILTER, \"%s\") "
635
693
  "for %V failed, ignored",
636
694
  ls[i].accept_filter, &ls[i].addr_text);
@@ -653,20 +711,20 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
653
711
  * if syncookies were used), hence we use 1 second timeout
654
712
  * here.
655
713
  */
656
- timeout = 1;
714
+ value = 1;
657
715
 
658
716
  } else {
659
- timeout = 0;
717
+ value = 0;
660
718
  }
661
719
 
662
720
  if (setsockopt(ls[i].fd, IPPROTO_TCP, TCP_DEFER_ACCEPT,
663
- &timeout, sizeof(int))
721
+ &value, sizeof(int))
664
722
  == -1)
665
723
  {
666
- ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
724
+ ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_socket_errno,
667
725
  "setsockopt(TCP_DEFER_ACCEPT, %d) for %V failed, "
668
726
  "ignored",
669
- timeout, &ls[i].addr_text);
727
+ value, &ls[i].addr_text);
670
728
 
671
729
  continue;
672
730
  }
@@ -859,7 +917,7 @@ ngx_close_connection(ngx_connection_t *c)
859
917
  ngx_uint_t log_error, level;
860
918
  ngx_socket_t fd;
861
919
 
862
- if (c->fd == -1) {
920
+ if (c->fd == (ngx_socket_t) -1) {
863
921
  ngx_log_error(NGX_LOG_ALERT, c->log, 0, "connection already closed");
864
922
  return;
865
923
  }
@@ -1034,6 +1092,10 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
1034
1092
  struct sockaddr_in6 *sin6;
1035
1093
  #endif
1036
1094
 
1095
+ if (c->local_socklen == 0) {
1096
+ return NGX_ERROR;
1097
+ }
1098
+
1037
1099
  switch (c->local_sockaddr->sa_family) {
1038
1100
 
1039
1101
  #if (NGX_HAVE_INET6)
@@ -1047,6 +1109,12 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
1047
1109
  break;
1048
1110
  #endif
1049
1111
 
1112
+ #if (NGX_HAVE_UNIX_DOMAIN)
1113
+ case AF_UNIX:
1114
+ addr = 1;
1115
+ break;
1116
+ #endif
1117
+
1050
1118
  default: /* AF_INET */
1051
1119
  sin = (struct sockaddr_in *) c->local_sockaddr;
1052
1120
  addr = sin->sin_addr.s_addr;
@@ -1068,13 +1136,16 @@ ngx_connection_local_sockaddr(ngx_connection_t *c, ngx_str_t *s,
1068
1136
  }
1069
1137
 
1070
1138
  ngx_memcpy(c->local_sockaddr, &sa, len);
1139
+
1140
+ c->local_socklen = len;
1071
1141
  }
1072
1142
 
1073
1143
  if (s == NULL) {
1074
1144
  return NGX_OK;
1075
1145
  }
1076
1146
 
1077
- s->len = ngx_sock_ntop(c->local_sockaddr, s->data, s->len, port);
1147
+ s->len = ngx_sock_ntop(c->local_sockaddr, c->local_socklen,
1148
+ s->data, s->len, port);
1078
1149
 
1079
1150
  return NGX_OK;
1080
1151
  }