summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_job_file_cache.c
blob: 680d06656cf1ea2fd4a66adcc5c14fd61acaf3b7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

/*
 * Copyright (C) Igor Sysoev
 * Copyright (C) NGINX, Inc.
 */


#include <nxt_main.h>


typedef struct {
    nxt_cache_node_t   node;
    nxt_file_t         file;
} nxt_file_cache_t;


void
nxt_job_file_cache_read(nxt_cache_t *cache, nxt_job_file_t *jbf)
{
    nxt_file_cache_node_t  *node;

    node = nxt_cache_find(cache);

    if (node != NULL) {

        if (node->fd != -1) {
            nxt_job_return(&jbf->job, jbf->ready_handler);
            return;
        }

        if (node->error != 0) {
            nxt_job_return(&jbf->job, jbf->error_handler);
            return;
        }

        if (node->accessed + 60 > nxt_thread_time()) {
            jbf->job.thread_pool = NULL;
        }
    }

    nxt_job_file_read(jbf);
}