diff options
author | Max Romanov <max.romanov@nginx.com> | 2017-07-06 18:38:51 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2017-07-06 18:38:51 +0300 |
commit | c56d2af3bcb10ca27b74c2fe123ea98dea07f0a0 (patch) | |
tree | 03e5469e6b32ccf31c52746c40358dd3f83e91d8 /src/nxt_controller.c | |
parent | e1219569f4433f9b45bc9db5c02c5cc5f66b69ab (diff) | |
download | unit-c56d2af3bcb10ca27b74c2fe123ea98dea07f0a0.tar.gz unit-c56d2af3bcb10ca27b74c2fe123ea98dea07f0a0.tar.bz2 |
Router: read configuration from port.
Controller: stub to send configuration from POST body "as is" to router.
Diffstat (limited to '')
-rw-r--r-- | src/nxt_controller.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c index 757c294d..6403c98a 100644 --- a/src/nxt_controller.c +++ b/src/nxt_controller.c @@ -562,6 +562,38 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c, nxt_memzero(&resp, sizeof(nxt_controller_response_t)); + if (nxt_str_eq(&req->parser.method, "POST", 4)) { + nxt_port_t *port; + nxt_runtime_t *rt; + + rt = task->thread->runtime; + + nxt_runtime_port_each(rt, port) { + + if (nxt_pid == port->pid) { + continue; + } + + if (port->type == NXT_PROCESS_ROUTER) { + nxt_buf_t *b, *src; + + src = c->read; + b = nxt_port_mmap_get_buf(task, port, + nxt_buf_mem_used_size(&src->mem)); + + nxt_memcpy(b->mem.pos, src->mem.pos, + nxt_buf_mem_used_size(&src->mem)); + b->mem.free += nxt_buf_mem_used_size(&src->mem); + + (void) nxt_port_socket_write(task, port, NXT_PORT_MSG_DATA, + -1, 0, 0, b); + + break; + } + + } nxt_runtime_port_loop; + } + if (nxt_str_eq(&req->parser.method, "GET", 3)) { value = nxt_conf_get_path(nxt_controller_conf.root, &path); |