nxt_conn_accept.c (312:c156aea91063) nxt_conn_accept.c (337:854a1a440616)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

41 lev = nxt_zalloc(sizeof(nxt_listen_event_t));
42
43 if (nxt_fast_path(lev != NULL)) {
44 lev->socket.fd = ls->socket;
45
46 engine = task->thread->engine;
47 lev->batch = engine->batch;
48
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8

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

41 lev = nxt_zalloc(sizeof(nxt_listen_event_t));
42
43 if (nxt_fast_path(lev != NULL)) {
44 lev->socket.fd = ls->socket;
45
46 engine = task->thread->engine;
47 lev->batch = engine->batch;
48
49 lev->mem_cache = (uint32_t) -1;
50
49 lev->socket.read_work_queue = &engine->accept_work_queue;
50 lev->socket.read_handler = nxt_conn_listen_handler;
51 lev->socket.error_handler = nxt_conn_listen_event_error;
52 lev->socket.log = &nxt_main_log;
53
54 lev->accept = engine->event.io->accept;
55
56 lev->listen = ls;

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

79}
80
81
82static nxt_conn_t *
83nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
84{
85 nxt_mp_t *mp;
86 nxt_conn_t *c;
51 lev->socket.read_work_queue = &engine->accept_work_queue;
52 lev->socket.read_handler = nxt_conn_listen_handler;
53 lev->socket.error_handler = nxt_conn_listen_event_error;
54 lev->socket.log = &nxt_main_log;
55
56 lev->accept = engine->event.io->accept;
57
58 lev->listen = ls;

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

81}
82
83
84static nxt_conn_t *
85nxt_conn_accept_alloc(nxt_task_t *task, nxt_listen_event_t *lev)
86{
87 nxt_mp_t *mp;
88 nxt_conn_t *c;
87 nxt_sockaddr_t *sa, *remote;
88 nxt_event_engine_t *engine;
89 nxt_listen_socket_t *ls;
90
91 engine = task->thread->engine;
92
93 if (engine->connections < engine->max_connections) {
94
95 mp = nxt_mp_create(1024, 128, 256, 32);

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

102
103 lev->next = c;
104 c->socket.read_work_queue = lev->socket.read_work_queue;
105 c->socket.write_ready = 1;
106 c->listen = lev;
107
108 ls = lev->listen;
109
89 nxt_event_engine_t *engine;
90 nxt_listen_socket_t *ls;
91
92 engine = task->thread->engine;
93
94 if (engine->connections < engine->max_connections) {
95
96 mp = nxt_mp_create(1024, 128, 256, 32);

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

103
104 lev->next = c;
105 c->socket.read_work_queue = lev->socket.read_work_queue;
106 c->socket.write_ready = 1;
107 c->listen = lev;
108
109 ls = lev->listen;
110
110 remote = nxt_sockaddr_alloc(mp, ls->socklen, ls->address_length);
111 if (nxt_slow_path(remote == NULL)) {
112 goto fail;
111 c->remote = nxt_sockaddr_cache_alloc(engine, lev);
112 if (nxt_fast_path(c->remote != NULL)) {
113 return c;
113 }
114 }
114
115 c->remote = remote;
116
117 sa = ls->sockaddr;
118 remote->type = sa->type;
119 /*
120 * Set address family for unspecified Unix domain socket,
121 * because these sockaddr's are not updated by old BSD systems,
122 * see comment in nxt_conn_io_accept().
123 */
124 remote->u.sockaddr.sa_family = sa->u.sockaddr.sa_family;
125
126 return c;
127 }
128
129 fail:
130
131 nxt_mp_destroy(mp);
132 }
133
134 return NULL;

--- 244 unchanged lines hidden ---
115 }
116
117 fail:
118
119 nxt_mp_destroy(mp);
120 }
121
122 return NULL;

--- 244 unchanged lines hidden ---