annotate src/os/unix/ngx_os.h @ 9299:2706b60dc225 default tip

Core: error logging rate limiting. With this change, error logging to files can be rate-limited with the "rate=" parameter. The parameter specifies allowed log messages rate to a particular file (per worker), in messages per second (m/s). By default, "rate=1000m/s" is used. Rate limiting is implemented using the "leaky bucket" method, similarly to the limit_req module. Maximum burst size is set to the number of log messages per second for each severity level, so "error" messages are logged even if the rate limit is hit by "info" messages (but not vice versa). When the limit is reached for a particular level, the "too many log messages, limiting" message is logged at this level. If debug logging is enabled, either for the particular log file or for the particular connection, rate limiting is not used.
author Maxim Dounin <mdounin@mdounin.ru>
date Tue, 25 Jun 2024 22:58:56 +0300
parents 3d455e37abf8
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: 417
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: 417
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: 4223
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: 417
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: 417
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: 417
diff changeset
7
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
8 #ifndef _NGX_OS_H_INCLUDED_
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
9 #define _NGX_OS_H_INCLUDED_
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
10
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
11
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
12 #include <ngx_config.h>
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
13 #include <ngx_core.h>
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
14
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
15
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
16 #define NGX_IO_SENDFILE 1
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
17
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
18
393
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
19 typedef ssize_t (*ngx_recv_pt)(ngx_connection_t *c, u_char *buf, size_t size);
5882
ec81934727a1 Core: added limit to recv_chain().
Roman Arutyunyan <arut@nginx.com>
parents: 5854
diff changeset
20 typedef ssize_t (*ngx_recv_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
ec81934727a1 Core: added limit to recv_chain().
Roman Arutyunyan <arut@nginx.com>
parents: 5854
diff changeset
21 off_t limit);
393
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
22 typedef ssize_t (*ngx_send_pt)(ngx_connection_t *c, u_char *buf, size_t size);
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
23 typedef ngx_chain_t *(*ngx_send_chain_pt)(ngx_connection_t *c, ngx_chain_t *in,
493
975f62e77f02 nginx-0.1.21-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
24 off_t limit);
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
25
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
26 typedef struct {
393
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
27 ngx_recv_pt recv;
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
28 ngx_recv_chain_pt recv_chain;
1689
0b592a68aade ngx_udp_recv()
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
29 ngx_recv_pt udp_recv;
393
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
30 ngx_send_pt send;
6436
8f038068f4bc Stream: UDP proxy.
Roman Arutyunyan <arut@nginx.com>
parents: 6125
diff changeset
31 ngx_send_pt udp_send;
6692
56fc55e32f23 Stream: filters.
Roman Arutyunyan <arut@nginx.com>
parents: 6483
diff changeset
32 ngx_send_chain_pt udp_send_chain;
393
5659d773cfa8 nginx-0.0.7-2004-07-15-20:35:51 import
Igor Sysoev <igor@sysoev.ru>
parents: 373
diff changeset
33 ngx_send_chain_pt send_chain;
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 393
diff changeset
34 ngx_uint_t flags;
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
35 } ngx_os_io_t;
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
36
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
37
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
38 ngx_int_t ngx_os_init(ngx_log_t *log);
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
39 void ngx_os_status(ngx_log_t *log);
539
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
40 ngx_int_t ngx_os_specific_init(ngx_log_t *log);
371c1cee100d nginx-0.1.44-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 515
diff changeset
41 void ngx_os_specific_status(ngx_log_t *log);
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
42 ngx_int_t ngx_daemon(ngx_log_t *log);
9270
3d455e37abf8 Core: PID file writing synchronization.
Maxim Dounin <mdounin@mdounin.ru>
parents: 6692
diff changeset
43 ngx_int_t ngx_daemon_sync(ngx_log_t *log);
6483
3a50ccd94333 Fixed ngx_os_signal_process() prototype.
Ruslan Ermilov <ru@nginx.com>
parents: 6436
diff changeset
44 ngx_int_t ngx_os_signal_process(ngx_cycle_t *cycle, char *sig, ngx_pid_t pid);
184
1bf718ce0dde nginx-0.0.1-2003-11-14-10:20:34 import
Igor Sysoev <igor@sysoev.ru>
parents: 183
diff changeset
45
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
46
290
87e73f067470 nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents: 278
diff changeset
47 ssize_t ngx_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
5882
ec81934727a1 Core: added limit to recv_chain().
Roman Arutyunyan <arut@nginx.com>
parents: 5854
diff changeset
48 ssize_t ngx_readv_chain(ngx_connection_t *c, ngx_chain_t *entry, off_t limit);
1689
0b592a68aade ngx_udp_recv()
Igor Sysoev <igor@sysoev.ru>
parents: 539
diff changeset
49 ssize_t ngx_udp_unix_recv(ngx_connection_t *c, u_char *buf, size_t size);
417
0526206251f6 nginx-0.0.10-2004-09-07-19:29:22 import
Igor Sysoev <igor@sysoev.ru>
parents: 393
diff changeset
50 ssize_t ngx_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
362
7650aea1816f nginx-0.0.7-2004-06-21-19:59:32 import
Igor Sysoev <igor@sysoev.ru>
parents: 292
diff changeset
51 ngx_chain_t *ngx_writev_chain(ngx_connection_t *c, ngx_chain_t *in,
493
975f62e77f02 nginx-0.1.21-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 473
diff changeset
52 off_t limit);
6436
8f038068f4bc Stream: UDP proxy.
Roman Arutyunyan <arut@nginx.com>
parents: 6125
diff changeset
53 ssize_t ngx_udp_unix_send(ngx_connection_t *c, u_char *buf, size_t size);
6692
56fc55e32f23 Stream: filters.
Roman Arutyunyan <arut@nginx.com>
parents: 6483
diff changeset
54 ngx_chain_t *ngx_udp_unix_sendmsg_chain(ngx_connection_t *c, ngx_chain_t *in,
56fc55e32f23 Stream: filters.
Roman Arutyunyan <arut@nginx.com>
parents: 6483
diff changeset
55 off_t limit);
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
56
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
57
5854
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
58 #if (IOV_MAX > 64)
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
59 #define NGX_IOVS_PREALLOCATE 64
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
60 #else
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
61 #define NGX_IOVS_PREALLOCATE IOV_MAX
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
62 #endif
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
63
b63e829621ab Generalized definitions of the number of preallocated iovec's.
Valentin Bartenev <vbart@nginx.com>
parents: 4412
diff changeset
64
5913
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
65 typedef struct {
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
66 struct iovec *iovs;
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
67 ngx_uint_t count;
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
68 size_t size;
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
69 ngx_uint_t nalloc;
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
70 } ngx_iovec_t;
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
71
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
72 ngx_chain_t *ngx_output_chain_to_iovec(ngx_iovec_t *vec, ngx_chain_t *in,
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
73 size_t limit, ngx_log_t *log);
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
74
8e903522c17a Introduced the ngx_output_chain_to_iovec() function.
Valentin Bartenev <vbart@nginx.com>
parents: 5882
diff changeset
75
5917
2c64b69daec5 Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents: 5913
diff changeset
76 ssize_t ngx_writev(ngx_connection_t *c, ngx_iovec_t *vec);
2c64b69daec5 Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents: 5913
diff changeset
77
2c64b69daec5 Moved writev() handling code to a separate function.
Valentin Bartenev <vbart@nginx.com>
parents: 5913
diff changeset
78
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
79 extern ngx_os_io_t ngx_os_io;
449
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
80 extern ngx_int_t ngx_ncpu;
3b1e8c9df9ad nginx-0.1.0-2004-10-04-00:02:06 import
Igor Sysoev <igor@sysoev.ru>
parents: 444
diff changeset
81 extern ngx_int_t ngx_max_sockets;
473
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
82 extern ngx_uint_t ngx_inherited_nonblocking;
8e8f3af115b5 nginx-0.1.11-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 469
diff changeset
83 extern ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush;
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
84
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
85
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
86 #if (NGX_FREEBSD)
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
87 #include <ngx_freebsd.h>
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
88
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
89
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
90 #elif (NGX_LINUX)
196
11fbd0fc041d nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 184
diff changeset
91 #include <ngx_linux.h>
11fbd0fc041d nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 184
diff changeset
92
11fbd0fc041d nginx-0.0.1-2003-11-26-18:42:18 import
Igor Sysoev <igor@sysoev.ru>
parents: 184
diff changeset
93
455
295d97d70c69 nginx-0.1.2-RELEASE import
Igor Sysoev <igor@sysoev.ru>
parents: 449
diff changeset
94 #elif (NGX_SOLARIS)
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 196
diff changeset
95 #include <ngx_solaris.h>
2128
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents: 1689
diff changeset
96
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents: 1689
diff changeset
97
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents: 1689
diff changeset
98 #elif (NGX_DARWIN)
345a014436d4 *) move Darwin support to separate files
Igor Sysoev <igor@sysoev.ru>
parents: 1689
diff changeset
99 #include <ngx_darwin.h>
198
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 196
diff changeset
100 #endif
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 196
diff changeset
101
34995c5ec6c4 nginx-0.0.1-2003-11-27-22:01:37 import
Igor Sysoev <igor@sysoev.ru>
parents: 196
diff changeset
102
183
4c698194c56d nginx-0.0.1-2003-11-13-19:16:33 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff changeset
103 #endif /* _NGX_OS_H_INCLUDED_ */