xref: /unit/src/nxt_job_file_cache.c (revision 0:a63ceefd6ab0)
1 
2 /*
3  * Copyright (C) Igor Sysoev
4  * Copyright (C) NGINX, Inc.
5  */
6 
7 
8 #include <nxt_main.h>
9 
10 
11 typedef struct {
12     nxt_cache_node_t   node;
13     nxt_file_t         file;
14 } nxt_file_cache_t;
15 
16 
17 void
18 nxt_job_file_cache_read(nxt_cache_t *cache, nxt_job_file_t *jbf)
19 {
20     nxt_file_cache_node_t  *node;
21 
22     node = nxt_cache_find(cache);
23 
24     if (node != NULL) {
25 
26         if (node->fd != -1) {
27             nxt_job_return(&jbf->job, jbf->ready_handler);
28             return;
29         }
30 
31         if (node->error != 0) {
32             nxt_job_return(&jbf->job, jbf->error_handler);
33             return;
34         }
35 
36 #if (NXT_THREADS)
37 
38         if (node->accessed + 60 > nxt_thread_time()) {
39             jbf->job.thread_pool = NULL;
40         }
41 
42 #endif
43 
44     }
45 
46     nxt_job_file_read(jbf);
47 }
48