Mercurial > hg > nginx-quic
annotate src/core/ngx_file.c @ 6699:9cf2dce316e5
Fixed log levels of configuration parsing errors.
All the errors that prevent loading configuration must be printed on the "emerg"
log level. Previously, nginx might silently fail to load configuration in some
cases as the default log level is "error".
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Tue, 20 Sep 2016 15:07:16 +0300 |
parents | 8bf484eef9ab |
children | 1606a817c1d4 |
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:
326
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:
326
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 | 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:
326
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:
326
diff
changeset
|
6 |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_config.h> |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_core.h> |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
5316
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
12 static ngx_int_t ngx_test_full_name(ngx_str_t *name); |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
13 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
14 |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
15 static ngx_atomic_t temp_number = 0; |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
16 ngx_atomic_t *ngx_temp_number = &temp_number; |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
17 ngx_atomic_int_t ngx_random_number = 123456; |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
18 |
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
19 |
5316
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
20 ngx_int_t |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
21 ngx_get_full_name(ngx_pool_t *pool, ngx_str_t *prefix, ngx_str_t *name) |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
22 { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
23 size_t len; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
24 u_char *p, *n; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
25 ngx_int_t rc; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
26 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
27 rc = ngx_test_full_name(name); |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
28 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
29 if (rc == NGX_OK) { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
30 return rc; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
31 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
32 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
33 len = prefix->len; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
34 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
35 #if (NGX_WIN32) |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
36 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
37 if (rc == 2) { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
38 len = rc; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
39 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
40 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
41 #endif |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
42 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
43 n = ngx_pnalloc(pool, len + name->len + 1); |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
44 if (n == NULL) { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
45 return NGX_ERROR; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
46 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
47 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
48 p = ngx_cpymem(n, prefix->data, len); |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
49 ngx_cpystrn(p, name->data, name->len + 1); |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
50 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
51 name->len += len; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
52 name->data = n; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
53 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
54 return NGX_OK; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
55 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
56 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
57 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
58 static ngx_int_t |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
59 ngx_test_full_name(ngx_str_t *name) |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
60 { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
61 #if (NGX_WIN32) |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
62 u_char c0, c1; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
63 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
64 c0 = name->data[0]; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
65 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
66 if (name->len < 2) { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
67 if (c0 == '/') { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
68 return 2; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
69 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
70 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
71 return NGX_DECLINED; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
72 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
73 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
74 c1 = name->data[1]; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
75 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
76 if (c1 == ':') { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
77 c0 |= 0x20; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
78 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
79 if ((c0 >= 'a' && c0 <= 'z')) { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
80 return NGX_OK; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
81 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
82 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
83 return NGX_DECLINED; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
84 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
85 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
86 if (c1 == '/') { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
87 return NGX_OK; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
88 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
89 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
90 if (c0 == '/') { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
91 return 2; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
92 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
93 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
94 return NGX_DECLINED; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
95 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
96 #else |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
97 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
98 if (name->data[0] == '/') { |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
99 return NGX_OK; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
100 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
101 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
102 return NGX_DECLINED; |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
103 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
104 #endif |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
105 } |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
106 |
12dd27b74117
Fixed memory leaks in the root and auth_basic_user_file directives.
Valentin Bartenev <vbart@nginx.com>
parents:
4966
diff
changeset
|
107 |
493 | 108 ssize_t |
109 ngx_write_chain_to_temp_file(ngx_temp_file_t *tf, ngx_chain_t *chain) | |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
110 { |
467 | 111 ngx_int_t rc; |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
112 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
113 if (tf->file.fd == NGX_INVALID_FILE) { |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
114 rc = ngx_create_temp_file(&tf->file, tf->path, tf->pool, |
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
115 tf->persistent, tf->clean, tf->access); |
208
0b67be7d4489
nginx-0.0.1-2003-12-08-23:48:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
195
diff
changeset
|
116 |
5957
570677a06dce
Unified handling of ngx_create_temp_file() return value.
Valentin Bartenev <vbart@nginx.com>
parents:
5377
diff
changeset
|
117 if (rc != NGX_OK) { |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
118 return rc; |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
119 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
120 |
667 | 121 if (tf->log_level) { |
122 ngx_log_error(tf->log_level, tf->file.log, 0, "%s %V", | |
637 | 123 tf->warn, &tf->file.name); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
124 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
125 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
126 |
6442
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
127 #if (NGX_THREADS && NGX_HAVE_PWRITEV) |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
128 |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
129 if (tf->thread_write) { |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
130 return ngx_thread_write_chain_to_file(&tf->file, chain, tf->offset, |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
131 tf->pool); |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
132 } |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
133 |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
134 #endif |
6e10518f95d8
Threads: offloading of temp files writing to thread pools.
Maxim Dounin <mdounin@mdounin.ru>
parents:
6071
diff
changeset
|
135 |
170
c42be4185301
nginx-0.0.1-2003-11-03-01:56:18 import
Igor Sysoev <igor@sysoev.ru>
parents:
160
diff
changeset
|
136 return ngx_write_chain_to_file(&tf->file, chain, tf->offset, tf->pool); |
160
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
137 } |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
138 |
e7e094d34162
nginx-0.0.1-2003-10-27-11:53:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
156
diff
changeset
|
139 |
493 | 140 ngx_int_t |
141 ngx_create_temp_file(ngx_file_t *file, ngx_path_t *path, ngx_pool_t *pool, | |
1075
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
1058
diff
changeset
|
142 ngx_uint_t persistent, ngx_uint_t clean, ngx_uint_t access) |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
143 { |
1090
01b48bcb73bf
shorten temporary names on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1075
diff
changeset
|
144 uint32_t n; |
509 | 145 ngx_err_t err; |
563 | 146 ngx_pool_cleanup_t *cln; |
147 ngx_pool_cleanup_file_t *clnf; | |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
148 |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
149 file->name.len = path->name.len + 1 + path->len + 10; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
150 |
2049 | 151 file->name.data = ngx_pnalloc(pool, file->name.len + 1); |
501 | 152 if (file->name.data == NULL) { |
467 | 153 return NGX_ERROR; |
154 } | |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
155 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
156 #if 0 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
157 for (i = 0; i < file->name.len; i++) { |
6474 | 158 file->name.data[i] = 'X'; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
159 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
160 #endif |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
161 |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
162 ngx_memcpy(file->name.data, path->name.data, path->name.len); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
163 |
1090
01b48bcb73bf
shorten temporary names on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1075
diff
changeset
|
164 n = (uint32_t) ngx_next_temp_number(0); |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
165 |
1747 | 166 cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t)); |
167 if (cln == NULL) { | |
168 return NGX_ERROR; | |
169 } | |
170 | |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 for ( ;; ) { |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
172 (void) ngx_sprintf(file->name.data + path->name.len + 1 + path->len, |
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
173 "%010uD%Z", n); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
174 |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
175 ngx_create_hashed_filename(path, file->name.data, file->name.len); |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
176 |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
177 ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
178 "hashed path: %s", file->name.data); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 |
1046 | 180 file->fd = ngx_open_tempfile(file->name.data, persistent, access); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
182 ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
183 "temp fd:%d", file->fd); |
75
869b10be682f
nginx-0.0.1-2003-04-14-21:04:58 import
Igor Sysoev <igor@sysoev.ru>
parents:
74
diff
changeset
|
184 |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 if (file->fd != NGX_INVALID_FILE) { |
563 | 186 |
1075
4d203f76b757
undo "client_body_in_file_only any"
Igor Sysoev <igor@sysoev.ru>
parents:
1058
diff
changeset
|
187 cln->handler = clean ? ngx_pool_delete_file : ngx_pool_cleanup_file; |
563 | 188 clnf = cln->data; |
509 | 189 |
563 | 190 clnf->fd = file->fd; |
191 clnf->name = file->name.data; | |
192 clnf->log = pool->log; | |
509 | 193 |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
194 return NGX_OK; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
195 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
196 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
197 err = ngx_errno; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
198 |
6468
a5897d360977
Win32: additional error code NGX_EEXIST_FILE (ticket #910).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6442
diff
changeset
|
199 if (err == NGX_EEXIST_FILE) { |
1090
01b48bcb73bf
shorten temporary names on 64-bit platforms
Igor Sysoev <igor@sysoev.ru>
parents:
1075
diff
changeset
|
200 n = (uint32_t) ngx_next_temp_number(1); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 continue; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
202 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
203 |
5969
3281de8142f5
Core: reverted prefix-based temp files (a9138c35120d).
Roman Arutyunyan <arut@nginx.com>
parents:
5967
diff
changeset
|
204 if ((path->level[0] == 0) || (err != NGX_ENOPATH)) { |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 ngx_log_error(NGX_LOG_CRIT, file->log, err, |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
206 ngx_open_tempfile_n " \"%s\" failed", |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
207 file->name.data); |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 return NGX_ERROR; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
209 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
210 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
211 if (ngx_create_path(file, path) == NGX_ERROR) { |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
212 return NGX_ERROR; |
93
738fe44c70d5
nginx-0.0.1-2003-05-21-17:28:21 import
Igor Sysoev <igor@sysoev.ru>
parents:
92
diff
changeset
|
213 } |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
214 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
215 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
216 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
493 | 218 void |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
219 ngx_create_hashed_filename(ngx_path_t *path, u_char *file, size_t len) |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
220 { |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
221 size_t i, level; |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
222 ngx_uint_t n; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
223 |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
224 i = path->name.len + 1; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
225 |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
226 file[path->name.len + path->len] = '/'; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
227 |
6617
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
228 for (n = 0; n < NGX_MAX_PATH_LEVEL; n++) { |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
229 level = path->level[n]; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
230 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
231 if (level == 0) { |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
232 break; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
233 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
234 |
1748
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
235 len -= level; |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
236 file[i - 1] = '/'; |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
237 ngx_memcpy(&file[i], &file[len], level); |
91d381e4e691
ngx_create_hashed_filename() does not need ngx_file_t
Igor Sysoev <igor@sysoev.ru>
parents:
1747
diff
changeset
|
238 i += level + 1; |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
239 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
240 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
241 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
242 |
493 | 243 ngx_int_t |
244 ngx_create_path(ngx_file_t *file, ngx_path_t *path) | |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
245 { |
517 | 246 size_t pos; |
247 ngx_err_t err; | |
248 ngx_uint_t i; | |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
249 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
250 pos = path->name.len; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
251 |
6617
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
252 for (i = 0; i < NGX_MAX_PATH_LEVEL; i++) { |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
253 if (path->level[i] == 0) { |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
254 break; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
255 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
256 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
257 pos += path->level[i] + 1; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
258 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
259 file->name.data[pos] = '\0'; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
260 |
257
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
261 ngx_log_debug1(NGX_LOG_DEBUG_CORE, file->log, 0, |
70e1c7d2b83d
nginx-0.0.2-2004-02-11-20:08:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
208
diff
changeset
|
262 "temp file: \"%s\"", file->name.data); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
263 |
669 | 264 if (ngx_create_dir(file->name.data, 0700) == NGX_FILE_ERROR) { |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
265 err = ngx_errno; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
266 if (err != NGX_EEXIST) { |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
267 ngx_log_error(NGX_LOG_CRIT, file->log, err, |
186
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
268 ngx_create_dir_n " \"%s\" failed", |
c1f3a3c7c5db
nginx-0.0.1-2003-11-17-00:49:42 import
Igor Sysoev <igor@sysoev.ru>
parents:
175
diff
changeset
|
269 file->name.data); |
74
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
270 return NGX_ERROR; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
271 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
272 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
273 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
274 file->name.data[pos] = '/'; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
275 } |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
276 |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
277 return NGX_OK; |
17ab1af8c3dd
nginx-0.0.1-2003-04-11-20:01:14 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
278 } |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
279 |
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
280 |
637 | 281 ngx_err_t |
669 | 282 ngx_create_full_path(u_char *dir, ngx_uint_t access) |
637 | 283 { |
284 u_char *p, ch; | |
285 ngx_err_t err; | |
286 | |
3202
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
287 err = 0; |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
288 |
3201
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
289 #if (NGX_WIN32) |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
290 p = dir + 3; |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
291 #else |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
292 p = dir + 1; |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
293 #endif |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
294 |
5fae6f9085e1
do not create Win32 drive letter in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3035
diff
changeset
|
295 for ( /* void */ ; *p; p++) { |
637 | 296 ch = *p; |
297 | |
298 if (ch != '/') { | |
299 continue; | |
300 } | |
301 | |
302 *p = '\0'; | |
303 | |
669 | 304 if (ngx_create_dir(dir, access) == NGX_FILE_ERROR) { |
637 | 305 err = ngx_errno; |
3202
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
306 |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
307 switch (err) { |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
308 case NGX_EEXIST: |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
309 err = 0; |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
310 case NGX_EACCES: |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
311 break; |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
312 |
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
313 default: |
637 | 314 return err; |
315 } | |
316 } | |
317 | |
318 *p = '/'; | |
319 } | |
320 | |
3202
121fae8c673c
ignore EACCES errors for top level directories in ngx_create_full_path()
Igor Sysoev <igor@sysoev.ru>
parents:
3201
diff
changeset
|
321 return err; |
637 | 322 } |
323 | |
324 | |
495 | 325 ngx_atomic_uint_t |
493 | 326 ngx_next_temp_number(ngx_uint_t collision) |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
327 { |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
328 ngx_atomic_uint_t n, add; |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
329 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
330 add = collision ? ngx_random_number : 1; |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
331 |
3035
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
332 n = ngx_atomic_fetch_add(ngx_temp_number, add); |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
333 |
f9d97311c652
*) share temporary number between workers
Igor Sysoev <igor@sysoev.ru>
parents:
3034
diff
changeset
|
334 return n + add; |
83
a7e45c45a95c
nginx-0.0.1-2003-04-28-19:06:39 import
Igor Sysoev <igor@sysoev.ru>
parents:
75
diff
changeset
|
335 } |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
336 |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
337 |
493 | 338 char * |
339 ngx_conf_set_path_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
340 { |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
341 char *p = conf; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
342 |
467 | 343 ssize_t level; |
629 | 344 ngx_str_t *value; |
290
87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
257
diff
changeset
|
345 ngx_uint_t i, n; |
479 | 346 ngx_path_t *path, **slot; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
347 |
467 | 348 slot = (ngx_path_t **) (p + cmd->offset); |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
349 |
467 | 350 if (*slot) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
351 return "is duplicate"; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
352 } |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
353 |
501 | 354 path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t)); |
355 if (path == NULL) { | |
467 | 356 return NGX_CONF_ERROR; |
357 } | |
190
02a715e85df1
nginx-0.0.1-2003-11-19-00:34:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
358 |
467 | 359 value = cf->args->elts; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
360 |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
361 path->name = value[1]; |
629 | 362 |
661 | 363 if (path->name.data[path->name.len - 1] == '/') { |
364 path->name.len--; | |
365 } | |
366 | |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
367 if (ngx_conf_full_name(cf->cycle, &path->name, 0) != NGX_OK) { |
6069
e37ec0a33901
Core: fixed error handling on ngx_conf_full_name() failure.
Sergey Kandaurov <pluknet@nginx.com>
parents:
5969
diff
changeset
|
368 return NGX_CONF_ERROR; |
629 | 369 } |
370 | |
467 | 371 path->conf_file = cf->conf_file->file.name.data; |
372 path->line = cf->conf_file->line; | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
373 |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
374 for (i = 0, n = 2; n < cf->args->nelts; i++, n++) { |
194
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
190
diff
changeset
|
375 level = ngx_atoi(value[n].data, value[n].len); |
2357fa41738a
nginx-0.0.1-2003-11-21-09:30:49 import
Igor Sysoev <igor@sysoev.ru>
parents:
190
diff
changeset
|
376 if (level == NGX_ERROR || level == 0) { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
377 return "invalid value"; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
378 } |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
379 |
195
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
380 path->level[i] = level; |
8dee38ea9117
nginx-0.0.1-2003-11-25-23:44:56 import
Igor Sysoev <igor@sysoev.ru>
parents:
194
diff
changeset
|
381 path->len += level + 1; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
382 } |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
383 |
6071
7bdd34cd2711
Core: limited levels of subdirectory hierarchy used for temp files.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6070
diff
changeset
|
384 if (path->len > 10 + i) { |
7bdd34cd2711
Core: limited levels of subdirectory hierarchy used for temp files.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6070
diff
changeset
|
385 return "invalid value"; |
7bdd34cd2711
Core: limited levels of subdirectory hierarchy used for temp files.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6070
diff
changeset
|
386 } |
7bdd34cd2711
Core: limited levels of subdirectory hierarchy used for temp files.
Sergey Kandaurov <pluknet@nginx.com>
parents:
6070
diff
changeset
|
387 |
479 | 388 *slot = path; |
467 | 389 |
479 | 390 if (ngx_add_path(cf, slot) == NGX_ERROR) { |
391 return NGX_CONF_ERROR; | |
392 } | |
393 | |
394 return NGX_CONF_OK; | |
395 } | |
396 | |
397 | |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
398 char * |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
399 ngx_conf_merge_path_value(ngx_conf_t *cf, ngx_path_t **path, ngx_path_t *prev, |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
400 ngx_path_init_t *init) |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
401 { |
6617
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
402 ngx_uint_t i; |
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
403 |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
404 if (*path) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
405 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
406 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
407 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
408 if (prev) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
409 *path = prev; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
410 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
411 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
412 |
5375
7d8770196436
Use ngx_pcalloc() in ngx_conf_merge_path_value().
Valentin Bartenev <vbart@nginx.com>
parents:
5330
diff
changeset
|
413 *path = ngx_pcalloc(cf->pool, sizeof(ngx_path_t)); |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
414 if (*path == NULL) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
415 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
416 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
417 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
418 (*path)->name = init->name; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
419 |
5330
314c3d7cc3a5
Backed out f1a91825730a and 7094bd12c1ff.
Maxim Dounin <mdounin@mdounin.ru>
parents:
5317
diff
changeset
|
420 if (ngx_conf_full_name(cf->cycle, &(*path)->name, 0) != NGX_OK) { |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
421 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
422 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
423 |
6617
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
424 for (i = 0; i < NGX_MAX_PATH_LEVEL; i++) { |
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
425 (*path)->level[i] = init->level[i]; |
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
426 (*path)->len += init->level[i] + (init->level[i] ? 1 : 0); |
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
427 } |
2592
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
428 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
429 if (ngx_add_path(cf, path) != NGX_OK) { |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
430 return NGX_CONF_ERROR; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
431 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
432 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
433 return NGX_CONF_OK; |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
434 } |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
435 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
436 |
3a8a53c0c42f
a prelimiary proxy cache support
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
437 char * |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
438 ngx_conf_set_access_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
439 { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
440 char *confp = conf; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
441 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
442 u_char *p; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
443 ngx_str_t *value; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
444 ngx_uint_t i, right, shift, *access; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
445 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
446 access = (ngx_uint_t *) (confp + cmd->offset); |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
447 |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
448 if (*access != NGX_CONF_UNSET_UINT) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
449 return "is duplicate"; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
450 } |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
451 |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
452 value = cf->args->elts; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
453 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
454 *access = 0600; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
455 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
456 for (i = 1; i < cf->args->nelts; i++) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
457 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
458 p = value[i].data; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
459 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
460 if (ngx_strncmp(p, "user:", sizeof("user:") - 1) == 0) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
461 shift = 6; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
462 p += sizeof("user:") - 1; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
463 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
464 } else if (ngx_strncmp(p, "group:", sizeof("group:") - 1) == 0) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
465 shift = 3; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
466 p += sizeof("group:") - 1; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
467 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
468 } else if (ngx_strncmp(p, "all:", sizeof("all:") - 1) == 0) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
469 shift = 0; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
470 p += sizeof("all:") - 1; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
471 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
472 } else { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
473 goto invalid; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
474 } |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
475 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
476 if (ngx_strcmp(p, "rw") == 0) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
477 right = 6; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
478 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
479 } else if (ngx_strcmp(p, "r") == 0) { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
480 right = 4; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
481 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
482 } else { |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
483 goto invalid; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
484 } |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
485 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
486 *access |= right << shift; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
487 } |
1295
5383f5232364
proxy_store and fastcgi_store were changed,
Igor Sysoev <igor@sysoev.ru>
parents:
1291
diff
changeset
|
488 |
1291
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
489 return NGX_CONF_OK; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
490 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
491 invalid: |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
492 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
493 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid value \"%V\"", &value[i]); |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
494 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
495 return NGX_CONF_ERROR; |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
496 } |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
497 |
13a4ce6e7f1e
proxy_store and fastcgi_store
Igor Sysoev <igor@sysoev.ru>
parents:
1091
diff
changeset
|
498 |
493 | 499 ngx_int_t |
500 ngx_add_path(ngx_conf_t *cf, ngx_path_t **slot) | |
479 | 501 { |
502 ngx_uint_t i, n; | |
503 ngx_path_t *path, **p; | |
504 | |
505 path = *slot; | |
506 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
507 p = cf->cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
508 for (i = 0; i < cf->cycle->paths.nelts; i++) { |
479 | 509 if (p[i]->name.len == path->name.len |
510 && ngx_strcmp(p[i]->name.data, path->name.data) == 0) | |
467 | 511 { |
5377
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
512 if (p[i]->data != path->data) { |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
513 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
514 "the same path name \"%V\" " |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
515 "used in %s:%ui and", |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
516 &p[i]->name, p[i]->conf_file, p[i]->line); |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
517 return NGX_ERROR; |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
518 } |
cec155f07c84
Improved check for duplicate path names in ngx_add_path().
Valentin Bartenev <vbart@nginx.com>
parents:
5376
diff
changeset
|
519 |
6617
8bf484eef9ab
Use NGX_MAX_PATH_LEVEL where appropriate.
Ruslan Ermilov <ru@nginx.com>
parents:
6480
diff
changeset
|
520 for (n = 0; n < NGX_MAX_PATH_LEVEL; n++) { |
479 | 521 if (p[i]->level[n] != path->level[n]) { |
522 if (path->conf_file == NULL) { | |
481 | 523 if (p[i]->conf_file == NULL) { |
524 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | |
525 "the default path name \"%V\" has " | |
526 "the same name as another default path, " | |
527 "but the different levels, you need to " | |
528 "redefine one of them in http section", | |
529 &p[i]->name); | |
530 return NGX_ERROR; | |
531 } | |
532 | |
479 | 533 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
534 "the path name \"%V\" in %s:%ui has " | |
481 | 535 "the same name as default path, but " |
479 | 536 "the different levels, you need to " |
537 "define default path in http section", | |
538 &p[i]->name, p[i]->conf_file, p[i]->line); | |
539 return NGX_ERROR; | |
540 } | |
541 | |
467 | 542 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
479 | 543 "the same path name \"%V\" in %s:%ui " |
544 "has the different levels than", | |
545 &p[i]->name, p[i]->conf_file, p[i]->line); | |
546 return NGX_ERROR; | |
467 | 547 } |
548 | |
479 | 549 if (p[i]->level[n] == 0) { |
467 | 550 break; |
551 } | |
552 } | |
553 | |
479 | 554 *slot = p[i]; |
467 | 555 |
479 | 556 return NGX_OK; |
467 | 557 } |
558 } | |
559 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
560 p = ngx_array_push(&cf->cycle->paths); |
501 | 561 if (p == NULL) { |
479 | 562 return NGX_ERROR; |
467 | 563 } |
564 | |
479 | 565 *p = path; |
190
02a715e85df1
nginx-0.0.1-2003-11-19-00:34:08 import
Igor Sysoev <igor@sysoev.ru>
parents:
186
diff
changeset
|
566 |
479 | 567 return NGX_OK; |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
100
diff
changeset
|
568 } |
467 | 569 |
570 | |
493 | 571 ngx_int_t |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
572 ngx_create_paths(ngx_cycle_t *cycle, ngx_uid_t user) |
467 | 573 { |
574 ngx_err_t err; | |
575 ngx_uint_t i; | |
576 ngx_path_t **path; | |
577 | |
4870
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
578 path = cycle->paths.elts; |
8a9b7b4e9f2d
Correct plural form for "path" in the whole source base.
Andrey Belov <defan@nginx.com>
parents:
4572
diff
changeset
|
579 for (i = 0; i < cycle->paths.nelts; i++) { |
467 | 580 |
669 | 581 if (ngx_create_dir(path[i]->name.data, 0700) == NGX_FILE_ERROR) { |
467 | 582 err = ngx_errno; |
583 if (err != NGX_EEXIST) { | |
584 ngx_log_error(NGX_LOG_EMERG, cycle->log, err, | |
585 ngx_create_dir_n " \"%s\" failed", | |
586 path[i]->name.data); | |
587 return NGX_ERROR; | |
588 } | |
589 } | |
590 | |
517 | 591 if (user == (ngx_uid_t) NGX_CONF_UNSET_UINT) { |
467 | 592 continue; |
593 } | |
594 | |
595 #if !(NGX_WIN32) | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1695
diff
changeset
|
596 { |
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1695
diff
changeset
|
597 ngx_file_info_t fi; |
467 | 598 |
2782
4bd7825fab80
uniform ngx_file_info() interface with ngx_fd_info()
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
599 if (ngx_file_info((const char *) path[i]->name.data, &fi) |
4bd7825fab80
uniform ngx_file_info() interface with ngx_fd_info()
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
600 == NGX_FILE_ERROR) |
4bd7825fab80
uniform ngx_file_info() interface with ngx_fd_info()
Igor Sysoev <igor@sysoev.ru>
parents:
2616
diff
changeset
|
601 { |
467 | 602 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, |
603 ngx_file_info_n " \"%s\" failed", path[i]->name.data); | |
604 return NGX_ERROR; | |
605 } | |
606 | |
607 if (fi.st_uid != user) { | |
608 if (chown((const char *) path[i]->name.data, user, -1) == -1) { | |
609 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
610 "chown(\"%s\", %d) failed", | |
611 path[i]->name.data, user); | |
612 return NGX_ERROR; | |
613 } | |
614 } | |
615 | |
616 if ((fi.st_mode & (S_IRUSR|S_IWUSR|S_IXUSR)) | |
617 != (S_IRUSR|S_IWUSR|S_IXUSR)) | |
618 { | |
619 fi.st_mode |= (S_IRUSR|S_IWUSR|S_IXUSR); | |
620 | |
621 if (chmod((const char *) path[i]->name.data, fi.st_mode) == -1) { | |
622 ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, | |
623 "chmod() \"%s\" failed", path[i]->name.data); | |
624 return NGX_ERROR; | |
625 } | |
626 } | |
1704
e584e946e198
move condition declarations inside blocks where they are used
Igor Sysoev <igor@sysoev.ru>
parents:
1695
diff
changeset
|
627 } |
467 | 628 #endif |
629 } | |
630 | |
631 return NGX_OK; | |
632 } | |
956 | 633 |
634 | |
635 ngx_int_t | |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
636 ngx_ext_rename_file(ngx_str_t *src, ngx_str_t *to, ngx_ext_rename_file_t *ext) |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
637 { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
638 u_char *name; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
639 ngx_err_t err; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
640 ngx_copy_file_t cf; |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
641 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
642 #if !(NGX_WIN32) |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
643 |
2394
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
644 if (ext->access) { |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
645 if (ngx_change_file_access(src->data, ext->access) == NGX_FILE_ERROR) { |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
646 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
647 ngx_change_file_access_n " \"%s\" failed", src->data); |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
648 err = 0; |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
649 goto failed; |
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
650 } |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
651 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
652 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
653 #endif |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
654 |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
655 if (ext->time != -1) { |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
656 if (ngx_set_file_time(src->data, ext->fd, ext->time) != NGX_OK) { |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
657 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
658 ngx_set_file_time_n " \"%s\" failed", src->data); |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
659 err = 0; |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
660 goto failed; |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
661 } |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
662 } |
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
663 |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
664 if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) { |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
665 return NGX_OK; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
666 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
667 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
668 err = ngx_errno; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
669 |
3023 | 670 if (err == NGX_ENOPATH) { |
671 | |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
672 if (!ext->create_path) { |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
673 goto failed; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
674 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
675 |
2394
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
676 err = ngx_create_full_path(to->data, ngx_dir_access(ext->path_access)); |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
677 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
678 if (err) { |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
679 ngx_log_error(NGX_LOG_CRIT, ext->log, err, |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
680 ngx_create_dir_n " \"%s\" failed", to->data); |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
681 err = 0; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
682 goto failed; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
683 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
684 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
685 if (ngx_rename_file(src->data, to->data) != NGX_FILE_ERROR) { |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
686 return NGX_OK; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
687 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
688 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
689 err = ngx_errno; |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
690 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
691 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
692 #if (NGX_WIN32) |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
693 |
6468
a5897d360977
Win32: additional error code NGX_EEXIST_FILE (ticket #910).
Maxim Dounin <mdounin@mdounin.ru>
parents:
6442
diff
changeset
|
694 if (err == NGX_EEXIST || err == NGX_EEXIST_FILE) { |
3382
6be1f25bae90
fix Win32 error messages when an temporary file replaces an existent file:
Igor Sysoev <igor@sysoev.ru>
parents:
3202
diff
changeset
|
695 err = ngx_win32_rename_file(src, to, ext->log); |
3387
a02b6d2e3bfd
fix Win32 error message when an temporary file replaces an existent file:
Igor Sysoev <igor@sysoev.ru>
parents:
3382
diff
changeset
|
696 |
a02b6d2e3bfd
fix Win32 error message when an temporary file replaces an existent file:
Igor Sysoev <igor@sysoev.ru>
parents:
3382
diff
changeset
|
697 if (err == 0) { |
a02b6d2e3bfd
fix Win32 error message when an temporary file replaces an existent file:
Igor Sysoev <igor@sysoev.ru>
parents:
3382
diff
changeset
|
698 return NGX_OK; |
a02b6d2e3bfd
fix Win32 error message when an temporary file replaces an existent file:
Igor Sysoev <igor@sysoev.ru>
parents:
3382
diff
changeset
|
699 } |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
700 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
701 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
702 #endif |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
703 |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
704 if (err == NGX_EXDEV) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
705 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
706 cf.size = -1; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
707 cf.buf_size = 0; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
708 cf.access = ext->access; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
709 cf.time = ext->time; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
710 cf.log = ext->log; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
711 |
3032
524ba56ba9f7
fix copy destination name length, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3027
diff
changeset
|
712 name = ngx_alloc(to->len + 1 + 10 + 1, ext->log); |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
713 if (name == NULL) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
714 return NGX_ERROR; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
715 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
716 |
3032
524ba56ba9f7
fix copy destination name length, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3027
diff
changeset
|
717 (void) ngx_sprintf(name, "%*s.%010uD%Z", to->len, to->data, |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
718 (uint32_t) ngx_next_temp_number(0)); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
719 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
720 if (ngx_copy_file(src->data, name, &cf) == NGX_OK) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
721 |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
722 if (ngx_rename_file(name, to->data) != NGX_FILE_ERROR) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
723 ngx_free(name); |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
724 |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
725 if (ngx_delete_file(src->data) == NGX_FILE_ERROR) { |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
726 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
727 ngx_delete_file_n " \"%s\" failed", |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
728 src->data); |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
729 return NGX_ERROR; |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
730 } |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
731 |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
732 return NGX_OK; |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
733 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
734 |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
735 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
736 ngx_rename_file_n " \"%s\" to \"%s\" failed", |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
737 name, to->data); |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
738 |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
739 if (ngx_delete_file(name) == NGX_FILE_ERROR) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
740 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
741 ngx_delete_file_n " \"%s\" failed", name); |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
742 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
743 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
744 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
745 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
746 ngx_free(name); |
3033
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
747 |
db3e5c4c7413
fix copy failure logging and stale files removal, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3032
diff
changeset
|
748 err = 0; |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
749 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
750 |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
751 failed: |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
752 |
1909 | 753 if (ext->delete_file) { |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
754 if (ngx_delete_file(src->data) == NGX_FILE_ERROR) { |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
755 ngx_log_error(NGX_LOG_CRIT, ext->log, ngx_errno, |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
756 ngx_delete_file_n " \"%s\" failed", src->data); |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
757 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
758 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
759 |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
760 if (err) { |
1826
8d50173ccba2
transform ngx_create_path_and_rename_file() to ngx_ext_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1750
diff
changeset
|
761 ngx_log_error(NGX_LOG_CRIT, ext->log, err, |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
762 ngx_rename_file_n " \"%s\" to \"%s\" failed", |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
763 src->data, to->data); |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
764 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
765 |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
766 return NGX_ERROR; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
767 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
768 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
769 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
770 ngx_int_t |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
771 ngx_copy_file(u_char *from, u_char *to, ngx_copy_file_t *cf) |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
772 { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
773 char *buf; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
774 off_t size; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
775 size_t len; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
776 ssize_t n; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
777 ngx_fd_t fd, nfd; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
778 ngx_int_t rc; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
779 ngx_file_info_t fi; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
780 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
781 rc = NGX_ERROR; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
782 buf = NULL; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
783 nfd = NGX_INVALID_FILE; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
784 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
785 fd = ngx_open_file(from, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
786 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
787 if (fd == NGX_INVALID_FILE) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
788 ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
789 ngx_open_file_n " \"%s\" failed", from); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
790 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
791 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
792 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
793 if (cf->size != -1) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
794 size = cf->size; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
795 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
796 } else { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
797 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
798 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
799 ngx_fd_info_n " \"%s\" failed", from); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
800 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
801 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
802 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
803 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
804 size = ngx_file_size(&fi); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
805 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
806 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
807 len = cf->buf_size ? cf->buf_size : 65536; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
808 |
3027
3e1b653fd22f
fix building on 64-bit platforms, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3024
diff
changeset
|
809 if ((off_t) len > size) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
810 len = (size_t) size; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
811 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
812 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
813 buf = ngx_alloc(len, cf->log); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
814 if (buf == NULL) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
815 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
816 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
817 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
818 nfd = ngx_open_file(to, NGX_FILE_WRONLY, NGX_FILE_CREATE_OR_OPEN, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
819 cf->access); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
820 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
821 if (nfd == NGX_INVALID_FILE) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
822 ngx_log_error(NGX_LOG_CRIT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
823 ngx_open_file_n " \"%s\" failed", to); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
824 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
825 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
826 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
827 while (size > 0) { |
2394
dbe746851b31
use ngx_ext_rename_file() for single file MOVE
Igor Sysoev <igor@sysoev.ru>
parents:
2049
diff
changeset
|
828 |
3027
3e1b653fd22f
fix building on 64-bit platforms, introduced in r3025
Igor Sysoev <igor@sysoev.ru>
parents:
3024
diff
changeset
|
829 if ((off_t) len > size) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
830 len = (size_t) size; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
831 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
832 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
833 n = ngx_read_fd(fd, buf, len); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
834 |
4966
c821975c9068
Fixed handling of ngx_write_fd() and ngx_read_fd() errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4870
diff
changeset
|
835 if (n == -1) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
836 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
837 ngx_read_fd_n " \"%s\" failed", from); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
838 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
839 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
840 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
841 if ((size_t) n != len) { |
4966
c821975c9068
Fixed handling of ngx_write_fd() and ngx_read_fd() errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4870
diff
changeset
|
842 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, |
6480 | 843 ngx_read_fd_n " has read only %z of %O from %s", |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
844 n, size, from); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
845 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
846 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
847 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
848 n = ngx_write_fd(nfd, buf, len); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
849 |
4966
c821975c9068
Fixed handling of ngx_write_fd() and ngx_read_fd() errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4870
diff
changeset
|
850 if (n == -1) { |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
851 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
852 ngx_write_fd_n " \"%s\" failed", to); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
853 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
854 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
855 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
856 if ((size_t) n != len) { |
4966
c821975c9068
Fixed handling of ngx_write_fd() and ngx_read_fd() errors.
Valentin Bartenev <vbart@nginx.com>
parents:
4870
diff
changeset
|
857 ngx_log_error(NGX_LOG_ALERT, cf->log, 0, |
6480 | 858 ngx_write_fd_n " has written only %z of %O to %s", |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
859 n, size, to); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
860 goto failed; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
861 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
862 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
863 size -= n; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
864 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
865 |
3481
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
866 if (cf->time != -1) { |
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
867 if (ngx_set_file_time(to, nfd, cf->time) != NGX_OK) { |
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
868 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
869 ngx_set_file_time_n " \"%s\" failed", to); |
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
870 goto failed; |
35e258519a83
do not set file time in ngx_copy_file() if the time is -1,
Igor Sysoev <igor@sysoev.ru>
parents:
3387
diff
changeset
|
871 } |
3024
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
872 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
873 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
874 rc = NGX_OK; |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
875 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
876 failed: |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
877 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
878 if (nfd != NGX_INVALID_FILE) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
879 if (ngx_close_file(nfd) == NGX_FILE_ERROR) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
880 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
881 ngx_close_file_n " \"%s\" failed", to); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
882 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
883 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
884 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
885 if (fd != NGX_INVALID_FILE) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
886 if (ngx_close_file(fd) == NGX_FILE_ERROR) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
887 ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno, |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
888 ngx_close_file_n " \"%s\" failed", from); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
889 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
890 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
891 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
892 if (buf) { |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
893 ngx_free(buf); |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
894 } |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
895 |
8101d9101ed8
allow cross device temporary files atomic copying:
Igor Sysoev <igor@sysoev.ru>
parents:
3023
diff
changeset
|
896 return rc; |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
897 } |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
898 |
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
899 |
1750 | 900 /* |
901 * ctx->init_handler() - see ctx->alloc | |
902 * ctx->file_handler() - file handler | |
903 * ctx->pre_tree_handler() - handler is called before entering directory | |
904 * ctx->post_tree_handler() - handler is called after leaving directory | |
905 * ctx->spec_handler() - special (socket, FIFO, etc.) file handler | |
906 * | |
907 * ctx->data - some data structure, it may be the same on all levels, or | |
908 * reallocated if ctx->alloc is nonzero | |
909 * | |
910 * ctx->alloc - a size of data structure that is allocated at every level | |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4412
diff
changeset
|
911 * and is initialized by ctx->init_handler() |
1750 | 912 * |
913 * ctx->log - a log | |
914 * | |
915 * on fatal (memory) error handler must return NGX_ABORT to stop walking tree | |
916 */ | |
917 | |
1695
8c4532a48b0a
ngx_create_path_and_rename_file()
Igor Sysoev <igor@sysoev.ru>
parents:
1352
diff
changeset
|
918 ngx_int_t |
956 | 919 ngx_walk_tree(ngx_tree_ctx_t *ctx, ngx_str_t *tree) |
920 { | |
921 void *data, *prev; | |
922 u_char *p, *name; | |
923 size_t len; | |
924 ngx_int_t rc; | |
925 ngx_err_t err; | |
977
b9836e87dd4d
style fix: remove trailing spaces
Igor Sysoev <igor@sysoev.ru>
parents:
956
diff
changeset
|
926 ngx_str_t file, buf; |
956 | 927 ngx_dir_t dir; |
928 | |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3481
diff
changeset
|
929 ngx_str_null(&buf); |
956 | 930 |
931 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
932 "walk tree \"%V\"", tree); | |
933 | |
934 if (ngx_open_dir(tree, &dir) == NGX_ERROR) { | |
935 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | |
936 ngx_open_dir_n " \"%s\" failed", tree->data); | |
937 return NGX_ERROR; | |
938 } | |
939 | |
940 prev = ctx->data; | |
941 | |
1058
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
942 if (ctx->alloc) { |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
943 data = ngx_alloc(ctx->alloc, ctx->log); |
956 | 944 if (data == NULL) { |
945 goto failed; | |
946 } | |
947 | |
948 if (ctx->init_handler(data, prev) == NGX_ABORT) { | |
949 goto failed; | |
950 } | |
951 | |
952 ctx->data = data; | |
1319 | 953 |
954 } else { | |
955 data = NULL; | |
956 | 956 } |
957 | |
958 for ( ;; ) { | |
959 | |
960 ngx_set_errno(0); | |
961 | |
962 if (ngx_read_dir(&dir) == NGX_ERROR) { | |
963 err = ngx_errno; | |
964 | |
965 if (err == NGX_ENOMOREFILES) { | |
966 rc = NGX_OK; | |
967 | |
968 } else { | |
969 ngx_log_error(NGX_LOG_CRIT, ctx->log, err, | |
970 ngx_read_dir_n " \"%s\" failed", tree->data); | |
971 rc = NGX_ERROR; | |
972 } | |
973 | |
974 goto done; | |
975 } | |
976 | |
977 len = ngx_de_namelen(&dir); | |
978 name = ngx_de_name(&dir); | |
979 | |
980 ngx_log_debug2(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
981 "tree name %uz:\"%s\"", len, name); | |
982 | |
983 if (len == 1 && name[0] == '.') { | |
984 continue; | |
985 } | |
986 | |
987 if (len == 2 && name[0] == '.' && name[1] == '.') { | |
988 continue; | |
989 } | |
990 | |
991 file.len = tree->len + 1 + len; | |
992 | |
993 if (file.len + NGX_DIR_MASK_LEN > buf.len) { | |
994 | |
995 if (buf.len) { | |
996 ngx_free(buf.data); | |
997 } | |
998 | |
999 buf.len = tree->len + 1 + len + NGX_DIR_MASK_LEN; | |
1000 | |
1001 buf.data = ngx_alloc(buf.len + 1, ctx->log); | |
1002 if (buf.data == NULL) { | |
1003 goto failed; | |
1004 } | |
1005 } | |
1006 | |
1007 p = ngx_cpymem(buf.data, tree->data, tree->len); | |
1008 *p++ = '/'; | |
1009 ngx_memcpy(p, name, len + 1); | |
1010 | |
1011 file.data = buf.data; | |
1012 | |
1013 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
1014 "tree path \"%s\"", file.data); | |
1015 | |
1016 if (!dir.valid_info) { | |
1017 if (ngx_de_info(file.data, &dir) == NGX_FILE_ERROR) { | |
1018 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | |
1019 ngx_de_info_n " \"%s\" failed", file.data); | |
1020 continue; | |
1021 } | |
1022 } | |
1023 | |
1024 if (ngx_de_is_file(&dir)) { | |
1025 | |
1026 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
1027 "tree file \"%s\"", file.data); | |
1028 | |
1058
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1029 ctx->size = ngx_de_size(&dir); |
3970
2d05952a324d
elimination of reading cache files by cache loader
Igor Sysoev <igor@sysoev.ru>
parents:
3516
diff
changeset
|
1030 ctx->fs_size = ngx_de_fs_size(&dir); |
1058
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1031 ctx->access = ngx_de_access(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1032 ctx->mtime = ngx_de_mtime(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1033 |
956 | 1034 if (ctx->file_handler(ctx, &file) == NGX_ABORT) { |
1035 goto failed; | |
1036 } | |
1037 | |
1038 } else if (ngx_de_is_dir(&dir)) { | |
1039 | |
1040 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
1041 "tree enter dir \"%s\"", file.data); | |
1042 | |
1058
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1043 ctx->access = ngx_de_access(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1044 ctx->mtime = ngx_de_mtime(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1045 |
5967
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1046 rc = ctx->pre_tree_handler(ctx, &file); |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1047 |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1048 if (rc == NGX_ABORT) { |
956 | 1049 goto failed; |
1050 } | |
1051 | |
5967
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1052 if (rc == NGX_DECLINED) { |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1053 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1054 "tree skip dir \"%s\"", file.data); |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1055 continue; |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1056 } |
863d9de1e62b
Core: supported directory skipping in ngx_walk_tree().
Roman Arutyunyan <arut@nginx.com>
parents:
5958
diff
changeset
|
1057 |
956 | 1058 if (ngx_walk_tree(ctx, &file) == NGX_ABORT) { |
1059 goto failed; | |
1060 } | |
1061 | |
1058
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1062 ctx->access = ngx_de_access(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1063 ctx->mtime = ngx_de_mtime(&dir); |
01f818c6f7de
add size, access, and mtime to ngx_walk_tree()
Igor Sysoev <igor@sysoev.ru>
parents:
1046
diff
changeset
|
1064 |
956 | 1065 if (ctx->post_tree_handler(ctx, &file) == NGX_ABORT) { |
1066 goto failed; | |
1067 } | |
1068 | |
1069 } else { | |
1070 | |
1071 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ctx->log, 0, | |
1072 "tree special \"%s\"", file.data); | |
1073 | |
1074 if (ctx->spec_handler(ctx, &file) == NGX_ABORT) { | |
1075 goto failed; | |
1076 } | |
1077 } | |
1078 } | |
1079 | |
1080 failed: | |
1081 | |
1082 rc = NGX_ABORT; | |
1083 | |
1084 done: | |
1085 | |
1086 if (buf.len) { | |
1087 ngx_free(buf.data); | |
1088 } | |
1089 | |
1319 | 1090 if (data) { |
1091 ngx_free(data); | |
956 | 1092 ctx->data = prev; |
1093 } | |
1094 | |
1095 if (ngx_close_dir(&dir) == NGX_ERROR) { | |
1096 ngx_log_error(NGX_LOG_CRIT, ctx->log, ngx_errno, | |
1097 ngx_close_dir_n " \"%s\" failed", tree->data); | |
1098 } | |
1099 | |
1100 return rc; | |
1101 } |