annotate src/os/unix/ngx_setaffinity.c @ 7690:8253424d1aff

Added size check to ngx_http_alloc_large_header_buffer(). This ensures that copying won't write more than the buffer size even if the buffer comes from hc->free and it is smaller than the large client header buffer size in the virtual host configuration. This might happen if size of large client header buffers is different in name-based virtual hosts, similarly to the problem with number of buffers fixed in 6926:e662cbf1b932.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 06 Aug 2020 05:02:22 +0300
parents 7296b38f6416
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
1
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
2 /*
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
3 * Copyright (C) Nginx, Inc.
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
4 */
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
5
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
6
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
7 #include <ngx_config.h>
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
8 #include <ngx_core.h>
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
9
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
10
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
11 #if (NGX_HAVE_CPUSET_SETAFFINITY)
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
12
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
13 void
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
14 ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log)
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
15 {
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
16 ngx_uint_t i;
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
17
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
18 for (i = 0; i < CPU_SETSIZE; i++) {
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
19 if (CPU_ISSET(i, cpu_affinity)) {
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
20 ngx_log_error(NGX_LOG_NOTICE, log, 0,
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
21 "cpuset_setaffinity(): using cpu #%ui", i);
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
22 }
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
23 }
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
24
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
25 if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
26 sizeof(cpuset_t), cpu_affinity) == -1)
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
27 {
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
28 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
29 "cpuset_setaffinity() failed");
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
30 }
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
31 }
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
32
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
33 #elif (NGX_HAVE_SCHED_SETAFFINITY)
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
34
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
35 void
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
36 ngx_setaffinity(ngx_cpuset_t *cpu_affinity, ngx_log_t *log)
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
37 {
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
38 ngx_uint_t i;
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
39
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
40 for (i = 0; i < CPU_SETSIZE; i++) {
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
41 if (CPU_ISSET(i, cpu_affinity)) {
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
42 ngx_log_error(NGX_LOG_NOTICE, log, 0,
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
43 "sched_setaffinity(): using cpu #%ui", i);
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
44 }
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
45 }
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
46
6402
7296b38f6416 Core: added support for more than 64 CPUs in worker_cpu_affinity.
Vladimir Homutov <vl@nginx.com>
parents: 4549
diff changeset
47 if (sched_setaffinity(0, sizeof(cpu_set_t), cpu_affinity) == -1) {
4549
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
48 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno,
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
49 "sched_setaffinity() failed");
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
50 }
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
51 }
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
52
f31162fefe01 worker_cpu_affinity: cleaned up Linux implementation, added FreeBSD support.
Ruslan Ermilov <ru@nginx.com>
parents:
diff changeset
53 #endif