nxt_stream_module.c (13:3a52b2c3d3f1) nxt_stream_module.c (20:4dc92b438f58)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_main.h>
8#include <nxt_cycle.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{
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_cycle_t *cycle;
20 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)) {
30 goto fail;
31 }
32
33 up->data = c;
34
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)) {
30 goto fail;
31 }
32
33 up->data = c;
34
35 cycle = nxt_thread_cycle();
35 rt = task->thread->runtime;
36
36
37 if (cycle->upstream.length != 0) {
38 up->addr = cycle->upstream;
37 if (rt->upstream.length != 0) {
38 up->addr = rt->upstream;
39
40 } else {
41 nxt_str_set(&up->addr, "127.0.0.1:8080");
42 }
43
44 up->ready_handler = nxt_stream_connection_peer;
45 up->mem_pool = c->mem_pool;
46

--- 84 unchanged lines hidden ---
39
40 } else {
41 nxt_str_set(&up->addr, "127.0.0.1:8080");
42 }
43
44 up->ready_handler = nxt_stream_connection_peer;
45 up->mem_pool = c->mem_pool;
46

--- 84 unchanged lines hidden ---