Mercurial > hg > nginx
annotate src/core/ngx_open_file_cache.c @ 1572:a3c0b8dadc16
ngx_md5.h
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Oct 2007 11:59:47 +0000 |
parents | 614090b26fbf |
children | 4fc402c3ec73 |
rev | line source |
---|---|
1453 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #include <ngx_config.h> | |
8 #include <ngx_core.h> | |
9 #include <ngx_event.h> | |
10 | |
11 | |
12 /* | |
13 * open file cache caches | |
14 * open file handles with stat() info; | |
15 * directories stat() info; | |
16 * files and directories errors: not found, access denied, etc. | |
17 */ | |
18 | |
19 | |
20 static void ngx_open_file_cache_cleanup(void *data); | |
21 static void ngx_open_file_cleanup(void *data); | |
22 static void ngx_close_cached_file(ngx_open_file_cache_t *cache, | |
23 ngx_cached_open_file_t *file, ngx_log_t *log); | |
24 static ngx_int_t ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, | |
25 ngx_log_t *log); | |
26 static void ngx_expire_old_cached_files(ngx_open_file_cache_t *cache, | |
27 ngx_uint_t n, ngx_log_t *log); | |
28 static void ngx_open_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp, | |
29 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel); | |
30 static void ngx_open_file_cache_remove(ngx_event_t *ev); | |
31 | |
32 | |
33 ngx_open_file_cache_t * | |
34 ngx_open_file_cache_init(ngx_pool_t *pool, ngx_uint_t max, time_t inactive) | |
35 { | |
36 ngx_rbtree_node_t *sentinel; | |
37 ngx_pool_cleanup_t *cln; | |
38 ngx_open_file_cache_t *cache; | |
39 | |
40 cache = ngx_palloc(pool, sizeof(ngx_open_file_cache_t)); | |
41 if (cache == NULL) { | |
42 return NULL; | |
43 } | |
44 | |
45 cache->list_head.prev = NULL; | |
46 cache->list_head.next = &cache->list_tail; | |
47 | |
48 cache->list_tail.prev = &cache->list_head; | |
49 cache->list_tail.next = NULL; | |
50 | |
51 sentinel = ngx_palloc(pool, sizeof(ngx_rbtree_node_t)); | |
52 if (sentinel == NULL) { | |
53 return NULL; | |
54 } | |
55 | |
56 ngx_rbtree_sentinel_init(sentinel); | |
57 | |
58 cache->rbtree.root = sentinel; | |
59 cache->rbtree.sentinel = sentinel; | |
60 cache->rbtree.insert = ngx_open_file_cache_rbtree_insert_value; | |
61 | |
62 cache->current = 0; | |
63 cache->max = max; | |
64 cache->inactive = inactive; | |
65 | |
66 cln = ngx_pool_cleanup_add(pool, 0); | |
67 if (cln == NULL) { | |
68 return NULL; | |
69 } | |
70 | |
71 cln->handler = ngx_open_file_cache_cleanup; | |
72 cln->data = cache; | |
73 | |
74 return cache; | |
75 } | |
76 | |
77 | |
78 static void | |
79 ngx_open_file_cache_cleanup(void *data) | |
80 { | |
81 ngx_open_file_cache_t *cache = data; | |
82 | |
83 ngx_cached_open_file_t *file; | |
84 | |
85 ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, | |
86 "open file cache cleanup"); | |
87 | |
88 for ( ;; ) { | |
89 | |
90 file = cache->list_tail.prev; | |
91 | |
92 if (file == &cache->list_head) { | |
93 break; | |
94 } | |
95 | |
96 file->next->prev = file->prev; | |
97 file->prev->next = file->next; | |
98 | |
99 ngx_rbtree_delete(&cache->rbtree, &file->node); | |
100 | |
101 cache->current--; | |
102 | |
103 ngx_log_debug1(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0, | |
104 "delete cached open file: %s", file->name); | |
105 | |
106 if (!file->err && !file->is_dir) { | |
107 file->close = 1; | |
108 file->count = 0; | |
109 ngx_close_cached_file(cache, file, ngx_cycle->log); | |
110 | |
111 } else { | |
112 ngx_free(file->name); | |
113 ngx_free(file); | |
114 } | |
115 } | |
116 | |
117 if (cache->current) { | |
118 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, | |
119 "%d items still leave in open file cache", | |
120 cache->current); | |
121 } | |
122 | |
123 if (cache->rbtree.root != cache->rbtree.sentinel) { | |
124 ngx_log_error(NGX_LOG_ALERT, ngx_cycle->log, 0, | |
125 "rbtree still is not empty in open file cache"); | |
126 | |
127 } | |
128 } | |
129 | |
130 | |
131 ngx_int_t | |
132 ngx_open_cached_file(ngx_open_file_cache_t *cache, ngx_str_t *name, | |
133 ngx_open_file_info_t *of, ngx_pool_t *pool) | |
134 { | |
135 time_t now; | |
136 uint32_t hash; | |
137 ngx_int_t rc; | |
138 ngx_rbtree_node_t *node, *sentinel; | |
139 ngx_pool_cleanup_t *cln; | |
140 ngx_cached_open_file_t *file; | |
141 ngx_pool_cleanup_file_t *clnf; | |
142 ngx_open_file_cache_event_t *fev; | |
143 ngx_open_file_cache_cleanup_t *ofcln; | |
144 | |
145 of->err = 0; | |
146 | |
147 if (cache == NULL) { | |
148 | |
149 cln = ngx_pool_cleanup_add(pool, sizeof(ngx_pool_cleanup_file_t)); | |
150 if (cln == NULL) { | |
151 return NGX_ERROR; | |
152 } | |
153 | |
154 rc = ngx_open_and_stat_file(name->data, of, pool->log); | |
155 | |
156 if (rc == NGX_OK && !of->is_dir) { | |
157 cln->handler = ngx_pool_cleanup_file; | |
158 clnf = cln->data; | |
159 | |
160 clnf->fd = of->fd; | |
161 clnf->name = name->data; | |
162 clnf->log = pool->log; | |
163 } | |
164 | |
165 return rc; | |
166 } | |
167 | |
168 cln = ngx_pool_cleanup_add(pool, sizeof(ngx_open_file_cache_cleanup_t)); | |
169 if (cln == NULL) { | |
170 return NGX_ERROR; | |
171 } | |
172 | |
173 hash = ngx_crc32_long(name->data, name->len); | |
174 | |
175 node = cache->rbtree.root; | |
176 sentinel = cache->rbtree.sentinel; | |
177 | |
178 now = ngx_time(); | |
179 | |
180 while (node != sentinel) { | |
181 | |
182 if (hash < node->key) { | |
183 node = node->left; | |
184 continue; | |
185 } | |
186 | |
187 if (hash > node->key) { | |
188 node = node->right; | |
189 continue; | |
190 } | |
191 | |
192 /* hash == node->key */ | |
193 | |
194 do { | |
195 file = (ngx_cached_open_file_t *) node; | |
196 | |
197 rc = ngx_strcmp(name->data, file->name); | |
198 | |
199 if (rc == 0) { | |
200 | |
201 file->next->prev = file->prev; | |
202 file->prev->next = file->next; | |
203 | |
204 if (file->event || now - file->created < of->retest) { | |
205 if (file->err == 0) { | |
206 of->fd = file->fd; | |
207 of->uniq = file->uniq; | |
208 of->mtime = file->mtime; | |
209 of->size = file->size; | |
210 | |
211 of->is_dir = file->is_dir; | |
212 of->is_file = file->is_file; | |
213 of->is_link = file->is_link; | |
214 of->is_exec = file->is_exec; | |
215 | |
216 if (!file->is_dir) { | |
217 file->count++; | |
218 } | |
219 | |
220 } else { | |
221 of->err = file->err; | |
222 } | |
223 | |
224 goto found; | |
225 } | |
226 | |
227 ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0, | |
228 "retest open file: %s, fd:%d, c:%d, e:%d", | |
229 file->name, file->fd, file->count, file->err); | |
230 | |
231 if (file->is_dir) { | |
232 | |
233 /* | |
234 * chances that directory became file are very small | |
235 * so test_dir flag allows to use a single ngx_file_info() | |
236 * syscall instead of three syscalls | |
237 */ | |
238 | |
239 of->test_dir = 1; | |
240 } | |
241 | |
242 rc = ngx_open_and_stat_file(name->data, of, pool->log); | |
243 | |
244 if (rc != NGX_OK && (of->err == 0 || !of->errors)) { | |
245 goto failed; | |
246 } | |
247 | |
248 if (of->is_dir) { | |
249 if (file->is_dir || file->err) { | |
250 goto update; | |
251 } | |
252 | |
253 /* file became directory */ | |
254 | |
255 } else if (of->err == 0) { /* file */ | |
256 | |
257 if (file->is_dir || file->err) { | |
258 goto update; | |
259 } | |
260 | |
261 if (of->uniq == file->uniq | |
262 && of->mtime == file->mtime | |
263 && of->size == file->size) | |
264 { | |
265 if (ngx_close_file(of->fd) == NGX_FILE_ERROR) { | |
266 ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno, | |
267 ngx_close_file_n " \"%s\" failed", | |
268 name->data); | |
269 } | |
270 | |
271 of->fd = file->fd; | |
272 file->count++; | |
273 | |
274 goto renew; | |
275 } | |
276 | |
277 /* file was changed */ | |
278 | |
279 } else { /* error to cache */ | |
280 | |
281 if (file->err || file->is_dir) { | |
282 goto update; | |
283 } | |
284 | |
285 /* file was removed, etc. */ | |
286 } | |
287 | |
288 if (file->count == 0) { | |
289 if (ngx_close_file(file->fd) == NGX_FILE_ERROR) { | |
290 ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno, | |
291 ngx_close_file_n " \"%s\" failed", | |
292 name->data); | |
293 } | |
294 | |
295 goto update; | |
296 } | |
297 | |
298 ngx_rbtree_delete(&cache->rbtree, &file->node); | |
299 | |
300 cache->current--; | |
301 | |
302 file->close = 1; | |
303 | |
304 goto create; | |
305 } | |
306 | |
307 node = (rc < 0) ? node->left : node->right; | |
308 | |
309 } while (node != sentinel && hash == node->key); | |
310 | |
311 break; | |
312 } | |
313 | |
314 /* not found */ | |
315 | |
316 file = NULL; | |
317 | |
318 rc = ngx_open_and_stat_file(name->data, of, pool->log); | |
319 | |
320 if (rc != NGX_OK && (of->err == 0 || !of->errors)) { | |
321 goto failed; | |
322 } | |
323 | |
324 create: | |
325 | |
326 if (cache->current >= cache->max) { | |
327 ngx_expire_old_cached_files(cache, 0, pool->log); | |
328 } | |
329 | |
330 file = ngx_alloc(sizeof(ngx_cached_open_file_t), pool->log); | |
331 | |
332 if (file == NULL) { | |
333 goto failed; | |
334 } | |
335 | |
336 file->name = ngx_alloc(name->len + 1, pool->log); | |
337 | |
338 if (file->name == NULL) { | |
339 ngx_free(file); | |
340 file = NULL; | |
341 goto failed; | |
342 } | |
343 | |
344 ngx_cpystrn(file->name, name->data, name->len + 1); | |
345 | |
346 file->node.key = hash; | |
347 | |
348 ngx_rbtree_insert(&cache->rbtree, &file->node); | |
349 | |
350 cache->current++; | |
351 | |
352 file->count = 0; | |
353 | |
354 update: | |
355 | |
1458
614090b26fbf
test the most relevant condition first
Igor Sysoev <igor@sysoev.ru>
parents:
1457
diff
changeset
|
356 if (of->events |
614090b26fbf
test the most relevant condition first
Igor Sysoev <igor@sysoev.ru>
parents:
1457
diff
changeset
|
357 && (ngx_event_flags & NGX_USE_VNODE_EVENT) |
1457 | 358 && of->fd != NGX_INVALID_FILE) |
359 { | |
1453 | 360 file->event = ngx_calloc(sizeof(ngx_event_t), pool->log); |
361 if (file->event== NULL) { | |
362 goto failed; | |
363 } | |
364 | |
365 fev = ngx_alloc(sizeof(ngx_open_file_cache_event_t), pool->log); | |
366 if (fev == NULL) { | |
367 goto failed; | |
368 } | |
369 | |
370 fev->fd = of->fd; | |
371 fev->file = file; | |
372 fev->cache = cache; | |
373 | |
374 file->event->handler = ngx_open_file_cache_remove; | |
375 file->event->data = fev; | |
376 | |
377 /* | |
378 * although vnode event may be called while ngx_cycle->poll | |
379 * destruction; however, cleanup procedures are run before any | |
380 * memory freeing and events will be canceled. | |
381 */ | |
382 | |
383 file->event->log = ngx_cycle->log; | |
384 | |
385 if (ngx_add_event(file->event, NGX_VNODE_EVENT, NGX_ONESHOT_EVENT) | |
386 != NGX_OK) | |
387 { | |
388 ngx_free(file->event->data); | |
389 ngx_free(file->event); | |
390 goto failed; | |
391 } | |
392 | |
393 } else { | |
394 file->event = NULL; | |
395 } | |
396 | |
397 file->fd = of->fd; | |
398 file->err = of->err; | |
399 | |
400 if (of->err == 0) { | |
401 file->uniq = of->uniq; | |
402 file->mtime = of->mtime; | |
403 file->size = of->size; | |
404 | |
405 file->close = 0; | |
406 | |
407 file->is_dir = of->is_dir; | |
408 file->is_file = of->is_file; | |
409 file->is_link = of->is_link; | |
410 file->is_exec = of->is_exec; | |
411 | |
412 if (!of->is_dir) { | |
413 file->count++; | |
414 } | |
415 } | |
416 | |
417 renew: | |
418 | |
419 file->created = now; | |
420 | |
421 found: | |
422 | |
423 file->accessed = now; | |
424 | |
425 /* add to the inactive list head */ | |
426 | |
427 file->next = cache->list_head.next; | |
428 file->next->prev = file; | |
429 file->prev = &cache->list_head; | |
430 cache->list_head.next = file; | |
431 | |
432 ngx_log_debug4(NGX_LOG_DEBUG_CORE, pool->log, 0, | |
433 "cached open file: %s, fd:%d, c:%d, e:%d", | |
434 file->name, file->fd, file->count, file->err); | |
435 | |
436 if (of->err == 0) { | |
437 | |
438 if (!of->is_dir) { | |
439 cln->handler = ngx_open_file_cleanup; | |
440 ofcln = cln->data; | |
441 | |
442 ofcln->cache = cache; | |
443 ofcln->file = file; | |
444 ofcln->log = pool->log; | |
445 } | |
446 | |
447 return NGX_OK; | |
448 } | |
449 | |
450 return NGX_ERROR; | |
451 | |
452 failed: | |
453 | |
454 if (file && file->count == 0) { | |
455 ngx_rbtree_delete(&cache->rbtree, &file->node); | |
456 | |
457 cache->current--; | |
458 | |
459 if (ngx_close_file(file->fd) == NGX_FILE_ERROR) { | |
460 ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno, | |
461 ngx_close_file_n " \"%s\" failed", file->name); | |
462 } | |
463 | |
464 ngx_free(file->name); | |
465 ngx_free(file); | |
466 } | |
467 | |
468 if (of->fd != NGX_INVALID_FILE) { | |
469 if (ngx_close_file(of->fd) == NGX_FILE_ERROR) { | |
470 ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno, | |
471 ngx_close_file_n " \"%s\" failed", name->data); | |
472 } | |
473 } | |
474 | |
475 return NGX_ERROR; | |
476 } | |
477 | |
478 | |
479 static ngx_int_t | |
480 ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) | |
481 { | |
482 ngx_fd_t fd; | |
483 ngx_file_info_t fi; | |
484 | |
485 of->fd = NGX_INVALID_FILE; | |
486 | |
487 if (of->test_dir) { | |
488 | |
489 if (ngx_file_info(name, &fi) == -1) { | |
490 of->err = ngx_errno; | |
491 | |
492 return NGX_ERROR; | |
493 } | |
494 | |
495 of->uniq = ngx_file_uniq(&fi); | |
496 of->mtime = ngx_file_mtime(&fi); | |
497 of->size = ngx_file_size(&fi); | |
498 of->is_dir = ngx_is_dir(&fi); | |
499 of->is_file = ngx_is_file(&fi); | |
500 of->is_link = ngx_is_link(&fi); | |
501 of->is_exec = ngx_is_exec(&fi); | |
502 | |
503 if (of->is_dir) { | |
504 return NGX_OK; | |
505 } | |
506 } | |
507 | |
508 fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); | |
509 | |
510 if (fd == NGX_INVALID_FILE) { | |
511 of->err = ngx_errno; | |
512 return NGX_ERROR; | |
513 } | |
514 | |
515 if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) { | |
516 ngx_log_error(NGX_LOG_CRIT, log, ngx_errno, | |
517 ngx_fd_info_n " \"%s\" failed", name); | |
518 | |
519 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
520 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
521 ngx_close_file_n " \"%s\" failed", name); | |
522 } | |
523 | |
524 return NGX_ERROR; | |
525 } | |
526 | |
527 if (ngx_is_dir(&fi)) { | |
528 if (ngx_close_file(fd) == NGX_FILE_ERROR) { | |
529 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
530 ngx_close_file_n " \"%s\" failed", name); | |
531 } | |
532 | |
533 fd = NGX_INVALID_FILE; | |
534 } | |
535 | |
536 of->fd = fd; | |
537 of->uniq = ngx_file_uniq(&fi); | |
538 of->mtime = ngx_file_mtime(&fi); | |
539 of->size = ngx_file_size(&fi); | |
540 of->is_dir = ngx_is_dir(&fi); | |
541 of->is_file = ngx_is_file(&fi); | |
542 of->is_link = ngx_is_link(&fi); | |
543 of->is_exec = ngx_is_exec(&fi); | |
544 | |
545 return NGX_OK; | |
546 } | |
547 | |
548 | |
549 static void | |
550 ngx_open_file_cleanup(void *data) | |
551 { | |
552 ngx_open_file_cache_cleanup_t *c = data; | |
553 | |
554 c->file->count--; | |
555 | |
556 ngx_close_cached_file(c->cache, c->file, c->log); | |
557 | |
558 /* drop one or two expired open files */ | |
559 ngx_expire_old_cached_files(c->cache, 1, c->log); | |
560 } | |
561 | |
562 | |
563 static void | |
564 ngx_close_cached_file(ngx_open_file_cache_t *cache, | |
565 ngx_cached_open_file_t *file, ngx_log_t *log) | |
566 { | |
567 ngx_log_debug4(NGX_LOG_DEBUG_CORE, log, 0, | |
568 "close cached open file: %s, fd:%d, c:%d, %d", | |
569 file->name, file->fd, file->count, file->close); | |
570 | |
571 if (!file->close) { | |
572 | |
573 file->accessed = ngx_time(); | |
574 | |
575 if (cache->list_head.next != file) { | |
576 | |
577 /* delete from inactive list */ | |
578 | |
579 file->next->prev = file->prev; | |
580 file->prev->next = file->next; | |
581 | |
582 /* add to the inactive list head */ | |
583 | |
584 file->next = cache->list_head.next; | |
585 file->next->prev = file; | |
586 file->prev = &cache->list_head; | |
587 cache->list_head.next = file; | |
588 } | |
589 | |
590 return; | |
591 } | |
592 | |
593 if (file->event) { | |
594 (void) ngx_del_event(file->event, NGX_VNODE_EVENT, | |
595 file->count ? NGX_FLUSH_EVENT : NGX_CLOSE_EVENT); | |
596 | |
597 ngx_free(file->event->data); | |
598 ngx_free(file->event); | |
599 file->event = NULL; | |
600 } | |
601 | |
602 if (file->count) { | |
603 return; | |
604 } | |
605 | |
606 if (ngx_close_file(file->fd) == NGX_FILE_ERROR) { | |
607 ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, | |
608 ngx_close_file_n " \"%s\" failed", file->name); | |
609 } | |
610 | |
611 ngx_free(file->name); | |
612 ngx_free(file); | |
613 } | |
614 | |
615 | |
616 static void | |
617 ngx_expire_old_cached_files(ngx_open_file_cache_t *cache, ngx_uint_t n, | |
618 ngx_log_t *log) | |
619 { | |
620 time_t now; | |
621 ngx_cached_open_file_t *file; | |
622 | |
623 now = ngx_time(); | |
624 | |
625 /* | |
626 * n == 1 deletes one or two inactive files | |
627 * n == 0 deletes least recently used file by force | |
628 * and one or two inactive files | |
629 */ | |
630 | |
631 while (n < 3) { | |
632 | |
633 file = cache->list_tail.prev; | |
634 | |
635 if (file == &cache->list_head) { | |
636 return; | |
637 } | |
638 | |
639 if (n++ != 0 && now - file->accessed <= cache->inactive) { | |
640 return; | |
641 } | |
642 | |
643 file->next->prev = file->prev; | |
644 file->prev->next = file->next; | |
645 | |
646 ngx_rbtree_delete(&cache->rbtree, &file->node); | |
647 | |
648 cache->current--; | |
649 | |
650 ngx_log_debug1(NGX_LOG_DEBUG_CORE, log, 0, | |
651 "expire cached open file: %s", file->name); | |
652 | |
653 if (!file->err && !file->is_dir) { | |
654 file->close = 1; | |
655 ngx_close_cached_file(cache, file, log); | |
656 | |
657 } else { | |
658 ngx_free(file->name); | |
659 ngx_free(file); | |
660 } | |
661 } | |
662 } | |
663 | |
664 | |
665 static void | |
666 ngx_open_file_cache_rbtree_insert_value(ngx_rbtree_node_t *temp, | |
667 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) | |
668 { | |
669 ngx_rbtree_node_t **p; | |
670 ngx_cached_open_file_t *file, *file_temp; | |
671 | |
672 for ( ;; ) { | |
673 | |
674 if (node->key < temp->key) { | |
675 | |
676 p = &temp->left; | |
677 | |
678 } else if (node->key > temp->key) { | |
679 | |
680 p = &temp->right; | |
681 | |
682 } else { /* node->key == temp->key */ | |
683 | |
684 file = (ngx_cached_open_file_t *) node; | |
685 file_temp = (ngx_cached_open_file_t *) temp; | |
686 | |
687 p = (ngx_strcmp(file->name, file_temp->name) < 0) | |
688 ? &temp->left : &temp->right; | |
689 } | |
690 | |
691 if (*p == sentinel) { | |
692 break; | |
693 } | |
694 | |
695 temp = *p; | |
696 } | |
697 | |
698 *p = node; | |
699 node->parent = temp; | |
700 node->left = sentinel; | |
701 node->right = sentinel; | |
702 ngx_rbt_red(node); | |
703 } | |
704 | |
705 | |
706 static void | |
707 ngx_open_file_cache_remove(ngx_event_t *ev) | |
708 { | |
709 ngx_cached_open_file_t *file; | |
710 ngx_open_file_cache_event_t *fev; | |
711 | |
712 fev = ev->data; | |
713 file = fev->file; | |
714 | |
715 file->next->prev = file->prev; | |
716 file->prev->next = file->next; | |
717 | |
718 ngx_rbtree_delete(&fev->cache->rbtree, &file->node); | |
719 | |
720 fev->cache->current--; | |
721 | |
722 /* NGX_ONESHOT_EVENT was already deleted */ | |
723 file->event = NULL; | |
724 | |
725 file->close = 1; | |
726 | |
727 ngx_close_cached_file(fev->cache, file, ev->log); | |
728 | |
729 /* free memory only when fev->cache and fev->file are already not needed */ | |
730 | |
731 ngx_free(ev->data); | |
732 ngx_free(ev); | |
733 } |