annotate src/os/unix/ngx_thread_cond.c @ 7355:b64adc956643

Rewrite: removed r->err_status special handling (ticket #1634). Trying to look into r->err_status in the "return" directive makes it behave differently than real errors generated in other parts of the code, and is an endless source of various problems. This behaviour was introduced in 726:7b71936d5299 (0.4.4) with the comment "fix: "return" always overrode "error_page" response code". It is not clear if there were any real cases this was expected to fix, but there are several cases which are broken due to this change, some previously fixed (4147:7f64de1cc2c0). In ticket #1634, the problem is that when r->err_status is set to a non-special status code, it is not possible to return a response by simply returning r->err_status. If this is the case, the only option is to return script's e->status instead. An example configuration: location / { error_page 404 =200 /err502; return 404; } location = /err502 { return 502; } After the change, such a configuration will properly return standard 502 error, much like it happens when a 502 error is generated by proxy_pass. This also fixes the following configuration to properly close connection as clearly requested by "return 444": location / { error_page 404 /close; return 404; } location = /close { return 444; } Previously, this required "error_page 404 = /close;" to work as intended.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 21 Sep 2018 15:59:33 +0300
parents 022ea0d17177
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6018
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
1
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
2 /*
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
4 * Copyright (C) Nginx, Inc.
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
5 */
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
6
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
7
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
8 #include <ngx_config.h>
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
9 #include <ngx_core.h>
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
10
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
11
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
12 ngx_int_t
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
13 ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log)
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
14 {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
15 ngx_err_t err;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
16
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
17 err = pthread_cond_init(cond, NULL);
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
18 if (err == 0) {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
19 return NGX_OK;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
20 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
21
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
22 ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_init() failed");
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
23 return NGX_ERROR;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
24 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
25
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
26
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
27 ngx_int_t
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
28 ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log)
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
29 {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
30 ngx_err_t err;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
31
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
32 err = pthread_cond_destroy(cond);
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
33 if (err == 0) {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
34 return NGX_OK;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
35 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
36
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
37 ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_destroy() failed");
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
38 return NGX_ERROR;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
39 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
40
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
41
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
42 ngx_int_t
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
43 ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log)
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
44 {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
45 ngx_err_t err;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
46
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
47 err = pthread_cond_signal(cond);
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
48 if (err == 0) {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
49 return NGX_OK;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
50 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
51
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
52 ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_signal() failed");
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
53 return NGX_ERROR;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
54 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
55
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
56
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
57 ngx_int_t
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
58 ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx,
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
59 ngx_log_t *log)
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
60 {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
61 ngx_err_t err;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
62
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
63 err = pthread_cond_wait(cond, mtx);
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
64
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
65 #if 0
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
66 ngx_time_update();
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
67 #endif
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
68
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
69 if (err == 0) {
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
70 return NGX_OK;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
71 }
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
72
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
73 ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_cond_wait() failed");
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
74
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
75 return NGX_ERROR;
466bd63b63d1 Thread pools implementation.
Valentin Bartenev <vbart@nginx.com>
parents:
diff changeset
76 }