Mercurial > hg > nginx
comparison src/core/ngx_open_file_cache.c @ 2070:92402cc8b3cf
fix the previous commit
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 30 Jun 2008 12:11:47 +0000 |
parents | 23930ccd2642 |
children | 2d216377146a |
comparison
equal
deleted
inserted
replaced
2069:23930ccd2642 | 2070:92402cc8b3cf |
---|---|
187 } | 187 } |
188 | 188 |
189 goto add_event; | 189 goto add_event; |
190 } | 190 } |
191 | 191 |
192 if ((file->event && file->use_event) | 192 if (file->use_event |
193 || (file->event == NULL | 193 || (file->event == NULL |
194 && (of->uniq == 0 || of->uniq == file->uniq) | 194 && (of->uniq == 0 || of->uniq == file->uniq) |
195 && now - file->created < of->valid)) | 195 && now - file->created < of->valid)) |
196 { | 196 { |
197 if (file->err == 0) { | 197 if (file->err == 0) { |
254 | 254 |
255 if (file->is_dir || file->err) { | 255 if (file->is_dir || file->err) { |
256 goto add_event; | 256 goto add_event; |
257 } | 257 } |
258 | 258 |
259 if (of->uniq == file->uniq | 259 if (of->uniq == file->uniq) { |
260 && of->mtime == file->mtime | |
261 && of->size == file->size) | |
262 { | |
263 if (of->fd != file->fd) { | |
264 if (ngx_close_file(of->fd) == NGX_FILE_ERROR) { | |
265 ngx_log_error(NGX_LOG_ALERT, pool->log, ngx_errno, | |
266 ngx_close_file_n " \"%s\" failed", | |
267 name->data); | |
268 } | |
269 | |
270 of->fd = file->fd; | |
271 } | |
272 | 260 |
273 file->count++; | 261 file->count++; |
274 | 262 |
275 if (file->event) { | 263 if (file->event) { |
276 file->use_event = 1; | 264 file->use_event = 1; |
277 goto renew; | |
278 } | 265 } |
279 | |
280 ngx_open_file_add_event(cache, file, of, pool->log); | |
281 | 266 |
282 goto renew; | 267 goto renew; |
283 } | 268 } |
284 | 269 |
285 /* file was changed */ | 270 /* file was changed */ |
351 | 336 |
352 cache->current++; | 337 cache->current++; |
353 | 338 |
354 file->uses = 1; | 339 file->uses = 1; |
355 file->count = 0; | 340 file->count = 0; |
356 file->use_event = 0; | |
357 file->event = NULL; | 341 file->event = NULL; |
358 | 342 |
359 add_event: | 343 add_event: |
360 | 344 |
361 ngx_open_file_add_event(cache, file, of, pool->log); | 345 ngx_open_file_add_event(cache, file, of, pool->log); |
453 ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) | 437 ngx_open_and_stat_file(u_char *name, ngx_open_file_info_t *of, ngx_log_t *log) |
454 { | 438 { |
455 ngx_fd_t fd; | 439 ngx_fd_t fd; |
456 ngx_file_info_t fi; | 440 ngx_file_info_t fi; |
457 | 441 |
458 if (of->fd != NGX_INVALID_FILE || of->test_dir) { | 442 if (of->fd != NGX_INVALID_FILE) { |
459 | 443 |
460 if (ngx_file_info(name, &fi) == -1) { | 444 if (ngx_file_info(name, &fi) == -1) { |
461 goto failed; | 445 goto failed; |
462 } | 446 } |
463 | 447 |
464 if (of->fd != NGX_INVALID_FILE && of->uniq == ngx_file_uniq(&fi)) { | 448 if (of->uniq == ngx_file_uniq(&fi)) { |
465 goto done; | 449 goto done; |
466 } | 450 } |
467 | 451 |
468 if (of->test_dir && of->is_dir) { | 452 } else if (of->test_dir) { |
453 | |
454 if (ngx_file_info(name, &fi) == -1) { | |
455 goto failed; | |
456 } | |
457 | |
458 if (of->is_dir) { | |
469 goto done; | 459 goto done; |
470 } | 460 } |
471 } | 461 } |
472 | 462 |
473 fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); | 463 fd = ngx_open_file(name, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0); |
541 || file->uses < of->min_uses) | 531 || file->uses < of->min_uses) |
542 { | 532 { |
543 return; | 533 return; |
544 } | 534 } |
545 | 535 |
536 file->use_event = 0; | |
537 | |
546 file->event = ngx_calloc(sizeof(ngx_event_t), log); | 538 file->event = ngx_calloc(sizeof(ngx_event_t), log); |
547 if (file->event== NULL) { | 539 if (file->event== NULL) { |
548 return; | 540 return; |
549 } | 541 } |
550 | 542 |
818 | 810 |
819 fev->cache->current--; | 811 fev->cache->current--; |
820 | 812 |
821 /* NGX_ONESHOT_EVENT was already deleted */ | 813 /* NGX_ONESHOT_EVENT was already deleted */ |
822 file->event = NULL; | 814 file->event = NULL; |
815 file->use_event = 0; | |
823 | 816 |
824 file->close = 1; | 817 file->close = 1; |
825 | 818 |
826 ngx_close_cached_file(fev->cache, file, 0, ev->log); | 819 ngx_close_cached_file(fev->cache, file, 0, ev->log); |
827 | 820 |