nxt_stream_module.c (20:4dc92b438f58) nxt_stream_module.c (62:5e1efcc7b740)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>
9
10
11static void nxt_stream_connection_peer(nxt_task_t *task,
12 nxt_upstream_peer_t *up);
13static void nxt_stream_connection_close(nxt_task_t *task, void *obj,
14 void *data);
15
16
17void
18nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data)
19{
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_runtime.h>
9
10
11static void nxt_stream_connection_peer(nxt_task_t *task,
12 nxt_upstream_peer_t *up);
13static void nxt_stream_connection_close(nxt_task_t *task, void *obj,
14 void *data);
15
16
17void
18nxt_stream_connection_init(nxt_task_t *task, void *obj, void *data)
19{
20 nxt_conn_t *c;
20 nxt_runtime_t *rt;
21 nxt_runtime_t *rt;
21 nxt_event_conn_t *c;
22 nxt_upstream_peer_t *up;
23
24 c = obj;
25
26 nxt_debug(task, "stream connection init");
27
28 up = nxt_mem_zalloc(c->mem_pool, sizeof(nxt_upstream_peer_t));
29 if (nxt_slow_path(up == NULL)) {

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

52 /* TODO: close connection */
53 return;
54}
55
56
57static void
58nxt_stream_connection_peer(nxt_task_t *task, nxt_upstream_peer_t *up)
59{
22 nxt_upstream_peer_t *up;
23
24 c = obj;
25
26 nxt_debug(task, "stream connection init");
27
28 up = nxt_mem_zalloc(c->mem_pool, sizeof(nxt_upstream_peer_t));
29 if (nxt_slow_path(up == NULL)) {

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

52 /* TODO: close connection */
53 return;
54}
55
56
57static void
58nxt_stream_connection_peer(nxt_task_t *task, nxt_upstream_peer_t *up)
59{
60 nxt_event_conn_t *c;
61 nxt_event_conn_proxy_t *p;
60 nxt_conn_t *c;
61 nxt_conn_proxy_t *p;
62
63 c = up->data;
64
65 up->sockaddr->type = SOCK_STREAM;
66
67 nxt_log_debug(c->socket.log, "stream connection peer %*s",
68 up->sockaddr->length, nxt_sockaddr_start(up->sockaddr));
69
62
63 c = up->data;
64
65 up->sockaddr->type = SOCK_STREAM;
66
67 nxt_log_debug(c->socket.log, "stream connection peer %*s",
68 up->sockaddr->length, nxt_sockaddr_start(up->sockaddr));
69
70 p = nxt_event_conn_proxy_create(c);
70 p = nxt_conn_proxy_create(c);
71 if (nxt_slow_path(p == NULL)) {
72 goto fail;
73 }
74
75 p->client->socket.data = p;
76 p->peer->socket.data = p;
77
78 p->client_buffer_size = 1024;

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

102 rate->limit = 1024;
103 rate->limit_after = 0;
104 rate->average = rate->limit;
105
106 engine = nxt_thread_event_engine();
107 rate->last = engine->timers.now;
108 }
109
71 if (nxt_slow_path(p == NULL)) {
72 goto fail;
73 }
74
75 p->client->socket.data = p;
76 p->peer->socket.data = p;
77
78 p->client_buffer_size = 1024;

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

102 rate->limit = 1024;
103 rate->limit_after = 0;
104 rate->average = rate->limit;
105
106 engine = nxt_thread_event_engine();
107 rate->last = engine->timers.now;
108 }
109
110 nxt_event_conn_proxy(task, p);
110 nxt_conn_proxy(task, p);
111 return;
112
113fail:
114
115 /* TODO: close connection */
116 return;
117}
118

--- 12 unchanged lines hidden ---
111 return;
112
113fail:
114
115 /* TODO: close connection */
116 return;
117}
118

--- 12 unchanged lines hidden ---