xref: /unit/src/nxt_job_file_cache.c (revision 223:bf98efe2c55c)
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
nxt_job_file_cache_read(nxt_cache_t * cache,nxt_job_file_t * jbf)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 (node->accessed + 60 > nxt_thread_time()) {
37             jbf->job.thread_pool = NULL;
38         }
39     }
40 
41     nxt_job_file_read(jbf);
42 }
43