nxt_event_conn_job_sendfile.c (56:92b4984ca3c1) nxt_event_conn_job_sendfile.c (62:5e1efcc7b740)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

20
21static void nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj,
22 void *data);
23static void nxt_event_conn_job_sendfile_handler(nxt_task_t *task, void *obj,
24 void *data);
25static void nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj,
26 void *data);
27static nxt_buf_t *nxt_event_conn_job_sendfile_completion(nxt_task_t *task,
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

20
21static void nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj,
22 void *data);
23static void nxt_event_conn_job_sendfile_handler(nxt_task_t *task, void *obj,
24 void *data);
25static void nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj,
26 void *data);
27static nxt_buf_t *nxt_event_conn_job_sendfile_completion(nxt_task_t *task,
28 nxt_event_conn_t *c, nxt_buf_t *b);
28 nxt_conn_t *c, nxt_buf_t *b);
29
30
31void
29
30
31void
32nxt_event_conn_job_sendfile(nxt_task_t *task, nxt_event_conn_t *c)
32nxt_event_conn_job_sendfile(nxt_task_t *task, nxt_conn_t *c)
33{
34 nxt_fd_event_disable(task->thread->engine, &c->socket);
35
36 /* A work item data is not used in nxt_event_conn_job_sendfile_start(). */
37 nxt_event_conn_job_sendfile_start(task, c, NULL);
38}
39
40
41static void
42nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj, void *data)
43{
33{
34 nxt_fd_event_disable(task->thread->engine, &c->socket);
35
36 /* A work item data is not used in nxt_event_conn_job_sendfile_start(). */
37 nxt_event_conn_job_sendfile_start(task, c, NULL);
38}
39
40
41static void
42nxt_event_conn_job_sendfile_start(nxt_task_t *task, void *obj, void *data)
43{
44 nxt_conn_t *c;
44 nxt_iobuf_t b;
45 nxt_iobuf_t b;
45 nxt_event_conn_t *c;
46 nxt_job_sendfile_t *jbs;
47 nxt_sendbuf_coalesce_t sb;
48
49 c = obj;
50
51 nxt_debug(task, "event conn sendfile fd:%d", c->socket.fd);
52
53 jbs = nxt_job_create(c->mem_pool, sizeof(nxt_job_sendfile_t));

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

94
95
96static void
97nxt_event_conn_job_sendfile_handler(nxt_task_t *task, void *obj, void *data)
98{
99 ssize_t ret;
100 nxt_buf_t *b;
101 nxt_bool_t first;
46 nxt_job_sendfile_t *jbs;
47 nxt_sendbuf_coalesce_t sb;
48
49 c = obj;
50
51 nxt_debug(task, "event conn sendfile fd:%d", c->socket.fd);
52
53 jbs = nxt_job_create(c->mem_pool, sizeof(nxt_job_sendfile_t));

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

94
95
96static void
97nxt_event_conn_job_sendfile_handler(nxt_task_t *task, void *obj, void *data)
98{
99 ssize_t ret;
100 nxt_buf_t *b;
101 nxt_bool_t first;
102 nxt_event_conn_t *c;
102 nxt_conn_t *c;
103 nxt_job_sendfile_t *jbs;
104
105 jbs = obj;
106 c = data;
107
108 nxt_debug(task, "event conn job sendfile fd:%d", c->socket.fd);
109
110 first = c->socket.write_ready;

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

161
162
163static void
164nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj, void *data)
165{
166 size_t sent;
167 nxt_buf_t *b;
168 nxt_bool_t done;
103 nxt_job_sendfile_t *jbs;
104
105 jbs = obj;
106 c = data;
107
108 nxt_debug(task, "event conn job sendfile fd:%d", c->socket.fd);
109
110 first = c->socket.write_ready;

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

161
162
163static void
164nxt_event_conn_job_sendfile_return(nxt_task_t *task, void *obj, void *data)
165{
166 size_t sent;
167 nxt_buf_t *b;
168 nxt_bool_t done;
169 nxt_event_conn_t *c;
169 nxt_conn_t *c;
170 nxt_job_sendfile_t *jbs;
171
172 jbs = obj;
173 c = data;
174
175 c->blocked = 0;
176
177 sent = jbs->sent;

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

207
208 if (sent != 0 && c->write_state->timer_autoreset) {
209 nxt_timer_disable(task->thread->engine, &c->write_timer);
210 }
211
212 if (c->socket.error == 0
213 && !nxt_event_conn_write_delayed(task->thread->engine, c, sent))
214 {
170 nxt_job_sendfile_t *jbs;
171
172 jbs = obj;
173 c = data;
174
175 c->blocked = 0;
176
177 sent = jbs->sent;

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

207
208 if (sent != 0 && c->write_state->timer_autoreset) {
209 nxt_timer_disable(task->thread->engine, &c->write_timer);
210 }
211
212 if (c->socket.error == 0
213 && !nxt_event_conn_write_delayed(task->thread->engine, c, sent))
214 {
215 nxt_event_conn_timer(task->thread->engine, c, c->write_state,
216 &c->write_timer);
215 nxt_conn_timer(task->thread->engine, c, c->write_state,
216 &c->write_timer);
217
218 nxt_fd_event_oneshot_write(task->thread->engine, &c->socket);
219 }
220
221 if (sent != 0) {
222 nxt_work_queue_add(c->write_work_queue, c->write_state->ready_handler,
223 task, c, c->socket.data);
224 /*

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

230 if (nxt_slow_path(c->socket.error != 0)) {
231 nxt_work_queue_add(c->write_work_queue, c->write_state->error_handler,
232 task, c, c->socket.data);
233 }
234}
235
236
237static nxt_buf_t *
217
218 nxt_fd_event_oneshot_write(task->thread->engine, &c->socket);
219 }
220
221 if (sent != 0) {
222 nxt_work_queue_add(c->write_work_queue, c->write_state->ready_handler,
223 task, c, c->socket.data);
224 /*

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

230 if (nxt_slow_path(c->socket.error != 0)) {
231 nxt_work_queue_add(c->write_work_queue, c->write_state->error_handler,
232 task, c, c->socket.data);
233 }
234}
235
236
237static nxt_buf_t *
238nxt_event_conn_job_sendfile_completion(nxt_task_t *task, nxt_event_conn_t *c,
238nxt_event_conn_job_sendfile_completion(nxt_task_t *task, nxt_conn_t *c,
239 nxt_buf_t *b)
240{
241 while (b != NULL) {
242
243 nxt_prefetch(b->next);
244
245 if (nxt_buf_is_mem(b) && b->mem.pos != b->mem.free) {
246 break;

--- 15 unchanged lines hidden ---
239 nxt_buf_t *b)
240{
241 while (b != NULL) {
242
243 nxt_prefetch(b->next);
244
245 if (nxt_buf_is_mem(b) && b->mem.pos != b->mem.free) {
246 break;

--- 15 unchanged lines hidden ---