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
@@ -18,6 +18,9 @@
18
18
  #define NGX_RESOLVE_PTR 12
19
19
  #define NGX_RESOLVE_MX 15
20
20
  #define NGX_RESOLVE_TXT 16
21
+ #if (NGX_HAVE_INET6)
22
+ #define NGX_RESOLVE_AAAA 28
23
+ #endif
21
24
  #define NGX_RESOLVE_DNAME 39
22
25
 
23
26
  #define NGX_RESOLVE_FORMERR 1
@@ -54,10 +57,18 @@ typedef struct {
54
57
  /* PTR: resolved name, A: name to resolve */
55
58
  u_char *name;
56
59
 
60
+ #if (NGX_HAVE_INET6)
61
+ /* PTR: IPv6 address to resolve (IPv4 address is in rbtree node key) */
62
+ struct in6_addr addr6;
63
+ #endif
64
+
57
65
  u_short nlen;
58
66
  u_short qlen;
59
67
 
60
68
  u_char *query;
69
+ #if (NGX_HAVE_INET6)
70
+ u_char *query6;
71
+ #endif
61
72
 
62
73
  union {
63
74
  in_addr_t addr;
@@ -65,11 +76,22 @@ typedef struct {
65
76
  u_char *cname;
66
77
  } u;
67
78
 
79
+ u_char code;
68
80
  u_short naddrs;
69
81
  u_short cnlen;
70
82
 
83
+ #if (NGX_HAVE_INET6)
84
+ union {
85
+ struct in6_addr addr6;
86
+ struct in6_addr *addrs6;
87
+ } u6;
88
+
89
+ u_short naddrs6;
90
+ #endif
91
+
71
92
  time_t expire;
72
93
  time_t valid;
94
+ uint32_t ttl;
73
95
 
74
96
  ngx_resolver_ctx_t *waiting;
75
97
  } ngx_resolver_node_t;
@@ -100,6 +122,14 @@ typedef struct {
100
122
  ngx_queue_t name_expire_queue;
101
123
  ngx_queue_t addr_expire_queue;
102
124
 
125
+ #if (NGX_HAVE_INET6)
126
+ ngx_uint_t ipv6; /* unsigned ipv6:1; */
127
+ ngx_rbtree_t addr6_rbtree;
128
+ ngx_rbtree_node_t addr6_sentinel;
129
+ ngx_queue_t addr6_resend_queue;
130
+ ngx_queue_t addr6_expire_queue;
131
+ #endif
132
+
103
133
  time_t resend_timeout;
104
134
  time_t expire;
105
135
  time_t valid;
@@ -117,12 +147,12 @@ struct ngx_resolver_ctx_s {
117
147
  ngx_int_t ident;
118
148
 
119
149
  ngx_int_t state;
120
- ngx_int_t type;
121
150
  ngx_str_t name;
122
151
 
123
152
  ngx_uint_t naddrs;
124
- in_addr_t *addrs;
125
- in_addr_t addr;
153
+ ngx_addr_t *addrs;
154
+ ngx_addr_t addr;
155
+ struct sockaddr_in sin;
126
156
 
127
157
  ngx_resolver_handler_pt handler;
128
158
  void *data;
@@ -129,6 +129,7 @@ ngx_slab_init(ngx_slab_pool_t *pool)
129
129
  pool->pages->slab = pages;
130
130
  }
131
131
 
132
+ pool->log_nomem = 1;
132
133
  pool->log_ctx = &pool->zero;
133
134
  pool->zero = '\0';
134
135
  }
@@ -440,7 +441,8 @@ ngx_slab_free_locked(ngx_slab_pool_t *pool, void *p)
440
441
  n = ((uintptr_t) p & (ngx_pagesize - 1)) >> shift;
441
442
  m = (uintptr_t) 1 << (n & (sizeof(uintptr_t) * 8 - 1));
442
443
  n /= (sizeof(uintptr_t) * 8);
443
- bitmap = (uintptr_t *) ((uintptr_t) p & ~(ngx_pagesize - 1));
444
+ bitmap = (uintptr_t *)
445
+ ((uintptr_t) p & ~((uintptr_t) ngx_pagesize - 1));
444
446
 
445
447
  if (bitmap[n] & m) {
446
448
 
@@ -657,7 +659,10 @@ ngx_slab_alloc_pages(ngx_slab_pool_t *pool, ngx_uint_t pages)
657
659
  }
658
660
  }
659
661
 
660
- ngx_slab_error(pool, NGX_LOG_CRIT, "ngx_slab_alloc() failed: no memory");
662
+ if (pool->log_nomem) {
663
+ ngx_slab_error(pool, NGX_LOG_CRIT,
664
+ "ngx_slab_alloc() failed: no memory");
665
+ }
661
666
 
662
667
  return NULL;
663
668
  }
@@ -39,6 +39,8 @@ typedef struct {
39
39
  u_char *log_ctx;
40
40
  u_char zero;
41
41
 
42
+ unsigned log_nomem:1;
43
+
42
44
  void *data;
43
45
  void *addr;
44
46
  } ngx_slab_pool_t;
@@ -11,6 +11,8 @@
11
11
 
12
12
  static u_char *ngx_sprintf_num(u_char *buf, u_char *last, uint64_t ui64,
13
13
  u_char zero, ngx_uint_t hexadecimal, ngx_uint_t width);
14
+ static void ngx_encode_base64_internal(ngx_str_t *dst, ngx_str_t *src,
15
+ const u_char *basis, ngx_uint_t padding);
14
16
  static ngx_int_t ngx_decode_base64_internal(ngx_str_t *dst, ngx_str_t *src,
15
17
  const u_char *basis);
16
18
 
@@ -486,7 +488,7 @@ ngx_sprintf_num(u_char *buf, u_char *last, uint64_t ui64, u_char zero,
486
488
 
487
489
  if (hexadecimal == 0) {
488
490
 
489
- if (ui64 <= NGX_MAX_UINT32_VALUE) {
491
+ if (ui64 <= (uint64_t) NGX_MAX_UINT32_VALUE) {
490
492
 
491
493
  /*
492
494
  * To divide 64-bit numbers and to find remainders
@@ -852,6 +854,46 @@ ngx_dns_strcmp(u_char *s1, u_char *s2)
852
854
  }
853
855
 
854
856
 
857
+ ngx_int_t
858
+ ngx_filename_cmp(u_char *s1, u_char *s2, size_t n)
859
+ {
860
+ ngx_uint_t c1, c2;
861
+
862
+ while (n) {
863
+ c1 = (ngx_uint_t) *s1++;
864
+ c2 = (ngx_uint_t) *s2++;
865
+
866
+ #if (NGX_HAVE_CASELESS_FILESYSTEM)
867
+ c1 = tolower(c1);
868
+ c2 = tolower(c2);
869
+ #endif
870
+
871
+ if (c1 == c2) {
872
+
873
+ if (c1) {
874
+ n--;
875
+ continue;
876
+ }
877
+
878
+ return 0;
879
+ }
880
+
881
+ /* we need '/' to be the lowest character */
882
+
883
+ if (c1 == 0 || c2 == 0) {
884
+ return c1 - c2;
885
+ }
886
+
887
+ c1 = (c1 == '/') ? 0 : c1;
888
+ c2 = (c2 == '/') ? 0 : c2;
889
+
890
+ return c1 - c2;
891
+ }
892
+
893
+ return 0;
894
+ }
895
+
896
+
855
897
  ngx_int_t
856
898
  ngx_atoi(u_char *line, size_t n)
857
899
  {
@@ -1060,38 +1102,61 @@ ngx_hex_dump(u_char *dst, u_char *src, size_t len)
1060
1102
  void
1061
1103
  ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src)
1062
1104
  {
1063
- u_char *d, *s;
1064
- size_t len;
1065
1105
  static u_char basis64[] =
1066
1106
  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
1067
1107
 
1108
+ ngx_encode_base64_internal(dst, src, basis64, 1);
1109
+ }
1110
+
1111
+
1112
+ void
1113
+ ngx_encode_base64url(ngx_str_t *dst, ngx_str_t *src)
1114
+ {
1115
+ static u_char basis64[] =
1116
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
1117
+
1118
+ ngx_encode_base64_internal(dst, src, basis64, 0);
1119
+ }
1120
+
1121
+
1122
+ static void
1123
+ ngx_encode_base64_internal(ngx_str_t *dst, ngx_str_t *src, const u_char *basis,
1124
+ ngx_uint_t padding)
1125
+ {
1126
+ u_char *d, *s;
1127
+ size_t len;
1128
+
1068
1129
  len = src->len;
1069
1130
  s = src->data;
1070
1131
  d = dst->data;
1071
1132
 
1072
1133
  while (len > 2) {
1073
- *d++ = basis64[(s[0] >> 2) & 0x3f];
1074
- *d++ = basis64[((s[0] & 3) << 4) | (s[1] >> 4)];
1075
- *d++ = basis64[((s[1] & 0x0f) << 2) | (s[2] >> 6)];
1076
- *d++ = basis64[s[2] & 0x3f];
1134
+ *d++ = basis[(s[0] >> 2) & 0x3f];
1135
+ *d++ = basis[((s[0] & 3) << 4) | (s[1] >> 4)];
1136
+ *d++ = basis[((s[1] & 0x0f) << 2) | (s[2] >> 6)];
1137
+ *d++ = basis[s[2] & 0x3f];
1077
1138
 
1078
1139
  s += 3;
1079
1140
  len -= 3;
1080
1141
  }
1081
1142
 
1082
1143
  if (len) {
1083
- *d++ = basis64[(s[0] >> 2) & 0x3f];
1144
+ *d++ = basis[(s[0] >> 2) & 0x3f];
1084
1145
 
1085
1146
  if (len == 1) {
1086
- *d++ = basis64[(s[0] & 3) << 4];
1087
- *d++ = '=';
1147
+ *d++ = basis[(s[0] & 3) << 4];
1148
+ if (padding) {
1149
+ *d++ = '=';
1150
+ }
1088
1151
 
1089
1152
  } else {
1090
- *d++ = basis64[((s[0] & 3) << 4) | (s[1] >> 4)];
1091
- *d++ = basis64[(s[1] & 0x0f) << 2];
1153
+ *d++ = basis[((s[0] & 3) << 4) | (s[1] >> 4)];
1154
+ *d++ = basis[(s[1] & 0x0f) << 2];
1092
1155
  }
1093
1156
 
1094
- *d++ = '=';
1157
+ if (padding) {
1158
+ *d++ = '=';
1159
+ }
1095
1160
  }
1096
1161
 
1097
1162
  dst->len = d - dst->data;
@@ -167,6 +167,7 @@ ngx_int_t ngx_rstrncmp(u_char *s1, u_char *s2, size_t n);
167
167
  ngx_int_t ngx_rstrncasecmp(u_char *s1, u_char *s2, size_t n);
168
168
  ngx_int_t ngx_memn2cmp(u_char *s1, u_char *s2, size_t n1, size_t n2);
169
169
  ngx_int_t ngx_dns_strcmp(u_char *s1, u_char *s2);
170
+ ngx_int_t ngx_filename_cmp(u_char *s1, u_char *s2, size_t n);
170
171
 
171
172
  ngx_int_t ngx_atoi(u_char *line, size_t n);
172
173
  ngx_int_t ngx_atofp(u_char *line, size_t n, size_t point);
@@ -182,6 +183,7 @@ u_char *ngx_hex_dump(u_char *dst, u_char *src, size_t len);
182
183
  #define ngx_base64_decoded_length(len) (((len + 3) / 4) * 3)
183
184
 
184
185
  void ngx_encode_base64(ngx_str_t *dst, ngx_str_t *src);
186
+ void ngx_encode_base64url(ngx_str_t *dst, ngx_str_t *src);
185
187
  ngx_int_t ngx_decode_base64(ngx_str_t *dst, ngx_str_t *src);
186
188
  ngx_int_t ngx_decode_base64url(ngx_str_t *dst, ngx_str_t *src);
187
189
 
@@ -425,7 +425,7 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
425
425
 
426
426
  case -1:
427
427
  ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
428
- "ioctl(DP_ISPOLLED) failed for socket %d, event",
428
+ "ioctl(DP_ISPOLLED) failed for socket %d, event %04Xd",
429
429
  fd, revents);
430
430
  break;
431
431
 
@@ -449,7 +449,7 @@ ngx_devpoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
449
449
  != (ssize_t) sizeof(struct pollfd))
450
450
  {
451
451
  ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
452
- "write(/dev/poll) for %d failed, fd");
452
+ "write(/dev/poll) for %d failed", fd);
453
453
  }
454
454
 
455
455
  if (close(fd) == -1) {
@@ -25,6 +25,8 @@
25
25
  #define EPOLLERR 0x008
26
26
  #define EPOLLHUP 0x010
27
27
 
28
+ #define EPOLLRDHUP 0x2000
29
+
28
30
  #define EPOLLET 0x80000000
29
31
  #define EPOLLONESHOT 0x40000000
30
32
 
@@ -396,13 +398,13 @@ ngx_epoll_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
396
398
  if (event == NGX_READ_EVENT) {
397
399
  e = c->write;
398
400
  prev = EPOLLOUT;
399
- #if (NGX_READ_EVENT != EPOLLIN)
400
- events = EPOLLIN;
401
+ #if (NGX_READ_EVENT != EPOLLIN|EPOLLRDHUP)
402
+ events = EPOLLIN|EPOLLRDHUP;
401
403
  #endif
402
404
 
403
405
  } else {
404
406
  e = c->read;
405
- prev = EPOLLIN;
407
+ prev = EPOLLIN|EPOLLRDHUP;
406
408
  #if (NGX_WRITE_EVENT != EPOLLOUT)
407
409
  events = EPOLLOUT;
408
410
  #endif
@@ -466,7 +468,7 @@ ngx_epoll_del_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
466
468
 
467
469
  } else {
468
470
  e = c->read;
469
- prev = EPOLLIN;
471
+ prev = EPOLLIN|EPOLLRDHUP;
470
472
  }
471
473
 
472
474
  if (e->active) {
@@ -501,7 +503,7 @@ ngx_epoll_add_connection(ngx_connection_t *c)
501
503
  {
502
504
  struct epoll_event ee;
503
505
 
504
- ee.events = EPOLLIN|EPOLLOUT|EPOLLET;
506
+ ee.events = EPOLLIN|EPOLLOUT|EPOLLET|EPOLLRDHUP;
505
507
  ee.data.ptr = (void *) ((uintptr_t) c | c->read->instance);
506
508
 
507
509
  ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
@@ -666,6 +668,12 @@ ngx_epoll_process_events(ngx_cycle_t *cycle, ngx_msec_t timer, ngx_uint_t flags)
666
668
 
667
669
  if ((revents & EPOLLIN) && rev->active) {
668
670
 
671
+ #if (NGX_HAVE_EPOLLRDHUP)
672
+ if (revents & EPOLLRDHUP) {
673
+ rev->pending_eof = 1;
674
+ }
675
+ #endif
676
+
669
677
  if ((flags & NGX_POST_THREAD_EVENTS) && !rev->accept) {
670
678
  rev->posted_ready = 1;
671
679
 
@@ -288,7 +288,7 @@ ngx_select_process_events(ngx_cycle_t *cycle, ngx_msec_t timer,
288
288
 
289
289
  ngx_log_error(level, cycle->log, err, "select() failed");
290
290
 
291
- if (err == EBADF) {
291
+ if (err == NGX_EBADF) {
292
292
  ngx_select_repair_fd_sets(cycle);
293
293
  }
294
294
 
@@ -148,8 +148,8 @@ ngx_select_add_event(ngx_event_t *ev, ngx_int_t event, ngx_uint_t flags)
148
148
  return NGX_ERROR;
149
149
  }
150
150
 
151
- if ((event == NGX_READ_EVENT) && (max_read >= FD_SETSIZE)
152
- || (event == NGX_WRITE_EVENT) && (max_write >= FD_SETSIZE))
151
+ if ((event == NGX_READ_EVENT && max_read >= FD_SETSIZE)
152
+ || (event == NGX_WRITE_EVENT && max_write >= FD_SETSIZE))
153
153
  {
154
154
  ngx_log_error(NGX_LOG_ERR, ev->log, 0,
155
155
  "maximum number of descriptors "
@@ -56,7 +56,6 @@ ngx_uint_t ngx_accept_events;
56
56
  ngx_uint_t ngx_accept_mutex_held;
57
57
  ngx_msec_t ngx_accept_mutex_delay;
58
58
  ngx_int_t ngx_accept_disabled;
59
- ngx_file_t ngx_accept_mutex_lock_file;
60
59
 
61
60
 
62
61
  #if (NGX_STAT_STUB)
@@ -69,13 +69,9 @@ struct ngx_event_s {
69
69
 
70
70
  unsigned delayed:1;
71
71
 
72
- unsigned read_discarded:1;
73
-
74
- unsigned unexpected_eof:1;
75
-
76
72
  unsigned deferred_accept:1;
77
73
 
78
- /* the pending eof reported by kqueue or in aio chain operation */
74
+ /* the pending eof reported by kqueue, epoll or in aio chain operation */
79
75
  unsigned pending_eof:1;
80
76
 
81
77
  #if !(NGX_THREADS)
@@ -353,6 +349,11 @@ extern ngx_event_actions_t ngx_event_actions;
353
349
  #define NGX_VNODE_EVENT 0
354
350
 
355
351
 
352
+ #if (NGX_HAVE_EPOLL) && !(NGX_HAVE_EPOLLRDHUP)
353
+ #define EPOLLRDHUP 0
354
+ #endif
355
+
356
+
356
357
  #if (NGX_HAVE_KQUEUE)
357
358
 
358
359
  #define NGX_READ_EVENT EVFILT_READ
@@ -396,7 +397,7 @@ extern ngx_event_actions_t ngx_event_actions;
396
397
 
397
398
  #elif (NGX_HAVE_EPOLL)
398
399
 
399
- #define NGX_READ_EVENT EPOLLIN
400
+ #define NGX_READ_EVENT (EPOLLIN|EPOLLRDHUP)
400
401
  #define NGX_WRITE_EVENT EPOLLOUT
401
402
 
402
403
  #define NGX_LEVEL_EVENT 0
@@ -70,7 +70,7 @@ ngx_event_accept(ngx_event_t *ev)
70
70
  s = accept(lc->fd, (struct sockaddr *) sa, &socklen);
71
71
  #endif
72
72
 
73
- if (s == -1) {
73
+ if (s == (ngx_socket_t) -1) {
74
74
  err = ngx_socket_errno;
75
75
 
76
76
  if (err == NGX_EAGAIN) {
@@ -212,6 +212,7 @@ ngx_event_accept(ngx_event_t *ev)
212
212
  c->socklen = socklen;
213
213
  c->listening = ls;
214
214
  c->local_sockaddr = ls->sockaddr;
215
+ c->local_socklen = ls->socklen;
215
216
 
216
217
  c->unexpected_eof = 1;
217
218
 
@@ -275,7 +276,8 @@ ngx_event_accept(ngx_event_t *ev)
275
276
  return;
276
277
  }
277
278
 
278
- c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->addr_text.data,
279
+ c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen,
280
+ c->addr_text.data,
279
281
  ls->addr_text_max_len, 0);
280
282
  if (c->addr_text.len == 0) {
281
283
  ngx_close_accepted_connection(c);
@@ -296,7 +298,7 @@ ngx_event_accept(ngx_event_t *ev)
296
298
 
297
299
  cidr = ecf->debug_connection.elts;
298
300
  for (i = 0; i < ecf->debug_connection.nelts; i++) {
299
- if (cidr[i].family != c->sockaddr->sa_family) {
301
+ if (cidr[i].family != (ngx_uint_t) c->sockaddr->sa_family) {
300
302
  goto next;
301
303
  }
302
304
 
@@ -342,7 +344,7 @@ ngx_event_accept(ngx_event_t *ev)
342
344
  #endif
343
345
 
344
346
  ngx_log_debug3(NGX_LOG_DEBUG_EVENT, log, 0,
345
- "*%d accept: %V fd:%d", c->number, &c->addr_text, s);
347
+ "*%uA accept: %V fd:%d", c->number, &c->addr_text, s);
346
348
 
347
349
  if (ngx_add_conn && (ngx_event_flags & NGX_USE_EPOLL_EVENT) == 0) {
348
350
  if (ngx_add_conn(c) == NGX_ERROR) {