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