nginxtra 1.6.3.9 → 1.8.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) 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 +358 -14
  6. data/vendor/nginx/CHANGES.ru +372 -18
  7. data/vendor/nginx/LICENSE +2 -2
  8. data/vendor/nginx/auto/cc/clang +5 -0
  9. data/vendor/nginx/auto/cc/gcc +5 -0
  10. data/vendor/nginx/auto/lib/google-perftools/conf +1 -1
  11. data/vendor/nginx/auto/lib/openssl/make +0 -5
  12. data/vendor/nginx/auto/lib/perl/conf +9 -1
  13. data/vendor/nginx/auto/make +1 -1
  14. data/vendor/nginx/auto/modules +11 -0
  15. data/vendor/nginx/auto/options +10 -2
  16. data/vendor/nginx/auto/os/darwin +0 -1
  17. data/vendor/nginx/auto/os/freebsd +6 -23
  18. data/vendor/nginx/auto/sources +16 -14
  19. data/vendor/nginx/auto/summary +3 -24
  20. data/vendor/nginx/auto/threads +20 -0
  21. data/vendor/nginx/auto/types/sizeof +2 -12
  22. data/vendor/nginx/auto/unix +50 -6
  23. data/vendor/nginx/configure +5 -0
  24. data/vendor/nginx/contrib/vim/syntax/nginx.vim +183 -50
  25. data/vendor/nginx/src/core/nginx.c +21 -9
  26. data/vendor/nginx/src/core/nginx.h +8 -2
  27. data/vendor/nginx/src/core/ngx_buf.c +88 -0
  28. data/vendor/nginx/src/core/ngx_buf.h +15 -1
  29. data/vendor/nginx/src/core/ngx_conf_file.c +4 -1
  30. data/vendor/nginx/src/core/ngx_connection.c +25 -66
  31. data/vendor/nginx/src/core/ngx_connection.h +1 -3
  32. data/vendor/nginx/src/core/ngx_core.h +11 -3
  33. data/vendor/nginx/src/core/ngx_crypt.c +1 -1
  34. data/vendor/nginx/src/core/ngx_cycle.c +7 -1
  35. data/vendor/nginx/src/core/ngx_cycle.h +6 -2
  36. data/vendor/nginx/src/core/ngx_file.c +13 -5
  37. data/vendor/nginx/src/core/ngx_file.h +6 -0
  38. data/vendor/nginx/src/core/ngx_log.c +215 -21
  39. data/vendor/nginx/src/core/ngx_log.h +9 -1
  40. data/vendor/nginx/src/core/ngx_output_chain.c +104 -15
  41. data/vendor/nginx/src/core/ngx_palloc.c +3 -7
  42. data/vendor/nginx/src/core/ngx_rbtree.c +2 -4
  43. data/vendor/nginx/src/core/ngx_rbtree.h +2 -4
  44. data/vendor/nginx/src/core/ngx_regex.c +14 -6
  45. data/vendor/nginx/src/core/ngx_resolver.c +16 -23
  46. data/vendor/nginx/src/core/ngx_resolver.h +8 -7
  47. data/vendor/nginx/src/core/ngx_shmtx.c +1 -1
  48. data/vendor/nginx/src/core/ngx_slab.c +89 -2
  49. data/vendor/nginx/src/core/ngx_slab.h +3 -0
  50. data/vendor/nginx/src/core/ngx_string.c +58 -2
  51. data/vendor/nginx/src/core/ngx_string.h +1 -0
  52. data/vendor/nginx/src/core/ngx_syslog.c +374 -0
  53. data/vendor/nginx/src/core/ngx_syslog.h +30 -0
  54. data/vendor/nginx/src/core/ngx_thread_pool.c +630 -0
  55. data/vendor/nginx/src/core/ngx_thread_pool.h +36 -0
  56. data/vendor/nginx/src/core/ngx_times.c +19 -2
  57. data/vendor/nginx/src/core/ngx_times.h +1 -0
  58. data/vendor/nginx/src/event/modules/ngx_aio_module.c +1 -1
  59. data/vendor/nginx/src/event/modules/ngx_devpoll_module.c +9 -24
  60. data/vendor/nginx/src/event/modules/ngx_epoll_module.c +152 -28
  61. data/vendor/nginx/src/event/modules/ngx_eventport_module.c +43 -25
  62. data/vendor/nginx/src/event/modules/ngx_kqueue_module.c +86 -156
  63. data/vendor/nginx/src/event/modules/ngx_poll_module.c +21 -37
  64. data/vendor/nginx/src/event/modules/ngx_rtsig_module.c +15 -27
  65. data/vendor/nginx/src/event/modules/ngx_select_module.c +10 -12
  66. data/vendor/nginx/src/event/modules/ngx_win32_select_module.c +7 -9
  67. data/vendor/nginx/src/event/ngx_event.c +5 -33
  68. data/vendor/nginx/src/event/ngx_event.h +15 -50
  69. data/vendor/nginx/src/event/ngx_event_accept.c +11 -10
  70. data/vendor/nginx/src/event/ngx_event_connect.c +0 -11
  71. data/vendor/nginx/src/event/ngx_event_connect.h +1 -4
  72. data/vendor/nginx/src/event/ngx_event_openssl.c +622 -38
  73. data/vendor/nginx/src/event/ngx_event_openssl.h +20 -2
  74. data/vendor/nginx/src/event/ngx_event_openssl_stapling.c +5 -1
  75. data/vendor/nginx/src/event/ngx_event_pipe.c +45 -19
  76. data/vendor/nginx/src/event/ngx_event_pipe.h +3 -0
  77. data/vendor/nginx/src/event/ngx_event_posted.c +7 -145
  78. data/vendor/nginx/src/event/ngx_event_posted.h +12 -39
  79. data/vendor/nginx/src/event/ngx_event_timer.c +50 -70
  80. data/vendor/nginx/src/event/ngx_event_timer.h +2 -14
  81. data/vendor/nginx/src/http/modules/ngx_http_addition_filter_module.c +1 -1
  82. data/vendor/nginx/src/http/modules/ngx_http_autoindex_module.c +416 -71
  83. data/vendor/nginx/src/http/modules/ngx_http_charset_filter_module.c +19 -15
  84. data/vendor/nginx/src/http/modules/ngx_http_dav_module.c +16 -4
  85. data/vendor/nginx/src/http/modules/ngx_http_fastcgi_module.c +601 -134
  86. data/vendor/nginx/src/http/modules/ngx_http_geo_module.c +1 -1
  87. data/vendor/nginx/src/http/modules/ngx_http_geoip_module.c +9 -3
  88. data/vendor/nginx/src/http/modules/ngx_http_gunzip_filter_module.c +9 -3
  89. data/vendor/nginx/src/http/modules/ngx_http_gzip_filter_module.c +9 -3
  90. data/vendor/nginx/src/http/modules/ngx_http_gzip_static_module.c +0 -2
  91. data/vendor/nginx/src/http/modules/ngx_http_headers_filter_module.c +197 -91
  92. data/vendor/nginx/src/http/modules/ngx_http_image_filter_module.c +1 -0
  93. data/vendor/nginx/src/http/modules/ngx_http_limit_conn_module.c +65 -162
  94. data/vendor/nginx/src/http/modules/ngx_http_limit_req_module.c +53 -67
  95. data/vendor/nginx/src/http/modules/ngx_http_log_module.c +128 -23
  96. data/vendor/nginx/src/http/modules/ngx_http_memcached_module.c +25 -6
  97. data/vendor/nginx/src/http/modules/ngx_http_mp4_module.c +1 -1
  98. data/vendor/nginx/src/http/modules/ngx_http_not_modified_filter_module.c +39 -13
  99. data/vendor/nginx/src/http/modules/ngx_http_proxy_module.c +697 -141
  100. data/vendor/nginx/src/http/modules/ngx_http_rewrite_module.c +5 -1
  101. data/vendor/nginx/src/http/modules/ngx_http_scgi_module.c +282 -125
  102. data/vendor/nginx/src/http/modules/ngx_http_ssi_filter_module.c +4 -1
  103. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.c +44 -1
  104. data/vendor/nginx/src/http/modules/ngx_http_ssl_module.h +2 -0
  105. data/vendor/nginx/src/http/modules/ngx_http_stub_status_module.c +10 -8
  106. data/vendor/nginx/src/http/modules/ngx_http_sub_filter_module.c +18 -3
  107. data/vendor/nginx/src/http/modules/ngx_http_upstream_hash_module.c +641 -0
  108. data/vendor/nginx/src/http/modules/ngx_http_upstream_ip_hash_module.c +1 -1
  109. data/vendor/nginx/src/http/modules/ngx_http_upstream_keepalive_module.c +3 -21
  110. data/vendor/nginx/src/http/modules/ngx_http_upstream_least_conn_module.c +0 -5
  111. data/vendor/nginx/src/http/modules/ngx_http_uwsgi_module.c +449 -125
  112. data/vendor/nginx/src/http/modules/ngx_http_xslt_filter_module.c +4 -2
  113. data/vendor/nginx/src/http/modules/perl/ngx_http_perl_module.c +2 -1
  114. data/vendor/nginx/src/http/ngx_http.c +10 -5
  115. data/vendor/nginx/src/http/ngx_http.h +4 -4
  116. data/vendor/nginx/src/http/ngx_http_cache.h +26 -1
  117. data/vendor/nginx/src/http/ngx_http_copy_filter_module.c +109 -68
  118. data/vendor/nginx/src/http/ngx_http_core_module.c +191 -46
  119. data/vendor/nginx/src/http/ngx_http_core_module.h +16 -4
  120. data/vendor/nginx/src/http/ngx_http_file_cache.c +584 -67
  121. data/vendor/nginx/src/http/ngx_http_parse.c +55 -4
  122. data/vendor/nginx/src/http/ngx_http_request.c +14 -6
  123. data/vendor/nginx/src/http/ngx_http_request.h +12 -4
  124. data/vendor/nginx/src/http/ngx_http_request_body.c +114 -28
  125. data/vendor/nginx/src/http/ngx_http_spdy.c +383 -229
  126. data/vendor/nginx/src/http/ngx_http_spdy.h +8 -5
  127. data/vendor/nginx/src/http/ngx_http_spdy_filter_module.c +12 -4
  128. data/vendor/nginx/src/http/ngx_http_special_response.c +2 -2
  129. data/vendor/nginx/src/http/ngx_http_upstream.c +808 -132
  130. data/vendor/nginx/src/http/ngx_http_upstream.h +33 -3
  131. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.c +72 -65
  132. data/vendor/nginx/src/http/ngx_http_upstream_round_robin.h +1 -2
  133. data/vendor/nginx/src/http/ngx_http_variables.c +47 -3
  134. data/vendor/nginx/src/http/ngx_http_write_filter_module.c +15 -6
  135. data/vendor/nginx/src/mail/ngx_mail.c +2 -3
  136. data/vendor/nginx/src/mail/ngx_mail.h +2 -0
  137. data/vendor/nginx/src/mail/ngx_mail_auth_http_module.c +140 -11
  138. data/vendor/nginx/src/mail/ngx_mail_core_module.c +3 -3
  139. data/vendor/nginx/src/mail/ngx_mail_handler.c +79 -2
  140. data/vendor/nginx/src/mail/ngx_mail_imap_module.c +3 -1
  141. data/vendor/nginx/src/mail/ngx_mail_pop3_module.c +3 -1
  142. data/vendor/nginx/src/mail/ngx_mail_smtp_module.c +3 -1
  143. data/vendor/nginx/src/mail/ngx_mail_ssl_module.c +125 -1
  144. data/vendor/nginx/src/mail/ngx_mail_ssl_module.h +8 -0
  145. data/vendor/nginx/src/misc/ngx_cpp_test_module.cpp +1 -1
  146. data/vendor/nginx/src/os/unix/ngx_aio_read_chain.c +1 -1
  147. data/vendor/nginx/src/os/unix/ngx_channel.c +0 -7
  148. data/vendor/nginx/src/os/unix/ngx_darwin_config.h +0 -3
  149. data/vendor/nginx/src/os/unix/ngx_darwin_sendfile_chain.c +44 -208
  150. data/vendor/nginx/src/os/unix/ngx_file_aio_read.c +25 -17
  151. data/vendor/nginx/src/os/unix/ngx_files.c +109 -0
  152. data/vendor/nginx/src/os/unix/ngx_files.h +6 -0
  153. data/vendor/nginx/src/os/unix/ngx_freebsd_config.h +0 -6
  154. data/vendor/nginx/src/os/unix/ngx_freebsd_sendfile_chain.c +78 -206
  155. data/vendor/nginx/src/os/unix/ngx_linux_aio_read.c +25 -14
  156. data/vendor/nginx/src/os/unix/ngx_linux_config.h +4 -1
  157. data/vendor/nginx/src/os/unix/ngx_linux_sendfile_chain.c +235 -194
  158. data/vendor/nginx/src/os/unix/ngx_os.h +25 -3
  159. data/vendor/nginx/src/os/unix/ngx_posix_init.c +4 -2
  160. data/vendor/nginx/src/os/unix/ngx_process_cycle.c +13 -195
  161. data/vendor/nginx/src/os/unix/ngx_process_cycle.h +0 -1
  162. data/vendor/nginx/src/os/unix/ngx_readv_chain.c +27 -108
  163. data/vendor/nginx/src/os/unix/ngx_setproctitle.h +2 -2
  164. data/vendor/nginx/src/os/unix/ngx_solaris_sendfilev_chain.c +12 -67
  165. data/vendor/nginx/src/os/unix/ngx_thread.h +26 -83
  166. data/vendor/nginx/src/os/unix/ngx_thread_cond.c +87 -0
  167. data/vendor/nginx/src/os/unix/ngx_thread_id.c +70 -0
  168. data/vendor/nginx/src/os/unix/ngx_thread_mutex.c +174 -0
  169. data/vendor/nginx/src/os/unix/ngx_user.c +2 -20
  170. data/vendor/nginx/src/os/unix/ngx_writev_chain.c +129 -98
  171. metadata +16 -17
  172. data/vendor/nginx/auto/lib/zlib/patch.zlib.h +0 -10
  173. data/vendor/nginx/src/event/ngx_event_busy_lock.c +0 -286
  174. data/vendor/nginx/src/event/ngx_event_busy_lock.h +0 -65
  175. data/vendor/nginx/src/event/ngx_event_mutex.c +0 -70
  176. data/vendor/nginx/src/http/ngx_http_busy_lock.c +0 -307
  177. data/vendor/nginx/src/http/ngx_http_busy_lock.h +0 -54
  178. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.c +0 -756
  179. data/vendor/nginx/src/os/unix/ngx_freebsd_rfork_thread.h +0 -122
  180. data/vendor/nginx/src/os/unix/ngx_pthread_thread.c +0 -278
  181. data/vendor/nginx/src/os/unix/rfork_thread.S +0 -73
@@ -1,122 +0,0 @@
1
-
2
- /*
3
- * Copyright (C) Igor Sysoev
4
- * Copyright (C) Nginx, Inc.
5
- */
6
-
7
-
8
- #ifndef _NGX_FREEBSD_RFORK_THREAD_H_INCLUDED_
9
- #define _NGX_FREEBSD_RFORK_THREAD_H_INCLUDED_
10
-
11
-
12
- #include <sys/ipc.h>
13
- #include <sys/sem.h>
14
- #include <sched.h>
15
-
16
- typedef pid_t ngx_tid_t;
17
-
18
- #define ngx_log_pid ngx_thread_self()
19
- #define ngx_log_tid 0
20
-
21
- #define NGX_TID_T_FMT "%P"
22
-
23
-
24
- #define NGX_MUTEX_LIGHT 1
25
-
26
- #define NGX_MUTEX_LOCK_BUSY 0x80000000
27
-
28
- typedef volatile struct {
29
- ngx_atomic_t lock;
30
- ngx_log_t *log;
31
- int semid;
32
- } ngx_mutex_t;
33
-
34
-
35
- #define NGX_CV_SIGNAL 64
36
-
37
- typedef struct {
38
- int signo;
39
- int kq;
40
- ngx_tid_t tid;
41
- ngx_log_t *log;
42
- } ngx_cond_t;
43
-
44
-
45
- #define ngx_thread_sigmask(how, set, oset) \
46
- (sigprocmask(how, set, oset) == -1) ? ngx_errno : 0
47
-
48
- #define ngx_thread_sigmask_n "sigprocmask()"
49
-
50
- #define ngx_thread_join(t, p)
51
-
52
- #define ngx_setthrtitle(n) setproctitle(n)
53
-
54
-
55
- extern char *ngx_freebsd_kern_usrstack;
56
- extern size_t ngx_thread_stack_size;
57
-
58
-
59
- static ngx_inline ngx_int_t
60
- ngx_gettid(void)
61
- {
62
- char *sp;
63
-
64
- if (ngx_thread_stack_size == 0) {
65
- return 0;
66
- }
67
-
68
- #if ( __i386__ )
69
-
70
- __asm__ volatile ("mov %%esp, %0" : "=q" (sp));
71
-
72
- #elif ( __amd64__ )
73
-
74
- __asm__ volatile ("mov %%rsp, %0" : "=q" (sp));
75
-
76
- #else
77
-
78
- #error "rfork()ed threads are not supported on this platform"
79
-
80
- #endif
81
-
82
- return (ngx_freebsd_kern_usrstack - sp) / ngx_thread_stack_size;
83
- }
84
-
85
-
86
- ngx_tid_t ngx_thread_self(void);
87
-
88
-
89
- typedef ngx_uint_t ngx_tls_key_t;
90
-
91
- #define NGX_THREAD_KEYS_MAX 16
92
-
93
- extern void **ngx_tls;
94
-
95
- ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key);
96
- #define ngx_thread_key_create_n "the tls key creation"
97
-
98
- ngx_err_t ngx_thread_set_tls(ngx_tls_key_t key, void *value);
99
- #define ngx_thread_set_tls_n "the tls key setting"
100
-
101
-
102
- static void *
103
- ngx_thread_get_tls(ngx_tls_key_t key)
104
- {
105
- if (key >= NGX_THREAD_KEYS_MAX) {
106
- return NULL;
107
- }
108
-
109
- return ngx_tls[key * NGX_THREAD_KEYS_MAX + ngx_gettid()];
110
- }
111
-
112
-
113
- #define ngx_mutex_trylock(m) ngx_mutex_dolock(m, 1)
114
- #define ngx_mutex_lock(m) (void) ngx_mutex_dolock(m, 0)
115
- ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try);
116
- void ngx_mutex_unlock(ngx_mutex_t *m);
117
-
118
-
119
- typedef int (*ngx_rfork_thread_func_pt)(void *arg);
120
-
121
-
122
- #endif /* _NGX_FREEBSD_RFORK_THREAD_H_INCLUDED_ */
@@ -1,278 +0,0 @@
1
-
2
- /*
3
- * Copyright (C) Igor Sysoev
4
- * Copyright (C) Nginx, Inc.
5
- */
6
-
7
-
8
- #include <ngx_config.h>
9
- #include <ngx_core.h>
10
-
11
-
12
- static ngx_uint_t nthreads;
13
- static ngx_uint_t max_threads;
14
-
15
-
16
- static pthread_attr_t thr_attr;
17
-
18
-
19
- ngx_err_t
20
- ngx_create_thread(ngx_tid_t *tid, ngx_thread_value_t (*func)(void *arg),
21
- void *arg, ngx_log_t *log)
22
- {
23
- int err;
24
-
25
- if (nthreads >= max_threads) {
26
- ngx_log_error(NGX_LOG_CRIT, log, 0,
27
- "no more than %ui threads can be created", max_threads);
28
- return NGX_ERROR;
29
- }
30
-
31
- err = pthread_create(tid, &thr_attr, func, arg);
32
-
33
- if (err != 0) {
34
- ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_create() failed");
35
- return err;
36
- }
37
-
38
- ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0,
39
- "thread is created: " NGX_TID_T_FMT, *tid);
40
-
41
- nthreads++;
42
-
43
- return err;
44
- }
45
-
46
-
47
- ngx_int_t
48
- ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle)
49
- {
50
- int err;
51
-
52
- max_threads = n;
53
-
54
- err = pthread_attr_init(&thr_attr);
55
-
56
- if (err != 0) {
57
- ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
58
- "pthread_attr_init() failed");
59
- return NGX_ERROR;
60
- }
61
-
62
- err = pthread_attr_setstacksize(&thr_attr, size);
63
-
64
- if (err != 0) {
65
- ngx_log_error(NGX_LOG_ALERT, cycle->log, err,
66
- "pthread_attr_setstacksize() failed");
67
- return NGX_ERROR;
68
- }
69
-
70
- ngx_threaded = 1;
71
-
72
- return NGX_OK;
73
- }
74
-
75
-
76
- ngx_mutex_t *
77
- ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags)
78
- {
79
- int err;
80
- ngx_mutex_t *m;
81
-
82
- m = ngx_alloc(sizeof(ngx_mutex_t), log);
83
- if (m == NULL) {
84
- return NULL;
85
- }
86
-
87
- m->log = log;
88
-
89
- err = pthread_mutex_init(&m->mutex, NULL);
90
-
91
- if (err != 0) {
92
- ngx_log_error(NGX_LOG_ALERT, m->log, err,
93
- "pthread_mutex_init() failed");
94
- return NULL;
95
- }
96
-
97
- return m;
98
- }
99
-
100
-
101
- void
102
- ngx_mutex_destroy(ngx_mutex_t *m)
103
- {
104
- int err;
105
-
106
- err = pthread_mutex_destroy(&m->mutex);
107
-
108
- if (err != 0) {
109
- ngx_log_error(NGX_LOG_ALERT, m->log, err,
110
- "pthread_mutex_destroy(%p) failed", m);
111
- }
112
-
113
- ngx_free(m);
114
- }
115
-
116
-
117
- void
118
- ngx_mutex_lock(ngx_mutex_t *m)
119
- {
120
- int err;
121
-
122
- if (!ngx_threaded) {
123
- return;
124
- }
125
-
126
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "lock mutex %p", m);
127
-
128
- err = pthread_mutex_lock(&m->mutex);
129
-
130
- if (err != 0) {
131
- ngx_log_error(NGX_LOG_ALERT, m->log, err,
132
- "pthread_mutex_lock(%p) failed", m);
133
- ngx_abort();
134
- }
135
-
136
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
137
-
138
- return;
139
- }
140
-
141
-
142
- ngx_int_t
143
- ngx_mutex_trylock(ngx_mutex_t *m)
144
- {
145
- int err;
146
-
147
- if (!ngx_threaded) {
148
- return NGX_OK;
149
- }
150
-
151
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "try lock mutex %p", m);
152
-
153
- err = pthread_mutex_trylock(&m->mutex);
154
-
155
- if (err == NGX_EBUSY) {
156
- return NGX_AGAIN;
157
- }
158
-
159
- if (err != 0) {
160
- ngx_log_error(NGX_LOG_ALERT, m->log, err,
161
- "pthread_mutex_trylock(%p) failed", m);
162
- ngx_abort();
163
- }
164
-
165
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
166
-
167
- return NGX_OK;
168
- }
169
-
170
-
171
- void
172
- ngx_mutex_unlock(ngx_mutex_t *m)
173
- {
174
- int err;
175
-
176
- if (!ngx_threaded) {
177
- return;
178
- }
179
-
180
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "unlock mutex %p", m);
181
-
182
- err = pthread_mutex_unlock(&m->mutex);
183
-
184
- if (err != 0) {
185
- ngx_log_error(NGX_LOG_ALERT, m->log, err,
186
- "pthread_mutex_unlock(%p) failed", m);
187
- ngx_abort();
188
- }
189
-
190
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is unlocked", m);
191
-
192
- return;
193
- }
194
-
195
-
196
- ngx_cond_t *
197
- ngx_cond_init(ngx_log_t *log)
198
- {
199
- int err;
200
- ngx_cond_t *cv;
201
-
202
- cv = ngx_alloc(sizeof(ngx_cond_t), log);
203
- if (cv == NULL) {
204
- return NULL;
205
- }
206
-
207
- cv->log = log;
208
-
209
- err = pthread_cond_init(&cv->cond, NULL);
210
-
211
- if (err != 0) {
212
- ngx_log_error(NGX_LOG_ALERT, cv->log, err,
213
- "pthread_cond_init() failed");
214
- return NULL;
215
- }
216
-
217
- return cv;
218
- }
219
-
220
-
221
- void
222
- ngx_cond_destroy(ngx_cond_t *cv)
223
- {
224
- int err;
225
-
226
- err = pthread_cond_destroy(&cv->cond);
227
-
228
- if (err != 0) {
229
- ngx_log_error(NGX_LOG_ALERT, cv->log, err,
230
- "pthread_cond_destroy(%p) failed", cv);
231
- }
232
-
233
- ngx_free(cv);
234
- }
235
-
236
-
237
- ngx_int_t
238
- ngx_cond_wait(ngx_cond_t *cv, ngx_mutex_t *m)
239
- {
240
- int err;
241
-
242
- ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p wait", cv);
243
-
244
- err = pthread_cond_wait(&cv->cond, &m->mutex);
245
-
246
- if (err != 0) {
247
- ngx_log_error(NGX_LOG_ALERT, cv->log, err,
248
- "pthread_cond_wait(%p) failed", cv);
249
- return NGX_ERROR;
250
- }
251
-
252
- ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p is waked up", cv);
253
-
254
- ngx_log_debug1(NGX_LOG_DEBUG_MUTEX, m->log, 0, "mutex %p is locked", m);
255
-
256
- return NGX_OK;
257
- }
258
-
259
-
260
- ngx_int_t
261
- ngx_cond_signal(ngx_cond_t *cv)
262
- {
263
- int err;
264
-
265
- ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p to signal", cv);
266
-
267
- err = pthread_cond_signal(&cv->cond);
268
-
269
- if (err != 0) {
270
- ngx_log_error(NGX_LOG_ALERT, cv->log, err,
271
- "pthread_cond_signal(%p) failed", cv);
272
- return NGX_ERROR;
273
- }
274
-
275
- ngx_log_debug1(NGX_LOG_DEBUG_CORE, cv->log, 0, "cv %p is signaled", cv);
276
-
277
- return NGX_OK;
278
- }
@@ -1,73 +0,0 @@
1
-
2
- /*
3
- * Copyright (C) Igor Sysoev
4
- * Copyright (C) Nginx, Inc.
5
- */
6
-
7
-
8
- #include <sys/syscall.h>
9
- #include <machine/asm.h>
10
-
11
- /*
12
- * rfork_thread(3) - rfork_thread(flags, stack, func, arg);
13
- */
14
-
15
- #define KERNCALL int $0x80
16
-
17
- ENTRY(rfork_thread)
18
- push %ebp
19
- mov %esp, %ebp
20
- push %esi
21
-
22
- mov 12(%ebp), %esi # the thread stack address
23
-
24
- sub $4, %esi
25
- mov 20(%ebp), %eax # the thread argument
26
- mov %eax, (%esi)
27
-
28
- sub $4, %esi
29
- mov 16(%ebp), %eax # the thread start address
30
- mov %eax, (%esi)
31
-
32
- push 8(%ebp) # rfork(2) flags
33
- push $0
34
- mov $SYS_rfork, %eax
35
- KERNCALL
36
- jc error
37
-
38
- cmp $0, %edx
39
- jne child
40
-
41
- parent:
42
- add $8, %esp
43
- pop %esi
44
- leave
45
- ret
46
-
47
- child:
48
- mov %esi, %esp
49
- pop %eax
50
- call *%eax # call a thread start address ...
51
- add $4, %esp
52
-
53
- push %eax
54
- push $0
55
- mov $SYS_exit, %eax # ... and exit(2) after a thread would return
56
- KERNCALL
57
-
58
- error:
59
- add $8, %esp
60
- pop %esi
61
- leave
62
- PIC_PROLOGUE
63
-
64
- /* libc's cerror: jmp PIC_PLT(HIDENAME(cerror)) */
65
-
66
- push %eax
67
- call PIC_PLT(CNAME(__error))
68
- pop %ecx
69
- PIC_EPILOGUE
70
- mov %ecx, (%eax)
71
- mov $-1, %eax
72
- mov $-1, %edx
73
- ret