Style fixes.
This commit is contained in:
@@ -52,6 +52,7 @@ nxt_go_new_port_mmap(nxt_go_process_t *process, nxt_port_id_t id)
|
|||||||
name_len = snprintf(name, sizeof(name) - 1, "/unit.go.%p", name);
|
name_len = snprintf(name, sizeof(name) - 1, "/unit.go.%p", name);
|
||||||
|
|
||||||
#if (NXT_HAVE_MEMFD_CREATE)
|
#if (NXT_HAVE_MEMFD_CREATE)
|
||||||
|
|
||||||
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
|
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
|
||||||
|
|
||||||
if (nxt_slow_path(fd == -1)) {
|
if (nxt_slow_path(fd == -1)) {
|
||||||
@@ -63,7 +64,9 @@ nxt_go_new_port_mmap(nxt_go_process_t *process, nxt_port_id_t id)
|
|||||||
nxt_go_debug("memfd_create(%s): %d", name, fd);
|
nxt_go_debug("memfd_create(%s): %d", name, fd);
|
||||||
|
|
||||||
#elif (NXT_HAVE_SHM_OPEN)
|
#elif (NXT_HAVE_SHM_OPEN)
|
||||||
shm_unlink((char *) name); // just in case
|
|
||||||
|
/* Just in case. */
|
||||||
|
shm_unlink((char *) name);
|
||||||
|
|
||||||
fd = shm_open((char *) name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
fd = shm_open((char *) name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
@@ -78,6 +81,7 @@ nxt_go_new_port_mmap(nxt_go_process_t *process, nxt_port_id_t id)
|
|||||||
if (nxt_slow_path(shm_unlink((char *) name) == -1)) {
|
if (nxt_slow_path(shm_unlink((char *) name) == -1)) {
|
||||||
nxt_go_warn("shm_unlink(%s) failed %d", name, errno);
|
nxt_go_warn("shm_unlink(%s) failed %d", name, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nxt_slow_path(ftruncate(fd, PORT_MMAP_SIZE) == -1)) {
|
if (nxt_slow_path(ftruncate(fd, PORT_MMAP_SIZE) == -1)) {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
|
|||||||
|
|
||||||
if (pid < process->pid) {
|
if (pid < process->pid) {
|
||||||
r = i;
|
r = i;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
l = i + 1;
|
l = i + 1;
|
||||||
}
|
}
|
||||||
@@ -78,8 +79,8 @@ nxt_go_get_process(nxt_pid_t pid)
|
|||||||
nxt_go_array_add(&processes);
|
nxt_go_array_add(&processes);
|
||||||
process = nxt_go_array_at(&processes, pos);
|
process = nxt_go_array_at(&processes, pos);
|
||||||
|
|
||||||
nxt_go_debug("init process #%d (%p) at %d", (int)pid, process,
|
nxt_go_debug("init process #%d (%p) at %d",
|
||||||
(int)pos);
|
(int) pid, process, (int) pos);
|
||||||
|
|
||||||
if (pos < processes.nelts - 1) {
|
if (pos < processes.nelts - 1) {
|
||||||
memmove(process + 1, process,
|
memmove(process + 1, process,
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ nxt_go_ctx_init_msg(nxt_go_msg_t *msg, nxt_port_msg_t *port_msg,
|
|||||||
msg->data_size += mmap_msg->size;
|
msg->data_size += mmap_msg->size;
|
||||||
mmap_msg += 1;
|
mmap_msg += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
msg->mmap_msg = NULL;
|
msg->mmap_msg = NULL;
|
||||||
msg->end = NULL;
|
msg->end = NULL;
|
||||||
@@ -187,6 +188,7 @@ nxt_go_ctx_add_msg(nxt_go_run_ctx_t *ctx, nxt_port_msg_t *port_msg, size_t size)
|
|||||||
|
|
||||||
if (ctx->msg_last == &ctx->msg) {
|
if (ctx->msg_last == &ctx->msg) {
|
||||||
msg->start_offset += ctx->r.body.preread_size;
|
msg->start_offset += ctx->r.body.preread_size;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
msg->start_offset += ctx->msg_last->data_size;
|
msg->start_offset += ctx->msg_last->data_size;
|
||||||
}
|
}
|
||||||
@@ -241,8 +243,7 @@ nxt_go_port_mmap_get_buf(nxt_go_run_ctx_t *ctx, size_t size)
|
|||||||
|
|
||||||
buf = &ctx->wbuf;
|
buf = &ctx->wbuf;
|
||||||
|
|
||||||
hdr = nxt_go_port_mmap_get(ctx->process,
|
hdr = nxt_go_port_mmap_get(ctx->process, ctx->msg.port_msg->reply_port, &c);
|
||||||
ctx->msg.port_msg->reply_port, &c);
|
|
||||||
if (nxt_slow_path(hdr == NULL)) {
|
if (nxt_slow_path(hdr == NULL)) {
|
||||||
nxt_go_warn("failed to get port_mmap");
|
nxt_go_warn("failed to get port_mmap");
|
||||||
|
|
||||||
@@ -324,9 +325,9 @@ nxt_go_port_mmap_increase_buf(nxt_buf_t *b, size_t size, size_t min_size)
|
|||||||
nchunks--;
|
nchunks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nchunks != 0 &&
|
if (nchunks != 0
|
||||||
min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start)) {
|
&& min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start))
|
||||||
|
{
|
||||||
c--;
|
c--;
|
||||||
while (c >= start) {
|
while (c >= start) {
|
||||||
nxt_port_mmap_set_chunk_free(hdr, c);
|
nxt_port_mmap_set_chunk_free(hdr, c);
|
||||||
@@ -334,6 +335,7 @@ nxt_go_port_mmap_increase_buf(nxt_buf_t *b, size_t size, size_t min_size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
b->mem.end += PORT_MMAP_CHUNK_SIZE * (c - start);
|
b->mem.end += PORT_MMAP_CHUNK_SIZE * (c - start);
|
||||||
|
|
||||||
@@ -378,6 +380,7 @@ nxt_go_ctx_write(nxt_go_run_ctx_t *ctx, void *data, size_t len)
|
|||||||
return NXT_OK;
|
return NXT_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} while (nxt_go_port_mmap_increase_buf(buf, len, 1) == NXT_OK);
|
} while (nxt_go_port_mmap_increase_buf(buf, len, 1) == NXT_OK);
|
||||||
|
|
||||||
if (ctx->nwbuf >= 8) {
|
if (ctx->nwbuf >= 8) {
|
||||||
@@ -476,8 +479,9 @@ nxt_go_ctx_read_str(nxt_go_run_ctx_t *ctx, nxt_str_t *str)
|
|||||||
|
|
||||||
buf->mem.pos += length;
|
buf->mem.pos += length;
|
||||||
|
|
||||||
nxt_go_debug("read_str: %d %.*s", (int)length - 1, (int)length - 1,
|
nxt_go_debug("read_str: %d %.*s",
|
||||||
str->start);
|
(int) length - 1, (int) length - 1, str->start);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
str->start = NULL;
|
str->start = NULL;
|
||||||
str->length = 0;
|
str->length = 0;
|
||||||
|
|||||||
@@ -124,7 +124,9 @@ func nxt_go_new_port(pid C.int, id C.int, t C.int, rcv C.int, snd C.int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_port_send
|
//export nxt_go_port_send
|
||||||
func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer, oob_size C.int) C.int {
|
func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int,
|
||||||
|
oob unsafe.Pointer, oob_size C.int) C.int {
|
||||||
|
|
||||||
key := port_key{
|
key := port_key{
|
||||||
pid: int(pid),
|
pid: int(pid),
|
||||||
id: int(id),
|
id: int(id),
|
||||||
@@ -133,7 +135,8 @@ func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int, o
|
|||||||
p := find_port(key)
|
p := find_port(key)
|
||||||
|
|
||||||
if p != nil {
|
if p != nil {
|
||||||
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size), C.GoBytes(oob, oob_size), nil)
|
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
|
||||||
|
C.GoBytes(oob, oob_size), nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
|
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
|
||||||
@@ -146,11 +149,14 @@ func nxt_go_port_send(pid C.int, id C.int, buf unsafe.Pointer, buf_size C.int, o
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_main_send
|
//export nxt_go_main_send
|
||||||
func nxt_go_main_send(buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer, oob_size C.int) C.int {
|
func nxt_go_main_send(buf unsafe.Pointer, buf_size C.int, oob unsafe.Pointer,
|
||||||
|
oob_size C.int) C.int {
|
||||||
|
|
||||||
p := main_port()
|
p := main_port()
|
||||||
|
|
||||||
if p != nil {
|
if p != nil {
|
||||||
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size), C.GoBytes(oob, oob_size), nil)
|
n, oobn, err := p.snd.WriteMsgUnix(C.GoBytes(buf, buf_size),
|
||||||
|
C.GoBytes(oob, oob_size), nil)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
|
fmt.Printf("write result %d (%d), %s\n", n, oobn, err)
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ func (r *request) Read(p []byte) (n int, err error) {
|
|||||||
if res == -2 /* NXT_AGAIN */ {
|
if res == -2 /* NXT_AGAIN */ {
|
||||||
m := <-r.ch
|
m := <-r.ch
|
||||||
|
|
||||||
res = C.nxt_go_request_read_from(r.c_req, b, c, m.buf.b, m.buf.s)
|
res = C.nxt_go_request_read_from(r.c_req, b, c, m.buf.b,
|
||||||
|
m.buf.s)
|
||||||
r.push(m)
|
r.push(m)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +125,9 @@ func (r *request) push(m *cmsg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_new_request
|
//export nxt_go_new_request
|
||||||
func nxt_go_new_request(c_req C.nxt_go_request_t, id C.uint32_t, c_method *C.nxt_go_str_t, c_uri *C.nxt_go_str_t) {
|
func nxt_go_new_request(c_req C.nxt_go_request_t, id C.uint32_t,
|
||||||
|
c_method *C.nxt_go_str_t, c_uri *C.nxt_go_str_t) {
|
||||||
|
|
||||||
uri := C.GoStringN(c_uri.start, c_uri.length)
|
uri := C.GoStringN(c_uri.start, c_uri.length)
|
||||||
|
|
||||||
var URL *url.URL
|
var URL *url.URL
|
||||||
@@ -162,7 +165,9 @@ func nxt_go_find_request(id C.uint32_t) C.nxt_go_request_t {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_request_set_proto
|
//export nxt_go_request_set_proto
|
||||||
func nxt_go_request_set_proto(c_req C.nxt_go_request_t, proto *C.nxt_go_str_t, maj C.int, min C.int) {
|
func nxt_go_request_set_proto(c_req C.nxt_go_request_t, proto *C.nxt_go_str_t,
|
||||||
|
maj C.int, min C.int) {
|
||||||
|
|
||||||
r := find_request(c_req)
|
r := find_request(c_req)
|
||||||
r.req.Proto = C.GoStringN(proto.start, proto.length)
|
r.req.Proto = C.GoStringN(proto.start, proto.length)
|
||||||
r.req.ProtoMajor = int(maj)
|
r.req.ProtoMajor = int(maj)
|
||||||
@@ -170,9 +175,12 @@ func nxt_go_request_set_proto(c_req C.nxt_go_request_t, proto *C.nxt_go_str_t, m
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_request_add_header
|
//export nxt_go_request_add_header
|
||||||
func nxt_go_request_add_header(c_req C.nxt_go_request_t, name *C.nxt_go_str_t, value *C.nxt_go_str_t) {
|
func nxt_go_request_add_header(c_req C.nxt_go_request_t, name *C.nxt_go_str_t,
|
||||||
|
value *C.nxt_go_str_t) {
|
||||||
|
|
||||||
r := find_request(c_req)
|
r := find_request(c_req)
|
||||||
r.req.Header.Add(C.GoStringN(name.start, name.length), C.GoStringN(value.start, value.length))
|
r.req.Header.Add(C.GoStringN(name.start, name.length),
|
||||||
|
C.GoStringN(value.start, value.length))
|
||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_request_set_content_length
|
//export nxt_go_request_set_content_length
|
||||||
@@ -196,7 +204,9 @@ func nxt_go_request_set_url(c_req C.nxt_go_request_t, scheme *C.char) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//export nxt_go_request_set_remote_addr
|
//export nxt_go_request_set_remote_addr
|
||||||
func nxt_go_request_set_remote_addr(c_req C.nxt_go_request_t, addr *C.nxt_go_str_t) {
|
func nxt_go_request_set_remote_addr(c_req C.nxt_go_request_t,
|
||||||
|
addr *C.nxt_go_str_t) {
|
||||||
|
|
||||||
find_request(c_req).req.RemoteAddr = C.GoStringN(addr.start, addr.length)
|
find_request(c_req).req.RemoteAddr = C.GoStringN(addr.start, addr.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -297,8 +297,8 @@ nxt_app_start(nxt_task_t *task, void *data)
|
|||||||
nxt_app = nxt_app_module_load(task, lang->file);
|
nxt_app = nxt_app_module_load(task, lang->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app_conf->working_directory != NULL &&
|
if (app_conf->working_directory != NULL
|
||||||
app_conf->working_directory[0] != 0)
|
&& app_conf->working_directory[0] != 0)
|
||||||
{
|
{
|
||||||
ret = chdir(app_conf->working_directory);
|
ret = chdir(app_conf->working_directory);
|
||||||
|
|
||||||
@@ -578,8 +578,7 @@ nxt_app_msg_read_str(nxt_task_t *task, nxt_app_rmsg_t *msg, nxt_str_t *str)
|
|||||||
|
|
||||||
buf->mem.pos = nxt_app_msg_read_length(buf->mem.pos, &length);
|
buf->mem.pos = nxt_app_msg_read_length(buf->mem.pos, &length);
|
||||||
|
|
||||||
if (nxt_slow_path(nxt_buf_mem_used_size(&buf->mem) < (intptr_t)length))
|
if (nxt_slow_path(nxt_buf_mem_used_size(&buf->mem) < (intptr_t) length)) {
|
||||||
{
|
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,7 @@ nxt_app_msg_write_length(u_char *dst, size_t length)
|
|||||||
if (length < 128) {
|
if (length < 128) {
|
||||||
*dst = length;
|
*dst = length;
|
||||||
dst++;
|
dst++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dst[0] = 0x80U | (length >> 24);
|
dst[0] = 0x80U | (length >> 24);
|
||||||
dst[1] = 0xFFU & (length >> 16);
|
dst[1] = 0xFFU & (length >> 16);
|
||||||
@@ -282,6 +283,7 @@ nxt_app_msg_read_length(u_char *src, size_t *length)
|
|||||||
if (src[0] < 128) {
|
if (src[0] < 128) {
|
||||||
*length = src[0];
|
*length = src[0];
|
||||||
src++;
|
src++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*length = ((src[0] & 0x7fU) << 24) +
|
*length = ((src[0] & 0x7fU) << 24) +
|
||||||
(src[1] << 16) +
|
(src[1] << 16) +
|
||||||
|
|||||||
@@ -488,8 +488,8 @@ nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt)
|
|||||||
nxt_port_t *port;
|
nxt_port_t *port;
|
||||||
nxt_process_t *process;
|
nxt_process_t *process;
|
||||||
|
|
||||||
nxt_runtime_process_each(rt, process)
|
nxt_runtime_process_each(rt, process) {
|
||||||
{
|
|
||||||
if (nxt_pid != process->pid) {
|
if (nxt_pid != process->pid) {
|
||||||
process->init = NULL;
|
process->init = NULL;
|
||||||
|
|
||||||
@@ -500,8 +500,8 @@ nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt)
|
|||||||
|
|
||||||
} nxt_process_port_loop;
|
} nxt_process_port_loop;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
nxt_runtime_process_loop;
|
} nxt_runtime_process_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -698,11 +698,12 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
|
|||||||
nxt_runtime_process_remove(rt, process);
|
nxt_runtime_process_remove(rt, process);
|
||||||
|
|
||||||
if (!nxt_exiting) {
|
if (!nxt_exiting) {
|
||||||
nxt_runtime_process_each(rt, process)
|
nxt_runtime_process_each(rt, process) {
|
||||||
|
|
||||||
|
if (process->pid == nxt_pid
|
||||||
|
|| process->pid == pid
|
||||||
|
|| nxt_queue_is_empty(&process->ports))
|
||||||
{
|
{
|
||||||
if (process->pid == nxt_pid ||
|
|
||||||
process->pid == pid ||
|
|
||||||
nxt_queue_is_empty(&process->ports)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -713,8 +714,7 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid)
|
|||||||
|
|
||||||
nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
|
nxt_port_socket_write(task, port, NXT_PORT_MSG_REMOVE_PID,
|
||||||
-1, init->stream, 0, buf);
|
-1, init->stream, 0, buf);
|
||||||
}
|
} nxt_runtime_process_loop;
|
||||||
nxt_runtime_process_loop;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nxt_exiting) {
|
if (nxt_exiting) {
|
||||||
|
|||||||
@@ -228,6 +228,7 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
|
|||||||
nxt_log_error(NXT_LOG_INFO, task->log,
|
nxt_log_error(NXT_LOG_INFO, task->log,
|
||||||
"(ABS_MODE) php script \"%V\" root: \"%V\"",
|
"(ABS_MODE) php script \"%V\" root: \"%V\"",
|
||||||
script, root);
|
script, root);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_log_error(NXT_LOG_INFO, task->log,
|
nxt_log_error(NXT_LOG_INFO, task->log,
|
||||||
"(non ABS_MODE) php root: \"%V\"", root);
|
"(non ABS_MODE) php root: \"%V\"", root);
|
||||||
@@ -290,6 +291,7 @@ nxt_php_read_request(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
|
|||||||
if (nxt_php_path.start == NULL) {
|
if (nxt_php_path.start == NULL) {
|
||||||
if (h->path.start[h->path.length - 1] == '/') {
|
if (h->path.start[h->path.length - 1] == '/') {
|
||||||
script_name = nxt_php_index;
|
script_name = nxt_php_index;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
script_name.length = 0;
|
script_name.length = 0;
|
||||||
}
|
}
|
||||||
@@ -313,6 +315,7 @@ nxt_php_read_request(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
p[0] = '\0';
|
p[0] = '\0';
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ctx->script = nxt_php_path;
|
ctx->script = nxt_php_path;
|
||||||
}
|
}
|
||||||
@@ -397,6 +400,7 @@ nxt_php_run(nxt_task_t *task,
|
|||||||
|
|
||||||
if (nxt_php_path.start != NULL) {
|
if (nxt_php_path.start != NULL) {
|
||||||
nxt_debug(task, "run script %V in absolute mode", &nxt_php_path);
|
nxt_debug(task, "run script %V in absolute mode", &nxt_php_path);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_debug(task, "run script %V", &run_ctx.script);
|
nxt_debug(task, "run script %V", &run_ctx.script);
|
||||||
}
|
}
|
||||||
@@ -431,6 +435,7 @@ nxt_php_write(nxt_php_run_ctx_t *ctx, const u_char *data, size_t len,
|
|||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
rc = nxt_app_msg_write_raw(ctx->task, ctx->wmsg, data, len);
|
rc = nxt_app_msg_write_raw(ctx->task, ctx->wmsg, data, len);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rc = NXT_OK;
|
rc = NXT_OK;
|
||||||
}
|
}
|
||||||
@@ -675,6 +680,7 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
|
|||||||
*/
|
*/
|
||||||
NXT_PHP_SET("PHP_SELF", nxt_php_script);
|
NXT_PHP_SET("PHP_SELF", nxt_php_script);
|
||||||
NXT_PHP_SET("SCRIPT_NAME", nxt_php_script);
|
NXT_PHP_SET("SCRIPT_NAME", nxt_php_script);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NXT_PHP_SET("PHP_SELF", h->path);
|
NXT_PHP_SET("PHP_SELF", h->path);
|
||||||
NXT_PHP_SET("SCRIPT_NAME", h->path);
|
NXT_PHP_SET("SCRIPT_NAME", h->path);
|
||||||
@@ -711,6 +717,7 @@ nxt_php_register_variables(zval *track_vars_array TSRMLS_DC)
|
|||||||
|
|
||||||
server_port.start = colon + 1;
|
server_port.start = colon + 1;
|
||||||
server_port.length = host.length - server_name.length - 1;
|
server_port.length = host.length - server_name.length - 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
server_port = def_port;
|
server_port = def_port;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,22 +170,22 @@ nxt_port_send_new_port(nxt_task_t *task, nxt_runtime_t *rt,
|
|||||||
nxt_debug(task, "new port %d for process %PI",
|
nxt_debug(task, "new port %d for process %PI",
|
||||||
new_port->pair[1], new_port->pid);
|
new_port->pair[1], new_port->pid);
|
||||||
|
|
||||||
nxt_runtime_process_each(rt, process)
|
nxt_runtime_process_each(rt, process) {
|
||||||
{
|
|
||||||
if (process->pid == new_port->pid || process->pid == nxt_pid) {
|
if (process->pid == new_port->pid || process->pid == nxt_pid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
port = nxt_process_port_first(process);
|
port = nxt_process_port_first(process);
|
||||||
|
|
||||||
if (port->type == NXT_PROCESS_MAIN ||
|
if (port->type == NXT_PROCESS_MAIN
|
||||||
port->type == NXT_PROCESS_CONTROLLER ||
|
|| port->type == NXT_PROCESS_CONTROLLER
|
||||||
port->type == NXT_PROCESS_ROUTER) {
|
|| port->type == NXT_PROCESS_ROUTER)
|
||||||
|
{
|
||||||
(void) nxt_port_send_port(task, port, new_port, stream);
|
(void) nxt_port_send_port(task, port, new_port, stream);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
nxt_runtime_process_loop;
|
} nxt_runtime_process_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -340,8 +340,8 @@ nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt, nxt_uint_t slot,
|
|||||||
|
|
||||||
nxt_debug(task, "change log file #%ui fd:%FD", slot, fd);
|
nxt_debug(task, "change log file #%ui fd:%FD", slot, fd);
|
||||||
|
|
||||||
nxt_runtime_process_each(rt, process)
|
nxt_runtime_process_each(rt, process) {
|
||||||
{
|
|
||||||
if (nxt_pid == process->pid) {
|
if (nxt_pid == process->pid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -358,8 +358,8 @@ nxt_port_change_log_file(nxt_task_t *task, nxt_runtime_t *rt, nxt_uint_t slot,
|
|||||||
|
|
||||||
(void) nxt_port_socket_write(task, port, NXT_PORT_MSG_CHANGE_FILE,
|
(void) nxt_port_socket_write(task, port, NXT_PORT_MSG_CHANGE_FILE,
|
||||||
fd, 0, 0, b);
|
fd, 0, 0, b);
|
||||||
}
|
|
||||||
nxt_runtime_process_loop;
|
} nxt_runtime_process_loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -386,7 +386,6 @@ nxt_port_change_log_file_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
* for new log file. This change is performed atomically in the kernel.
|
* for new log file. This change is performed atomically in the kernel.
|
||||||
*/
|
*/
|
||||||
if (nxt_file_redirect(log_file, msg->fd) == NXT_OK) {
|
if (nxt_file_redirect(log_file, msg->fd) == NXT_OK) {
|
||||||
|
|
||||||
if (slot == 0) {
|
if (slot == 0) {
|
||||||
(void) nxt_file_stderr(log_file);
|
(void) nxt_file_stderr(log_file);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,10 @@ nxt_port_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
|
|||||||
port = data;
|
port = data;
|
||||||
pid_port_id = (nxt_pid_port_id_t *) lhq->key.start;
|
pid_port_id = (nxt_pid_port_id_t *) lhq->key.start;
|
||||||
|
|
||||||
if (lhq->key.length == sizeof(nxt_pid_port_id_t) &&
|
if (lhq->key.length == sizeof(nxt_pid_port_id_t)
|
||||||
pid_port_id->pid == port->pid &&
|
&& pid_port_id->pid == port->pid
|
||||||
pid_port_id->port_id == port->id) {
|
&& pid_port_id->port_id == port->id)
|
||||||
|
{
|
||||||
return NXT_OK;
|
return NXT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
|
|
||||||
#if (NXT_HAVE_MEMFD_CREATE)
|
#if (NXT_HAVE_MEMFD_CREATE)
|
||||||
|
|
||||||
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
|
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
|
||||||
|
|
||||||
if (nxt_slow_path(fd == -1)) {
|
if (nxt_slow_path(fd == -1)) {
|
||||||
@@ -253,7 +254,9 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
|
|||||||
nxt_debug(task, "memfd_create(%s): %FD", name, fd);
|
nxt_debug(task, "memfd_create(%s): %FD", name, fd);
|
||||||
|
|
||||||
#elif (NXT_HAVE_SHM_OPEN)
|
#elif (NXT_HAVE_SHM_OPEN)
|
||||||
shm_unlink((char *) name); // just in case
|
|
||||||
|
/* Just in case. */
|
||||||
|
shm_unlink((char *) name);
|
||||||
|
|
||||||
fd = shm_open((char *) name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
fd = shm_open((char *) name, O_CREAT | O_EXCL | O_RDWR, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
@@ -269,6 +272,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
|
|||||||
nxt_log(task, NXT_LOG_WARN, "shm_unlink(%s) failed %E", name,
|
nxt_log(task, NXT_LOG_WARN, "shm_unlink(%s) failed %E", name,
|
||||||
nxt_errno);
|
nxt_errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (nxt_slow_path(ftruncate(fd, PORT_MMAP_SIZE) == -1)) {
|
if (nxt_slow_path(ftruncate(fd, PORT_MMAP_SIZE) == -1)) {
|
||||||
@@ -277,8 +281,8 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
|
|||||||
goto remove_fail;
|
goto remove_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
mem = nxt_mem_mmap(NULL, PORT_MMAP_SIZE,
|
mem = nxt_mem_mmap(NULL, PORT_MMAP_SIZE, PROT_READ | PROT_WRITE,
|
||||||
PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
MAP_SHARED, fd, 0);
|
||||||
|
|
||||||
if (nxt_slow_path(mem == MAP_FAILED)) {
|
if (nxt_slow_path(mem == MAP_FAILED)) {
|
||||||
goto remove_fail;
|
goto remove_fail;
|
||||||
@@ -395,6 +399,7 @@ nxt_port_get_port_incoming_mmap(nxt_task_t *task, nxt_pid_t spid, uint32_t id)
|
|||||||
if (nxt_fast_path(incoming != NULL && incoming->nelts > id)) {
|
if (nxt_fast_path(incoming != NULL && incoming->nelts > id)) {
|
||||||
port_mmap = incoming->elts;
|
port_mmap = incoming->elts;
|
||||||
hdr = port_mmap[id].hdr;
|
hdr = port_mmap[id].hdr;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_log(task, NXT_LOG_WARN,
|
nxt_log(task, NXT_LOG_WARN,
|
||||||
"failed to get incoming mmap #%d for process %PI", id, spid);
|
"failed to get incoming mmap #%d for process %PI", id, spid);
|
||||||
@@ -511,9 +516,9 @@ nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b, size_t size,
|
|||||||
nchunks--;
|
nchunks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nchunks != 0 &&
|
if (nchunks != 0
|
||||||
min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start)) {
|
&& min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start))
|
||||||
|
{
|
||||||
c--;
|
c--;
|
||||||
while (c >= start) {
|
while (c >= start) {
|
||||||
nxt_port_mmap_set_chunk_free(hdr, c);
|
nxt_port_mmap_set_chunk_free(hdr, c);
|
||||||
@@ -523,6 +528,7 @@ nxt_port_mmap_increase_buf(nxt_task_t *task, nxt_buf_t *b, size_t size,
|
|||||||
nxt_debug(task, "failed to increase, %d chunks busy", nchunks);
|
nxt_debug(task, "failed to increase, %d chunks busy", nchunks);
|
||||||
|
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
b->mem.end += PORT_MMAP_CHUNK_SIZE * (c - start);
|
b->mem.end += PORT_MMAP_CHUNK_SIZE * (c - start);
|
||||||
|
|
||||||
@@ -565,8 +571,8 @@ nxt_port_mmap_get_incoming_buf(nxt_task_t *task, nxt_port_t *port,
|
|||||||
|
|
||||||
b->parent = hdr;
|
b->parent = hdr;
|
||||||
|
|
||||||
nxt_debug(task, "incoming mmap buf allocation: %p [%p,%d] %PI,%d,%d", b,
|
nxt_debug(task, "incoming mmap buf allocation: %p [%p,%d] %PI,%d,%d",
|
||||||
b->mem.start, b->mem.end - b->mem.start,
|
b, b->mem.start, b->mem.end - b->mem.start,
|
||||||
hdr->pid, hdr->id, mmap_msg->chunk_id);
|
hdr->pid, hdr->id, mmap_msg->chunk_id);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
@@ -599,8 +605,8 @@ nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (nxt_slow_path(bmem == NULL)) {
|
if (nxt_slow_path(bmem == NULL)) {
|
||||||
nxt_log_error(NXT_LOG_ERR, task->log, "failed to find buf for "
|
nxt_log_error(NXT_LOG_ERR, task->log,
|
||||||
"iobuf[%d]", i);
|
"failed to find buf for iobuf[%d]", i);
|
||||||
return;
|
return;
|
||||||
/* TODO clear b and exit */
|
/* TODO clear b and exit */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ nxt_port_rpc_register_handler(nxt_task_t *task, nxt_port_t *port,
|
|||||||
nxt_port_rpc_reg_t *reg;
|
nxt_port_rpc_reg_t *reg;
|
||||||
nxt_lvlhsh_query_t lhq;
|
nxt_lvlhsh_query_t lhq;
|
||||||
|
|
||||||
|
|
||||||
nxt_assert(port->pair[0] != -1);
|
nxt_assert(port->pair[0] != -1);
|
||||||
|
|
||||||
stream = port->next_stream++;
|
stream = port->next_stream++;
|
||||||
@@ -158,6 +157,7 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
|
|
||||||
if (last != 0) {
|
if (last != 0) {
|
||||||
ret = nxt_lvlhsh_delete(&port->rpc_streams, &lhq);
|
ret = nxt_lvlhsh_delete(&port->rpc_streams, &lhq);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ret = nxt_lvlhsh_find(&port->rpc_streams, &lhq);
|
ret = nxt_lvlhsh_find(&port->rpc_streams, &lhq);
|
||||||
}
|
}
|
||||||
@@ -176,6 +176,7 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
|
|
||||||
if (type == _NXT_PORT_MSG_RPC_ERROR) {
|
if (type == _NXT_PORT_MSG_RPC_ERROR) {
|
||||||
reg->error_handler(task, msg, reg->data);
|
reg->error_handler(task, msg, reg->data);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
reg->ready_handler(task, msg, reg->data);
|
reg->ready_handler(task, msg, reg->data);
|
||||||
}
|
}
|
||||||
@@ -197,6 +198,7 @@ nxt_port_rpc_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
|
nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
|
||||||
"peer %PI", reg->peer);
|
"peer %PI", reg->peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_queue_remove(®->link);
|
nxt_queue_remove(®->link);
|
||||||
}
|
}
|
||||||
@@ -262,8 +264,9 @@ nxt_port_rpc_remove_peer(nxt_task_t *task, nxt_port_t *port, nxt_pid_t peer)
|
|||||||
ret = nxt_lvlhsh_delete(&port->rpc_streams, &lhq);
|
ret = nxt_lvlhsh_delete(&port->rpc_streams, &lhq);
|
||||||
|
|
||||||
if (nxt_slow_path(ret != NXT_OK)) {
|
if (nxt_slow_path(ret != NXT_OK)) {
|
||||||
nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
|
nxt_log_error(NXT_LOG_ERR, task->log,
|
||||||
"handler for stream #%uD", stream);
|
"rpc: failed to delete handler for stream #%uD",
|
||||||
|
stream);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -309,9 +312,10 @@ nxt_port_rpc_cancel(nxt_task_t *task, nxt_port_t *port, uint32_t stream)
|
|||||||
ret = nxt_lvlhsh_delete(&port->rpc_peers, &lhq);
|
ret = nxt_lvlhsh_delete(&port->rpc_peers, &lhq);
|
||||||
|
|
||||||
if (nxt_slow_path(ret != NXT_OK)) {
|
if (nxt_slow_path(ret != NXT_OK)) {
|
||||||
nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
|
nxt_log_error(NXT_LOG_ERR, task->log,
|
||||||
"peer %PI", reg->peer);
|
"rpc: failed to delete peer %PI", reg->peer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_queue_remove(®->link);
|
nxt_queue_remove(®->link);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -176,10 +176,10 @@ nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port, nxt_uint_t type,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg->port_msg.stream == stream &&
|
if (msg->port_msg.stream == stream
|
||||||
msg->port_msg.reply_port == reply_port &&
|
&& msg->port_msg.reply_port == reply_port
|
||||||
msg->port_msg.last == 0 &&
|
&& msg->port_msg.last == 0
|
||||||
msg->opened) {
|
&& msg->opened) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* An fd is ignored since a file descriptor
|
* An fd is ignored since a file descriptor
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
|
|||||||
nxt_debug(task, "remove not ready process %PI", p->pid);
|
nxt_debug(task, "remove not ready process %PI", p->pid);
|
||||||
|
|
||||||
nxt_runtime_process_remove(rt, p);
|
nxt_runtime_process_remove(rt, p);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_port_mmaps_destroy(p->incoming, 0);
|
nxt_port_mmaps_destroy(p->incoming, 0);
|
||||||
nxt_port_mmaps_destroy(p->outgoing, 0);
|
nxt_port_mmaps_destroy(p->outgoing, 0);
|
||||||
|
|||||||
@@ -359,7 +359,6 @@ nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg)
|
|||||||
nxt_python_write(&run_ctx, buf, size, 1, 1);
|
nxt_python_write(&run_ctx, buf, size, 1, 1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
iterator = PyObject_GetIter(result);
|
iterator = PyObject_GetIter(result);
|
||||||
|
|
||||||
if (nxt_slow_path(iterator == NULL)) {
|
if (nxt_slow_path(iterator == NULL)) {
|
||||||
@@ -574,6 +573,7 @@ nxt_python_add_env(nxt_task_t *task, PyObject *env, const char *name,
|
|||||||
nxt_log_error(NXT_LOG_ERR, task->log,
|
nxt_log_error(NXT_LOG_ERR, task->log,
|
||||||
"Python failed to set the \"%s\" environ value", name);
|
"Python failed to set the \"%s\" environ value", name);
|
||||||
rc = NXT_ERROR;
|
rc = NXT_ERROR;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rc = NXT_OK;
|
rc = NXT_OK;
|
||||||
}
|
}
|
||||||
@@ -682,6 +682,7 @@ nxt_python_get_environ(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
|
|||||||
|
|
||||||
server_port.start = colon + 1;
|
server_port.start = colon + 1;
|
||||||
server_port.length = host.length - server_name.length - 1;
|
server_port.length = host.length - server_name.length - 1;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
server_port = def_port;
|
server_port = def_port;
|
||||||
}
|
}
|
||||||
@@ -914,6 +915,7 @@ nxt_python_write_py_str(nxt_python_run_ctx_t *ctx, PyObject *str,
|
|||||||
if (PyBytes_Check(str)) {
|
if (PyBytes_Check(str)) {
|
||||||
rc = nxt_python_write(ctx, (u_char *) PyBytes_AS_STRING(str),
|
rc = nxt_python_write(ctx, (u_char *) PyBytes_AS_STRING(str),
|
||||||
PyBytes_GET_SIZE(str), flush, last);
|
PyBytes_GET_SIZE(str), flush, last);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (!PyUnicode_Check(str)) {
|
if (!PyUnicode_Check(str)) {
|
||||||
return NXT_ERROR;
|
return NXT_ERROR;
|
||||||
|
|||||||
@@ -101,6 +101,8 @@ static void nxt_router_apps_sort(nxt_router_t *router,
|
|||||||
|
|
||||||
static void nxt_router_engines_post(nxt_router_temp_conf_t *tmcf);
|
static void nxt_router_engines_post(nxt_router_temp_conf_t *tmcf);
|
||||||
static void nxt_router_engine_post(nxt_router_engine_conf_t *recf);
|
static void nxt_router_engine_post(nxt_router_engine_conf_t *recf);
|
||||||
|
static void nxt_router_app_data_handler(nxt_task_t *task,
|
||||||
|
nxt_port_recv_msg_t *msg);
|
||||||
|
|
||||||
static void nxt_router_thread_start(void *data);
|
static void nxt_router_thread_start(void *data);
|
||||||
static void nxt_router_listen_socket_create(nxt_task_t *task, void *obj,
|
static void nxt_router_listen_socket_create(nxt_task_t *task, void *obj,
|
||||||
@@ -1525,9 +1527,6 @@ nxt_router_engine_post(nxt_router_engine_conf_t *recf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
nxt_router_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg);
|
|
||||||
|
|
||||||
static nxt_port_handler_t nxt_router_app_port_handlers[] = {
|
static nxt_port_handler_t nxt_router_app_port_handlers[] = {
|
||||||
NULL, /* NXT_PORT_MSG_QUIT */
|
NULL, /* NXT_PORT_MSG_QUIT */
|
||||||
NULL, /* NXT_PORT_MSG_NEW_PORT */
|
NULL, /* NXT_PORT_MSG_NEW_PORT */
|
||||||
@@ -1998,6 +1997,7 @@ nxt_router_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
c->write_state = &nxt_router_conn_write_state;
|
c->write_state = &nxt_router_conn_write_state;
|
||||||
|
|
||||||
nxt_conn_write(task->thread->engine, c);
|
nxt_conn_write(task->thread->engine, c);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_debug(task, "router data attach out bufs to existing chain");
|
nxt_debug(task, "router data attach out bufs to existing chain");
|
||||||
|
|
||||||
@@ -2005,6 +2005,7 @@ nxt_router_app_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nxt_inline const char *
|
nxt_inline const char *
|
||||||
nxt_router_text_by_code(int code)
|
nxt_router_text_by_code(int code)
|
||||||
{
|
{
|
||||||
@@ -2090,6 +2091,7 @@ nxt_router_gen_error(nxt_task_t *task, nxt_conn_t *c, int code,
|
|||||||
c->write_state = &nxt_router_conn_write_state;
|
c->write_state = &nxt_router_conn_write_state;
|
||||||
|
|
||||||
nxt_conn_write(task->thread->engine, c);
|
nxt_conn_write(task->thread->engine, c);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_debug(task, "router data attach out bufs to existing chain");
|
nxt_debug(task, "router data attach out bufs to existing chain");
|
||||||
|
|
||||||
@@ -2133,7 +2135,8 @@ nxt_router_sw_error(nxt_task_t *task, nxt_port_recv_msg_t *msg, void *data)
|
|||||||
|
|
||||||
sw->app->pending_workers--;
|
sw->app->pending_workers--;
|
||||||
|
|
||||||
nxt_debug(task, "sw %p error, failed to start app '%V'", sw, &sw->app->name);
|
nxt_debug(task, "sw %p error, failed to start app '%V'",
|
||||||
|
sw, &sw->app->name);
|
||||||
|
|
||||||
nxt_router_sw_release(task, sw);
|
nxt_router_sw_release(task, sw);
|
||||||
}
|
}
|
||||||
@@ -2221,19 +2224,21 @@ nxt_router_app_free(nxt_task_t *task, nxt_app_t *app)
|
|||||||
app->live, app->workers, app->pending_workers,
|
app->live, app->workers, app->pending_workers,
|
||||||
nxt_queue_is_empty(&app->requests));
|
nxt_queue_is_empty(&app->requests));
|
||||||
|
|
||||||
if (app->live == 0 && app->workers == 0 &&
|
if (app->live == 0
|
||||||
app->pending_workers == 0 &&
|
&& app->workers == 0
|
||||||
nxt_queue_is_empty(&app->requests)) {
|
&& app->pending_workers == 0
|
||||||
|
&& nxt_queue_is_empty(&app->requests))
|
||||||
|
{
|
||||||
nxt_thread_mutex_destroy(&app->mutex);
|
nxt_thread_mutex_destroy(&app->mutex);
|
||||||
nxt_free(app);
|
nxt_free(app);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (app->live == 1 && nxt_queue_is_empty(&app->requests) == 0 &&
|
if (app->live == 1
|
||||||
(app->workers + app->pending_workers < app->max_workers)) {
|
&& nxt_queue_is_empty(&app->requests) == 0
|
||||||
|
&& app->workers + app->pending_workers < app->max_workers)
|
||||||
|
{
|
||||||
lnk = nxt_queue_first(&app->requests);
|
lnk = nxt_queue_first(&app->requests);
|
||||||
nxt_queue_remove(lnk);
|
nxt_queue_remove(lnk);
|
||||||
|
|
||||||
@@ -2515,10 +2520,10 @@ nxt_router_conn_http_header_parse(nxt_task_t *task, void *obj, void *data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joint->socket_conf->max_body_size > 0 &&
|
if (joint->socket_conf->max_body_size > 0
|
||||||
(size_t) h->parsed_content_length >
|
&& (size_t) h->parsed_content_length
|
||||||
joint->socket_conf->max_body_size) {
|
> joint->socket_conf->max_body_size)
|
||||||
|
{
|
||||||
nxt_router_gen_error(task, c, 413, "Content-Length too big");
|
nxt_router_gen_error(task, c, 413, "Content-Length too big");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -2555,8 +2560,10 @@ nxt_router_conn_http_header_parse(nxt_task_t *task, void *obj, void *data)
|
|||||||
if (c->read->mem.free == c->read->mem.end) {
|
if (c->read->mem.free == c->read->mem.end) {
|
||||||
size = joint->socket_conf->large_header_buffer_size;
|
size = joint->socket_conf->large_header_buffer_size;
|
||||||
|
|
||||||
if (size <= (size_t) nxt_buf_mem_used_size(&buf->mem) ||
|
if (size <= (size_t) nxt_buf_mem_used_size(&buf->mem)
|
||||||
ap->r.header.bufs >= joint->socket_conf->large_header_buffers) {
|
|| ap->r.header.bufs
|
||||||
|
>= joint->socket_conf->large_header_buffers)
|
||||||
|
{
|
||||||
nxt_router_gen_error(task, c, 413,
|
nxt_router_gen_error(task, c, 413,
|
||||||
"Too long request headers");
|
"Too long request headers");
|
||||||
return;
|
return;
|
||||||
@@ -2797,8 +2804,10 @@ nxt_python_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
|
|||||||
|
|
||||||
NXT_WRITE(&h->method);
|
NXT_WRITE(&h->method);
|
||||||
NXT_WRITE(&h->target);
|
NXT_WRITE(&h->target);
|
||||||
|
|
||||||
if (h->path.start == h->target.start) {
|
if (h->path.start == h->target.start) {
|
||||||
NXT_WRITE(&eof);
|
NXT_WRITE(&eof);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NXT_WRITE(&h->path);
|
NXT_WRITE(&h->path);
|
||||||
}
|
}
|
||||||
@@ -2876,8 +2885,10 @@ nxt_php_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
|
|||||||
|
|
||||||
NXT_WRITE(&h->method);
|
NXT_WRITE(&h->method);
|
||||||
NXT_WRITE(&h->target);
|
NXT_WRITE(&h->target);
|
||||||
|
|
||||||
if (h->path.start == h->target.start) {
|
if (h->path.start == h->target.start) {
|
||||||
NXT_WRITE(&eof);
|
NXT_WRITE(&eof);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NXT_WRITE(&h->path);
|
NXT_WRITE(&h->path);
|
||||||
}
|
}
|
||||||
@@ -2961,8 +2972,10 @@ nxt_go_prepare_msg(nxt_task_t *task, nxt_app_request_t *r, nxt_app_wmsg_t *wmsg)
|
|||||||
|
|
||||||
NXT_WRITE(&h->method);
|
NXT_WRITE(&h->method);
|
||||||
NXT_WRITE(&h->target);
|
NXT_WRITE(&h->target);
|
||||||
|
|
||||||
if (h->path.start == h->target.start) {
|
if (h->path.start == h->target.start) {
|
||||||
NXT_WRITE(&eof);
|
NXT_WRITE(&eof);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
NXT_WRITE(&h->path);
|
NXT_WRITE(&h->path);
|
||||||
}
|
}
|
||||||
@@ -3057,6 +3070,7 @@ nxt_router_conn_ready(nxt_task_t *task, void *obj, void *data)
|
|||||||
nxt_debug(task, "router conn %p has more data to write", obj);
|
nxt_debug(task, "router conn %p has more data to write", obj);
|
||||||
|
|
||||||
nxt_conn_write(task->thread->engine, c);
|
nxt_conn_write(task->thread->engine, c);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
nxt_debug(task, "router conn %p no more data to write, last = %d", obj,
|
nxt_debug(task, "router conn %p no more data to write, last = %d", obj,
|
||||||
last);
|
last);
|
||||||
|
|||||||
@@ -1571,8 +1571,9 @@ nxt_runtime_lvlhsh_pid_test(nxt_lvlhsh_query_t *lhq, void *data)
|
|||||||
|
|
||||||
process = data;
|
process = data;
|
||||||
|
|
||||||
if (lhq->key.length == sizeof(nxt_pid_t) &&
|
if (lhq->key.length == sizeof(nxt_pid_t)
|
||||||
*(nxt_pid_t *) lhq->key.start == process->pid) {
|
&& *(nxt_pid_t *) lhq->key.start == process->pid)
|
||||||
|
{
|
||||||
return NXT_OK;
|
return NXT_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user