annotate src/core/ngx_regex.h @ 8045:aa28c802409f

Resolver: make TCP write timer event cancelable. Similar to 70e65bf8dfd7, the change is made to ensure that the ability to cancel resolver tasks is fully controlled by the caller. As mentioned in the referenced commit, it is safe to make this timer cancelable because resolve tasks can have their own timeouts that are not cancelable. The scenario where this may become a problem is a periodic background resolve task (not tied to a specific request or a client connection), which receives a response with short TTL, large enough to warrant fallback to a TCP query. With each event loop wakeup, we either have a previously set write timer instance or schedule a new one. The non-cancelable write timer can delay or block graceful shutdown of a worker even if the ngx_resolver_ctx_t->cancelable flag is set by the API user, and there are no other tasks or connections. We use the resolver API in this way to maintain the list of upstream server addresses specified with the 'resolve' parameter, and there could be third-party modules implementing similar logic.
author Aleksei Bavshin <a.bavshin@f5.com>
date Wed, 01 Jun 2022 20:17:23 -0700
parents d07456044b61
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 216
diff changeset
1
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 216
diff changeset
2 /*
444
42d11f017717 nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents: 441
diff changeset
3 * Copyright (C) Igor Sysoev
4412
d620f497c50f Copyright updated.
Maxim Konovalov <maxim@nginx.com>
parents: 4388
diff changeset
4 * Copyright (C) Nginx, Inc.
441
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 216
diff changeset
5 */
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 216
diff changeset
6
da8c5707af39 nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents: 216
diff changeset
7
195
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_REGEX_H_INCLUDED_
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #define _NGX_REGEX_H_INCLUDED_
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 #include <ngx_config.h>
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 #include <ngx_core.h>
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
7981
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
15
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
16 #if (NGX_PCRE2)
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
17
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
18 #define PCRE2_CODE_UNIT_WIDTH 8
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
19 #include <pcre2.h>
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
20
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
21 #define NGX_REGEX_NO_MATCHED PCRE2_ERROR_NOMATCH /* -1 */
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
22
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
23 typedef pcre2_code ngx_regex_t;
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
24
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
25 #else
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
26
195
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
27 #include <pcre.h>
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
28
7981
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
29 #define NGX_REGEX_NO_MATCHED PCRE_ERROR_NOMATCH /* -1 */
4388
005fc2d5e84f Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents: 3325
diff changeset
30
005fc2d5e84f Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents: 3325
diff changeset
31 typedef struct {
4638
6e1a48bcf915 Fixed the ngx_regex.h header file compatibility with C++.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
32 pcre *code;
4388
005fc2d5e84f Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents: 3325
diff changeset
33 pcre_extra *extra;
005fc2d5e84f Added support for regex study and PCRE JIT (ticket #41) optimizations on
Valentin Bartenev <vbart@nginx.com>
parents: 3325
diff changeset
34 } ngx_regex_t;
195
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35
7981
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
36 #endif
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
37
3325
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
38
7982
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
39 #define NGX_REGEX_CASELESS 0x00000001
7983
d07456044b61 Core: added NGX_REGEX_MULTILINE for 3rd party modules.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7982
diff changeset
40 #define NGX_REGEX_MULTILINE 0x00000002
7982
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
41
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
42
1784
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
43 typedef struct {
3325
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
44 ngx_str_t pattern;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
45 ngx_pool_t *pool;
7982
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
46 ngx_uint_t options;
3325
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
47
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
48 ngx_regex_t *regex;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
49 int captures;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
50 int named_captures;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
51 int name_size;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
52 u_char *names;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
53 ngx_str_t err;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
54 } ngx_regex_compile_t;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
55
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
56
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
57 typedef struct {
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
58 ngx_regex_t *regex;
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
59 u_char *name;
1784
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
60 } ngx_regex_elt_t;
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
61
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
62
499
64d9afb209da nginx-0.1.24-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 481
diff changeset
63 void ngx_regex_init(void);
3325
42c16d8bddbe regex named captures
Igor Sysoev <igor@sysoev.ru>
parents: 3319
diff changeset
64 ngx_int_t ngx_regex_compile(ngx_regex_compile_t *rc);
3319
be47fe127f8c ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents: 1784
diff changeset
65
7981
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
66 ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s, int *captures,
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
67 ngx_uint_t size);
7982
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
68
fbbb5ce52995 PCRE2 and PCRE binary compatibility.
Maxim Dounin <mdounin@mdounin.ru>
parents: 7981
diff changeset
69 #if (NGX_PCRE2)
7981
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
70 #define ngx_regex_exec_n "pcre2_match()"
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
71 #else
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
72 #define ngx_regex_exec_n "pcre_exec()"
0b5f12d5c531 PCRE2 library support.
Maxim Dounin <mdounin@mdounin.ru>
parents: 4638
diff changeset
73 #endif
3319
be47fe127f8c ngx_regex_exec() calling optimiztion:
Igor Sysoev <igor@sysoev.ru>
parents: 1784
diff changeset
74
1784
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
75 ngx_int_t ngx_regex_exec_array(ngx_array_t *a, ngx_str_t *s, ngx_log_t *log);
7d313324d874 ngx_regex_exec_array()
Igor Sysoev <igor@sysoev.ru>
parents: 1167
diff changeset
76
195
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
77
8dee38ea9117 nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
78 #endif /* _NGX_REGEX_H_INCLUDED_ */