nxt_job_file.c (0:a63ceefd6ab0) nxt_job_file.c (1:fdc027c56872)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7
8#include <nxt_main.h>
9
10
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7
8#include <nxt_main.h>
9
10
11static void nxt_job_file_open_and_read(nxt_thread_t *thr, void *obj,
12 void *data);
11static void nxt_job_file_open_and_read(nxt_task_t *task, void *obj, void *data);
13static nxt_int_t nxt_job_file_open(nxt_job_file_t *jbf);
14static nxt_int_t nxt_job_file_info(nxt_job_file_t *jbf);
15static nxt_int_t nxt_job_file_mmap(nxt_job_file_t *jbf, size_t size);
16static nxt_int_t nxt_job_file_read_data(nxt_job_file_t *jbf, size_t size);
17static nxt_int_t nxt_job_file_read_required(nxt_job_file_t *jbf);
18
19
20nxt_job_file_t *

--- 25 unchanged lines hidden (view full) ---

46
47
48/*
49 * Must be a function but not a macro, because
50 * it can be used as function pointer.
51 */
52
53void
12static nxt_int_t nxt_job_file_open(nxt_job_file_t *jbf);
13static nxt_int_t nxt_job_file_info(nxt_job_file_t *jbf);
14static nxt_int_t nxt_job_file_mmap(nxt_job_file_t *jbf, size_t size);
15static nxt_int_t nxt_job_file_read_data(nxt_job_file_t *jbf, size_t size);
16static nxt_int_t nxt_job_file_read_required(nxt_job_file_t *jbf);
17
18
19nxt_job_file_t *

--- 25 unchanged lines hidden (view full) ---

45
46
47/*
48 * Must be a function but not a macro, because
49 * it can be used as function pointer.
50 */
51
52void
54nxt_job_file_read(nxt_thread_t *thr, nxt_job_t *job)
53nxt_job_file_read(nxt_task_t *task, nxt_job_t *job)
55{
54{
56 nxt_job_start(thr, job, nxt_job_file_open_and_read);
55 nxt_job_start(task, job, nxt_job_file_open_and_read);
57}
58
59
60static void
56}
57
58
59static void
61nxt_job_file_open_and_read(nxt_thread_t *thr, void *obj, void *data)
60nxt_job_file_open_and_read(nxt_task_t *task, void *obj, void *data)
62{
63 size_t size;
64 nxt_int_t n;
65 nxt_bool_t read_ahead;
66 nxt_file_t *file;
67 nxt_job_file_t *jbf;
68 nxt_work_handler_t handler;
69
70 jbf = obj;
71 file = &jbf->file;
72
61{
62 size_t size;
63 nxt_int_t n;
64 nxt_bool_t read_ahead;
65 nxt_file_t *file;
66 nxt_job_file_t *jbf;
67 nxt_work_handler_t handler;
68
69 jbf = obj;
70 file = &jbf->file;
71
73 nxt_log_debug(thr->log, "file job read: \"%FN\"", file->name);
72 nxt_debug(task, "file job read: \"%FN\"", file->name);
74
75 if (file->fd != NXT_FILE_INVALID && jbf->close_before_open) {
76 nxt_file_close(file);
77 file->fd = NXT_FILE_INVALID;
78 }
79
80 if (file->fd == NXT_FILE_INVALID) {
81

--- 48 unchanged lines hidden (view full) ---

130 jbf->complete = 1;
131
132 if (jbf->close) {
133 nxt_file_close(file);
134 file->fd = NXT_FILE_INVALID;
135 }
136 }
137
73
74 if (file->fd != NXT_FILE_INVALID && jbf->close_before_open) {
75 nxt_file_close(file);
76 file->fd = NXT_FILE_INVALID;
77 }
78
79 if (file->fd == NXT_FILE_INVALID) {
80

--- 48 unchanged lines hidden (view full) ---

129 jbf->complete = 1;
130
131 if (jbf->close) {
132 nxt_file_close(file);
133 file->fd = NXT_FILE_INVALID;
134 }
135 }
136
138 nxt_job_return(thr, &jbf->job, jbf->ready_handler);
137 nxt_job_return(task, &jbf->job, jbf->ready_handler);
139 return;
140
141done:
142
143 if (file->fd != NXT_FILE_INVALID) {
144 nxt_file_close(file);
145 file->fd = NXT_FILE_INVALID;
146 }
147
138 return;
139
140done:
141
142 if (file->fd != NXT_FILE_INVALID) {
143 nxt_file_close(file);
144 file->fd = NXT_FILE_INVALID;
145 }
146
148 nxt_job_return(thr, &jbf->job, handler);
147 nxt_job_return(task, &jbf->job, handler);
149}
150
151
152static nxt_int_t
153nxt_job_file_open(nxt_job_file_t *jbf)
154{
155 nxt_int_t n;
156

--- 147 unchanged lines hidden ---
148}
149
150
151static nxt_int_t
152nxt_job_file_open(nxt_job_file_t *jbf)
153{
154 nxt_int_t n;
155

--- 147 unchanged lines hidden ---