nginxtra 1.0.15.0 → 1.2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. data/VERSION +1 -1
  2. data/bin/nginxtra +1 -1
  3. data/lib/nginxtra/action.rb +10 -0
  4. data/lib/nginxtra/actions/compile.rb +16 -2
  5. data/lib/nginxtra/actions/start.rb +18 -2
  6. data/lib/nginxtra/actions/status.rb +1 -10
  7. data/lib/nginxtra/actions/stop.rb +18 -0
  8. data/lib/nginxtra/cli.rb +12 -3
  9. data/lib/nginxtra/config.rb +10 -0
  10. data/src/nginx/CHANGES +311 -90
  11. data/src/nginx/CHANGES.ru +315 -88
  12. data/src/nginx/auto/lib/pcre/conf +22 -5
  13. data/src/nginx/auto/lib/pcre/make +1 -1
  14. data/src/nginx/auto/modules +14 -3
  15. data/src/nginx/auto/options +17 -3
  16. data/src/nginx/auto/os/freebsd +8 -0
  17. data/src/nginx/auto/os/linux +5 -4
  18. data/src/nginx/auto/os/solaris +2 -1
  19. data/src/nginx/auto/sources +10 -2
  20. data/src/nginx/auto/summary +2 -0
  21. data/src/nginx/auto/types/sizeof +2 -1
  22. data/src/nginx/auto/types/typedef +1 -1
  23. data/src/nginx/auto/types/uintptr_t +7 -4
  24. data/src/nginx/auto/unix +82 -21
  25. data/src/nginx/conf/fastcgi.conf +1 -0
  26. data/src/nginx/conf/fastcgi_params +1 -0
  27. data/src/nginx/conf/scgi_params +1 -0
  28. data/src/nginx/conf/uwsgi_params +1 -0
  29. data/src/nginx/man/nginx.8 +49 -49
  30. data/src/nginx/src/core/nginx.c +10 -12
  31. data/src/nginx/src/core/nginx.h +2 -2
  32. data/src/nginx/src/core/ngx_buf.c +9 -7
  33. data/src/nginx/src/core/ngx_buf.h +2 -2
  34. data/src/nginx/src/core/ngx_conf_file.c +4 -11
  35. data/src/nginx/src/core/ngx_conf_file.h +1 -1
  36. data/src/nginx/src/core/ngx_connection.c +52 -1
  37. data/src/nginx/src/core/ngx_connection.h +6 -0
  38. data/src/nginx/src/core/ngx_core.h +5 -0
  39. data/src/nginx/src/core/ngx_cycle.c +1 -1
  40. data/src/nginx/src/core/ngx_cycle.h +2 -2
  41. data/src/nginx/src/core/ngx_file.c +1 -1
  42. data/src/nginx/src/core/ngx_inet.c +11 -8
  43. data/src/nginx/src/core/ngx_murmurhash.h +1 -1
  44. data/src/nginx/src/core/ngx_open_file_cache.c +343 -38
  45. data/src/nginx/src/core/ngx_open_file_cache.h +10 -0
  46. data/src/nginx/src/core/ngx_output_chain.c +2 -1
  47. data/src/nginx/src/core/ngx_parse.h +0 -3
  48. data/src/nginx/src/core/ngx_rbtree.c +1 -2
  49. data/src/nginx/src/core/ngx_regex.c +263 -5
  50. data/src/nginx/src/core/ngx_regex.h +6 -2
  51. data/src/nginx/src/core/ngx_resolver.c +88 -21
  52. data/src/nginx/src/core/ngx_resolver.h +7 -8
  53. data/src/nginx/src/core/ngx_shmtx.c +69 -44
  54. data/src/nginx/src/core/ngx_shmtx.h +12 -1
  55. data/src/nginx/src/core/ngx_slab.c +3 -3
  56. data/src/nginx/src/core/ngx_slab.h +1 -1
  57. data/src/nginx/src/core/ngx_string.c +19 -16
  58. data/src/nginx/src/core/ngx_times.c +2 -2
  59. data/src/nginx/src/event/modules/ngx_epoll_module.c +2 -2
  60. data/src/nginx/src/event/modules/ngx_eventport_module.c +1 -1
  61. data/src/nginx/src/event/modules/ngx_kqueue_module.c +1 -1
  62. data/src/nginx/src/event/ngx_event.c +25 -17
  63. data/src/nginx/src/event/ngx_event_openssl.c +3 -1
  64. data/src/nginx/src/event/ngx_event_pipe.c +108 -85
  65. data/src/nginx/src/event/ngx_event_pipe.h +1 -2
  66. data/src/nginx/src/event/ngx_event_timer.c +2 -3
  67. data/src/nginx/src/http/modules/ngx_http_access_module.c +9 -4
  68. data/src/nginx/src/http/modules/ngx_http_browser_module.c +5 -3
  69. data/src/nginx/src/http/modules/ngx_http_chunked_filter_module.c +1 -1
  70. data/src/nginx/src/http/modules/ngx_http_degradation_module.c +1 -1
  71. data/src/nginx/src/http/modules/ngx_http_fastcgi_module.c +144 -22
  72. data/src/nginx/src/http/modules/ngx_http_flv_module.c +8 -0
  73. data/src/nginx/src/http/modules/ngx_http_geo_module.c +3 -3
  74. data/src/nginx/src/http/modules/ngx_http_gzip_filter_module.c +20 -6
  75. data/src/nginx/src/http/modules/ngx_http_gzip_static_module.c +8 -0
  76. data/src/nginx/src/http/modules/ngx_http_headers_filter_module.c +23 -27
  77. data/src/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -3
  78. data/src/nginx/src/http/modules/ngx_http_index_module.c +24 -0
  79. data/src/nginx/src/http/modules/ngx_http_limit_conn_module.c +747 -0
  80. data/src/nginx/src/http/modules/ngx_http_limit_req_module.c +289 -133
  81. data/src/nginx/src/http/modules/ngx_http_log_module.c +34 -6
  82. data/src/nginx/src/http/modules/ngx_http_memcached_module.c +19 -3
  83. data/src/nginx/src/http/modules/ngx_http_mp4_module.c +8 -0
  84. data/src/nginx/src/http/modules/ngx_http_proxy_module.c +1446 -239
  85. data/src/nginx/src/http/modules/ngx_http_realip_module.c +4 -10
  86. data/src/nginx/src/http/modules/ngx_http_scgi_module.c +90 -21
  87. data/src/nginx/src/http/modules/ngx_http_split_clients_module.c +8 -11
  88. data/src/nginx/src/http/modules/ngx_http_ssi_filter_module.c +16 -6
  89. data/src/nginx/src/http/modules/ngx_http_static_module.c +8 -0
  90. data/src/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +2 -2
  91. data/src/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +570 -0
  92. data/src/nginx/src/http/modules/ngx_http_userid_filter_module.c +1 -5
  93. data/src/nginx/src/http/modules/ngx_http_uwsgi_module.c +77 -26
  94. data/src/nginx/src/http/modules/ngx_http_xslt_filter_module.c +171 -37
  95. data/src/nginx/src/http/modules/perl/nginx.pm +2 -1
  96. data/src/nginx/src/http/modules/perl/nginx.xs +4 -0
  97. data/src/nginx/src/http/ngx_http.c +8 -1
  98. data/src/nginx/src/http/ngx_http.h +1 -0
  99. data/src/nginx/src/http/ngx_http_busy_lock.c +2 -2
  100. data/src/nginx/src/http/ngx_http_cache.h +12 -1
  101. data/src/nginx/src/http/ngx_http_copy_filter_module.c +4 -3
  102. data/src/nginx/src/http/ngx_http_core_module.c +303 -37
  103. data/src/nginx/src/http/ngx_http_core_module.h +15 -0
  104. data/src/nginx/src/http/ngx_http_file_cache.c +226 -52
  105. data/src/nginx/src/http/ngx_http_parse.c +69 -3
  106. data/src/nginx/src/http/ngx_http_postpone_filter_module.c +4 -4
  107. data/src/nginx/src/http/ngx_http_request.c +61 -27
  108. data/src/nginx/src/http/ngx_http_request.h +3 -3
  109. data/src/nginx/src/http/ngx_http_request_body.c +1 -1
  110. data/src/nginx/src/http/ngx_http_script.c +6 -0
  111. data/src/nginx/src/http/ngx_http_upstream.c +200 -47
  112. data/src/nginx/src/http/ngx_http_upstream.h +20 -1
  113. data/src/nginx/src/http/ngx_http_upstream_round_robin.c +22 -6
  114. data/src/nginx/src/http/ngx_http_upstream_round_robin.h +1 -0
  115. data/src/nginx/src/http/ngx_http_variables.c +123 -4
  116. data/src/nginx/src/mail/ngx_mail.c +13 -0
  117. data/src/nginx/src/mail/ngx_mail.h +12 -0
  118. data/src/nginx/src/mail/ngx_mail_core_module.c +100 -15
  119. data/src/nginx/src/os/unix/ngx_daemon.c +2 -1
  120. data/src/nginx/src/os/unix/ngx_darwin.h +3 -0
  121. data/src/nginx/src/os/unix/ngx_darwin_config.h +1 -0
  122. data/src/nginx/src/os/unix/ngx_darwin_init.c +30 -0
  123. data/src/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +11 -5
  124. data/src/nginx/src/os/unix/ngx_errno.h +5 -0
  125. data/src/nginx/src/os/unix/ngx_files.h +50 -1
  126. data/src/nginx/src/os/unix/ngx_freebsd.h +2 -1
  127. data/src/nginx/src/os/unix/ngx_freebsd_config.h +2 -0
  128. data/src/nginx/src/os/unix/ngx_freebsd_init.c +4 -3
  129. data/src/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +2 -2
  130. data/src/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +12 -6
  131. data/src/nginx/src/os/unix/ngx_gcc_atomic_sparc64.h +1 -1
  132. data/src/nginx/src/os/unix/ngx_linux_config.h +1 -0
  133. data/src/nginx/src/os/unix/ngx_linux_sendfile_chain.c +6 -4
  134. data/src/nginx/src/os/unix/ngx_os.h +0 -1
  135. data/src/nginx/src/os/unix/ngx_posix_config.h +3 -0
  136. data/src/nginx/src/os/unix/ngx_process.c +50 -11
  137. data/src/nginx/src/os/unix/ngx_process.h +1 -0
  138. data/src/nginx/src/os/unix/ngx_process_cycle.c +6 -15
  139. data/src/nginx/src/os/unix/ngx_readv_chain.c +8 -0
  140. data/src/nginx/src/os/unix/ngx_setaffinity.c +69 -0
  141. data/src/nginx/src/os/unix/ngx_setaffinity.h +23 -0
  142. data/src/nginx/src/os/unix/ngx_setproctitle.c +1 -1
  143. data/src/nginx/src/os/unix/ngx_solaris_config.h +2 -0
  144. data/src/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +11 -3
  145. data/src/nginx/src/os/unix/ngx_writev_chain.c +7 -3
  146. metadata +7 -4
  147. data/src/nginx/src/http/modules/ngx_http_limit_zone_module.c +0 -553
@@ -9,7 +9,8 @@
9
9
  #include <ngx_core.h>
10
10
 
11
11
 
12
- ngx_int_t ngx_daemon(ngx_log_t *log)
12
+ ngx_int_t
13
+ ngx_daemon(ngx_log_t *log)
13
14
  {
14
15
  int fd;
15
16
 
@@ -9,6 +9,7 @@
9
9
  #define _NGX_DARWIN_H_INCLUDED_
10
10
 
11
11
 
12
+ void ngx_debug_init(void);
12
13
  ngx_chain_t *ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
13
14
  off_t limit);
14
15
 
@@ -16,5 +17,7 @@ extern int ngx_darwin_kern_osreldate;
16
17
  extern int ngx_darwin_hw_ncpu;
17
18
  extern u_long ngx_darwin_net_inet_tcp_sendspace;
18
19
 
20
+ extern ngx_uint_t ngx_debug_malloc;
21
+
19
22
 
20
23
  #endif /* _NGX_DARWIN_H_INCLUDED_ */
@@ -88,6 +88,7 @@
88
88
 
89
89
 
90
90
  #define NGX_HAVE_OS_SPECIFIC_INIT 1
91
+ #define NGX_HAVE_DEBUG_MALLOC 1
91
92
 
92
93
 
93
94
  extern char **environ;
@@ -15,6 +15,8 @@ int ngx_darwin_hw_ncpu;
15
15
  int ngx_darwin_kern_ipc_somaxconn;
16
16
  u_long ngx_darwin_net_inet_tcp_sendspace;
17
17
 
18
+ ngx_uint_t ngx_debug_malloc;
19
+
18
20
 
19
21
  static ngx_os_io_t ngx_darwin_io = {
20
22
  ngx_unix_recv,
@@ -56,6 +58,34 @@ sysctl_t sysctls[] = {
56
58
  };
57
59
 
58
60
 
61
+ void
62
+ ngx_debug_init()
63
+ {
64
+ #if (NGX_DEBUG_MALLOC)
65
+
66
+ /*
67
+ * MacOSX 10.6, 10.7: MallocScribble fills freed memory with 0x55
68
+ * and fills allocated memory with 0xAA.
69
+ * MacOSX 10.4, 10.5: MallocScribble fills freed memory with 0x55,
70
+ * MallocPreScribble fills allocated memory with 0xAA.
71
+ * MacOSX 10.3: MallocScribble fills freed memory with 0x55,
72
+ * and no way to fill allocated memory.
73
+ */
74
+
75
+ setenv("MallocScribble", "1", 0);
76
+
77
+ ngx_debug_malloc = 1;
78
+
79
+ #else
80
+
81
+ if (getenv("MallocScribble")) {
82
+ ngx_debug_malloc = 1;
83
+ }
84
+
85
+ #endif
86
+ }
87
+
88
+
59
89
  ngx_int_t
60
90
  ngx_os_specific_init(ngx_log_t *log)
61
91
  {
@@ -103,10 +103,8 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
103
103
  prev = NULL;
104
104
  iov = NULL;
105
105
 
106
- for (cl = in;
107
- cl && header.nelts < IOV_MAX && send < limit;
108
- cl = cl->next)
109
- {
106
+ for (cl = in; cl && send < limit; cl = cl->next) {
107
+
110
108
  if (ngx_buf_special(cl->buf)) {
111
109
  continue;
112
110
  }
@@ -125,6 +123,10 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
125
123
  iov->iov_len += (size_t) size;
126
124
 
127
125
  } else {
126
+ if (header.nelts >= IOV_MAX) {
127
+ break;
128
+ }
129
+
128
130
  iov = ngx_array_push(&header);
129
131
  if (iov == NULL) {
130
132
  return NGX_CHAIN_ERROR;
@@ -178,7 +180,7 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
178
180
  prev = NULL;
179
181
  iov = NULL;
180
182
 
181
- while (cl && header.nelts < IOV_MAX && send < limit) {
183
+ while (cl && send < limit) {
182
184
 
183
185
  if (ngx_buf_special(cl->buf)) {
184
186
  cl = cl->next;
@@ -199,6 +201,10 @@ ngx_darwin_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
199
201
  iov->iov_len += (size_t) size;
200
202
 
201
203
  } else {
204
+ if (trailer.nelts >= IOV_MAX) {
205
+ break;
206
+ }
207
+
202
208
  iov = ngx_array_push(&trailer);
203
209
  if (iov == NULL) {
204
210
  return NGX_CHAIN_ERROR;
@@ -48,6 +48,11 @@ typedef int ngx_err_t;
48
48
  #define NGX_EILSEQ EILSEQ
49
49
  #define NGX_ENOMOREFILES 0
50
50
 
51
+ #if (NGX_HAVE_OPENAT)
52
+ #define NGX_EMLINK EMLINK
53
+ #define NGX_ELOOP ELOOP
54
+ #endif
55
+
51
56
  #if (__hpux__)
52
57
  #define NGX_EAGAIN EWOULDBLOCK
53
58
  #else
@@ -76,6 +76,27 @@ typedef struct {
76
76
  #define NGX_FILE_APPEND O_WRONLY|O_APPEND
77
77
  #define NGX_FILE_NONBLOCK O_NONBLOCK
78
78
 
79
+ #if (NGX_HAVE_OPENAT)
80
+ #define NGX_FILE_NOFOLLOW O_NOFOLLOW
81
+
82
+ #if defined(O_DIRECTORY)
83
+ #define NGX_FILE_DIRECTORY O_DIRECTORY
84
+ #else
85
+ #define NGX_FILE_DIRECTORY 0
86
+ #endif
87
+
88
+ #if defined(O_SEARCH)
89
+ #define NGX_FILE_SEARCH O_SEARCH|NGX_FILE_DIRECTORY
90
+
91
+ #elif defined(O_EXEC)
92
+ #define NGX_FILE_SEARCH O_EXEC|NGX_FILE_DIRECTORY
93
+
94
+ #else
95
+ #define NGX_FILE_SEARCH O_RDONLY|NGX_FILE_DIRECTORY
96
+ #endif
97
+
98
+ #endif /* NGX_HAVE_OPENAT */
99
+
79
100
  #define NGX_FILE_DEFAULT_ACCESS 0644
80
101
  #define NGX_FILE_OWNER_ACCESS 0600
81
102
 
@@ -179,14 +200,25 @@ void ngx_close_file_mapping(ngx_file_mapping_t *fm);
179
200
  #endif
180
201
 
181
202
 
182
- #define ngx_realpath(p, r) realpath((char *) p, (char *) r)
203
+ #define ngx_realpath(p, r) (u_char *) realpath((char *) p, (char *) r)
183
204
  #define ngx_realpath_n "realpath()"
184
205
  #define ngx_getcwd(buf, size) (getcwd((char *) buf, size) != NULL)
185
206
  #define ngx_getcwd_n "getcwd()"
186
207
  #define ngx_path_separator(c) ((c) == '/')
187
208
 
209
+
210
+ #if defined(PATH_MAX)
211
+
212
+ #define NGX_HAVE_MAX_PATH 1
188
213
  #define NGX_MAX_PATH PATH_MAX
189
214
 
215
+ #else
216
+
217
+ #define NGX_MAX_PATH 4096
218
+
219
+ #endif
220
+
221
+
190
222
  #define NGX_DIR_MASK_LEN 0
191
223
 
192
224
 
@@ -325,6 +357,23 @@ ngx_int_t ngx_directio_off(ngx_fd_t fd);
325
357
  size_t ngx_fs_bsize(u_char *name);
326
358
 
327
359
 
360
+ #if (NGX_HAVE_OPENAT)
361
+
362
+ #define ngx_openat_file(fd, name, mode, create, access) \
363
+ openat(fd, (const char *) name, mode|create, access)
364
+
365
+ #define ngx_openat_file_n "openat()"
366
+
367
+ #define ngx_file_at_info(fd, name, sb, flag) \
368
+ fstatat(fd, (const char *) name, sb, flag)
369
+
370
+ #define ngx_file_at_info_n "fstatat()"
371
+
372
+ #define NGX_AT_FDCWD (ngx_fd_t) AT_FDCWD
373
+
374
+ #endif
375
+
376
+
328
377
  #define ngx_stderr STDERR_FILENO
329
378
  #define ngx_set_stderr(fd) dup2(fd, STDERR_FILENO)
330
379
  #define ngx_set_stderr_n "dup2(STDERR_FILENO)"
@@ -9,6 +9,7 @@
9
9
  #define _NGX_FREEBSD_H_INCLUDED_
10
10
 
11
11
 
12
+ void ngx_debug_init(void);
12
13
  ngx_chain_t *ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in,
13
14
  off_t limit);
14
15
 
@@ -18,7 +19,7 @@ extern u_long ngx_freebsd_net_inet_tcp_sendspace;
18
19
 
19
20
  extern ngx_uint_t ngx_freebsd_sendfile_nbytes_bug;
20
21
  extern ngx_uint_t ngx_freebsd_use_tcp_nopush;
21
- extern ngx_uint_t ngx_freebsd_debug_malloc;
22
+ extern ngx_uint_t ngx_debug_malloc;
22
23
 
23
24
 
24
25
  #endif /* _NGX_FREEBSD_H_INCLUDED_ */
@@ -23,6 +23,7 @@
23
23
  #include <grp.h>
24
24
  #include <dirent.h>
25
25
  #include <glob.h>
26
+ #include <time.h>
26
27
  #include <sys/param.h> /* ALIGN() */
27
28
  #include <sys/mount.h> /* statfs() */
28
29
 
@@ -110,6 +111,7 @@ pid_t rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg);
110
111
 
111
112
 
112
113
  #define NGX_HAVE_OS_SPECIFIC_INIT 1
114
+ #define NGX_HAVE_DEBUG_MALLOC 1
113
115
 
114
116
 
115
117
  extern char **environ;
@@ -23,7 +23,8 @@ int ngx_freebsd_machdep_hlt_logical_cpus;
23
23
 
24
24
  ngx_uint_t ngx_freebsd_sendfile_nbytes_bug;
25
25
  ngx_uint_t ngx_freebsd_use_tcp_nopush;
26
- ngx_uint_t ngx_freebsd_debug_malloc;
26
+
27
+ ngx_uint_t ngx_debug_malloc;
27
28
 
28
29
 
29
30
  static ngx_os_io_t ngx_freebsd_io = {
@@ -81,7 +82,7 @@ ngx_debug_init()
81
82
  malloc_options = "J";
82
83
  #endif
83
84
 
84
- ngx_freebsd_debug_malloc = 1;
85
+ ngx_debug_malloc = 1;
85
86
 
86
87
  #else
87
88
  char *mo;
@@ -89,7 +90,7 @@ ngx_debug_init()
89
90
  mo = getenv("MALLOC_OPTIONS");
90
91
 
91
92
  if (mo && ngx_strchr(mo, 'J')) {
92
- ngx_freebsd_debug_malloc = 1;
93
+ ngx_debug_malloc = 1;
93
94
  }
94
95
  #endif
95
96
  }
@@ -11,14 +11,14 @@
11
11
  /*
12
12
  * The threads implementation uses the rfork(RFPROC|RFTHREAD|RFMEM) syscall
13
13
  * to create threads. All threads use the stacks of the same size mmap()ed
14
- * below the main stack. Thus the current thread id is determinated via
14
+ * below the main stack. Thus the current thread id is determined via
15
15
  * the stack pointer value.
16
16
  *
17
17
  * The mutex implementation uses the ngx_atomic_cmp_set() operation
18
18
  * to acquire a mutex and the SysV semaphore to wait on a mutex and to wake up
19
19
  * the waiting threads. The light mutex does not use semaphore, so after
20
20
  * spinning in the lock the thread calls sched_yield(). However the light
21
- * mutecies are intended to be used with the "trylock" operation only.
21
+ * mutexes are intended to be used with the "trylock" operation only.
22
22
  * The SysV semop() is a cheap syscall, particularly if it has little sembuf's
23
23
  * and does not use SEM_UNDO.
24
24
  *
@@ -18,7 +18,7 @@
18
18
  * as the 11 full 1460-bytes packets, then one incomplete 324-bytes packet,
19
19
  * and then again the 11 full 1460-bytes packets.
20
20
  *
21
- * Threfore we use the TCP_NOPUSH option (similar to Linux's TCP_CORK)
21
+ * Therefore we use the TCP_NOPUSH option (similar to Linux's TCP_CORK)
22
22
  * to postpone the sending - it not only sends a header and the first part of
23
23
  * the file in one packet, but also sends the file pages in the full packets.
24
24
  *
@@ -107,10 +107,8 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
107
107
  prev = NULL;
108
108
  iov = NULL;
109
109
 
110
- for (cl = in;
111
- cl && header.nelts < IOV_MAX && send < limit;
112
- cl = cl->next)
113
- {
110
+ for (cl = in; cl && send < limit; cl = cl->next) {
111
+
114
112
  if (ngx_buf_special(cl->buf)) {
115
113
  continue;
116
114
  }
@@ -129,6 +127,10 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
129
127
  iov->iov_len += (size_t) size;
130
128
 
131
129
  } else {
130
+ if (header.nelts >= IOV_MAX){
131
+ break;
132
+ }
133
+
132
134
  iov = ngx_array_push(&header);
133
135
  if (iov == NULL) {
134
136
  return NGX_CHAIN_ERROR;
@@ -183,7 +185,7 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
183
185
  prev = NULL;
184
186
  iov = NULL;
185
187
 
186
- while (cl && header.nelts < IOV_MAX && send < limit) {
188
+ while (cl && send < limit) {
187
189
 
188
190
  if (ngx_buf_special(cl->buf)) {
189
191
  cl = cl->next;
@@ -204,6 +206,10 @@ ngx_freebsd_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
204
206
  iov->iov_len += (size_t) size;
205
207
 
206
208
  } else {
209
+ if (trailer.nelts >= IOV_MAX){
210
+ break;
211
+ }
212
+
207
213
  iov = ngx_array_push(&trailer);
208
214
  if (iov == NULL) {
209
215
  return NGX_CHAIN_ERROR;
@@ -15,7 +15,7 @@
15
15
  * r0 = [r1];
16
16
  * }
17
17
  *
18
- * so "r0 == r2" means that the operation was successfull.
18
+ * so "r0 == r2" means that the operation was successful.
19
19
  *
20
20
  *
21
21
  * The "r" means the general register.
@@ -109,6 +109,7 @@ typedef struct iocb ngx_aiocb_t;
109
109
 
110
110
 
111
111
  #define NGX_HAVE_OS_SPECIFIC_INIT 1
112
+ #define ngx_debug_init()
112
113
 
113
114
 
114
115
  extern char **environ;
@@ -89,10 +89,8 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
89
89
 
90
90
  /* create the iovec and coalesce the neighbouring bufs */
91
91
 
92
- for (cl = in;
93
- cl && header.nelts < IOV_MAX && send < limit;
94
- cl = cl->next)
95
- {
92
+ for (cl = in; cl && send < limit; cl = cl->next) {
93
+
96
94
  if (ngx_buf_special(cl->buf)) {
97
95
  continue;
98
96
  }
@@ -132,6 +130,10 @@ ngx_linux_sendfile_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit)
132
130
  iov->iov_len += (size_t) size;
133
131
 
134
132
  } else {
133
+ if (header.nelts >= IOV_MAX) {
134
+ break;
135
+ }
136
+
135
137
  iov = ngx_array_push(&header);
136
138
  if (iov == NULL) {
137
139
  return NGX_CHAIN_ERROR;
@@ -32,7 +32,6 @@ typedef struct {
32
32
  } ngx_os_io_t;
33
33
 
34
34
 
35
- void ngx_debug_init(void);
36
35
  ngx_int_t ngx_os_init(ngx_log_t *log);
37
36
  void ngx_os_status(ngx_log_t *log);
38
37
  ngx_int_t ngx_os_specific_init(ngx_log_t *log);
@@ -45,6 +45,7 @@
45
45
  #include <grp.h>
46
46
  #include <dirent.h>
47
47
  #include <glob.h>
48
+ #include <time.h>
48
49
  #if (NGX_HAVE_SYS_PARAM_H)
49
50
  #include <sys/param.h> /* statfs() */
50
51
  #endif
@@ -126,6 +127,8 @@ typedef struct aiocb ngx_aiocb_t;
126
127
 
127
128
  #define NGX_LISTEN_BACKLOG 511
128
129
 
130
+ #define ngx_debug_init()
131
+
129
132
 
130
133
  #if (__FreeBSD__) && (__FreeBSD_version < 400017)
131
134
 
@@ -23,6 +23,7 @@ typedef struct {
23
23
  static void ngx_execute_proc(ngx_cycle_t *cycle, void *data);
24
24
  static void ngx_signal_handler(int signo);
25
25
  static void ngx_process_get_status(void);
26
+ static void ngx_unlock_mutexes(ngx_pid_t pid);
26
27
 
27
28
 
28
29
  int ngx_argc;
@@ -498,17 +499,6 @@ ngx_process_get_status(void)
498
499
  }
499
500
 
500
501
 
501
- if (ngx_accept_mutex_ptr) {
502
-
503
- /*
504
- * unlock the accept mutex if the abnormally exited process
505
- * held it
506
- */
507
-
508
- ngx_atomic_cmp_set(ngx_accept_mutex_ptr, pid, 0);
509
- }
510
-
511
-
512
502
  one = 1;
513
503
  process = "unknown process";
514
504
 
@@ -546,6 +536,55 @@ ngx_process_get_status(void)
546
536
  process, pid, WEXITSTATUS(status));
547
537
  ngx_processes[i].respawn = 0;
548
538
  }
539
+
540
+ ngx_unlock_mutexes(pid);
541
+ }
542
+ }
543
+
544
+
545
+ static void
546
+ ngx_unlock_mutexes(ngx_pid_t pid)
547
+ {
548
+ ngx_uint_t i;
549
+ ngx_shm_zone_t *shm_zone;
550
+ ngx_list_part_t *part;
551
+ ngx_slab_pool_t *sp;
552
+
553
+ /*
554
+ * unlock the accept mutex if the abnormally exited process
555
+ * held it
556
+ */
557
+
558
+ if (ngx_accept_mutex_ptr) {
559
+ (void) ngx_shmtx_force_unlock(&ngx_accept_mutex, pid);
560
+ }
561
+
562
+ /*
563
+ * unlock shared memory mutexes if held by the abnormally exited
564
+ * process
565
+ */
566
+
567
+ part = (ngx_list_part_t *) &ngx_cycle->shared_memory.part;
568
+ shm_zone = part->elts;
569
+
570
+ for (i = 0; /* void */ ; i++) {
571
+
572
+ if (i >= part->nelts) {
573
+ if (part->next == NULL) {
574
+ break;
575
+ }
576
+ part = part->next;
577
+ shm_zone = part->elts;
578
+ i = 0;
579
+ }
580
+
581
+ sp = (ngx_slab_pool_t *) shm_zone[i].shm.addr;
582
+
583
+ if (ngx_shmtx_force_unlock(&sp->mutex, pid)) {
584
+ ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0,
585
+ "shared memory zone \"%V\" was locked by %P",
586
+ &shm_zone[i].shm.name, pid);
587
+ }
549
588
  }
550
589
  }
551
590