Style fixes.

This commit is contained in:
Igor Sysoev
2017-09-06 02:30:55 +03:00
parent 22ae3d4ff5
commit 58907888e5
22 changed files with 186 additions and 125 deletions

View File

@@ -65,7 +65,7 @@ $echo "checking for PHP ..." >> $NXT_AUTOCONF_ERR
NXT_PHP_LDFLAGS= NXT_PHP_LDFLAGS=
if /bin/sh -c "${NXT_PHP_CONFIG} --version" >> $NXT_AUTOCONF_ERR 2>&1; then if /bin/sh -c "${NXT_PHP_CONFIG} --version" >> $NXT_AUTOCONF_ERR 2>&1; then
$echo " found" $echo " found"

View File

@@ -123,7 +123,7 @@ nxt_go_port_on_read(void *buf, size_t buf_size, void *oob, size_t oob_size)
nxt_port_msg_new_port_t *new_port_msg; nxt_port_msg_new_port_t *new_port_msg;
fd = -1; fd = -1;
nxt_go_debug("on read: %d (%d)", (int)buf_size, (int)oob_size); nxt_go_debug("on read: %d (%d)", (int) buf_size, (int) oob_size);
cm = oob; cm = oob;
if (oob_size >= CMSG_SPACE(sizeof(int)) if (oob_size >= CMSG_SPACE(sizeof(int))
@@ -137,11 +137,11 @@ nxt_go_port_on_read(void *buf, size_t buf_size, void *oob, size_t oob_size)
port_msg = buf; port_msg = buf;
if (buf_size < sizeof(nxt_port_msg_t)) { if (buf_size < sizeof(nxt_port_msg_t)) {
nxt_go_warn("message too small (%d bytes)", (int)buf_size); nxt_go_warn("message too small (%d bytes)", (int) buf_size);
goto fail; goto fail;
} }
buf_end = ((char *)buf) + buf_size; buf_end = ((char *) buf) + buf_size;
payload = port_msg + 1; payload = port_msg + 1;
payload_size = buf_size - sizeof(nxt_port_msg_t); payload_size = buf_size - sizeof(nxt_port_msg_t);
@@ -151,7 +151,7 @@ nxt_go_port_on_read(void *buf, size_t buf_size, void *oob, size_t oob_size)
} }
if (port_msg->type >= NXT_PORT_MSG_MAX) { if (port_msg->type >= NXT_PORT_MSG_MAX) {
nxt_go_warn("unknown message type (%d)", (int)port_msg->type); nxt_go_warn("unknown message type (%d)", (int) port_msg->type);
goto fail; goto fail;
} }

View File

@@ -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)) {
@@ -135,7 +139,7 @@ nxt_go_new_port_mmap(nxt_go_process_t *process, nxt_port_id_t id)
&cmsg, sizeof(cmsg)); &cmsg, sizeof(cmsg));
nxt_go_debug("new mmap #%d created for %d -> %d", nxt_go_debug("new mmap #%d created for %d -> %d",
(int)hdr->id, (int)getpid(), (int)process->pid); (int) hdr->id, (int) getpid(), (int) process->pid);
close(fd); close(fd);

View File

@@ -35,10 +35,10 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
process = nxt_go_array_at(&processes, i); process = nxt_go_array_at(&processes, i);
nxt_go_debug("compare process #%d (%p) at %d", nxt_go_debug("compare process #%d (%p) at %d",
(int)process->pid, process, (int)i); (int) process->pid, process, (int) i);
if (pid == process->pid) { if (pid == process->pid) {
nxt_go_debug("found process %d at %d", (int)pid, (int)i); nxt_go_debug("found process %d at %d", (int) pid, (int) i);
if (pos != NULL) { if (pos != NULL) {
*pos = i; *pos = i;
@@ -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;
} }
@@ -60,7 +61,7 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
*pos = i; *pos = i;
} }
nxt_go_debug("process %d not found, best pos %d", (int)pid, (int)i); nxt_go_debug("process %d not found, best pos %d", (int) pid, (int) i);
return NULL; return NULL;
} }
@@ -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,
@@ -108,10 +109,10 @@ nxt_go_new_incoming_mmap(nxt_pid_t pid, nxt_fd_t fd)
process = nxt_go_get_process(pid); process = nxt_go_get_process(pid);
nxt_go_debug("got new mmap fd #%d from process %d", nxt_go_debug("got new mmap fd #%d from process %d",
(int)fd, (int)pid); (int) fd, (int) pid);
if (fstat(fd, &mmap_stat) == -1) { if (fstat(fd, &mmap_stat) == -1) {
nxt_go_warn("fstat(%d) failed %d", (int)fd, errno); nxt_go_warn("fstat(%d) failed %d", (int) fd, errno);
return; return;
} }

View File

@@ -29,7 +29,7 @@ nxt_go_ctx_msg_rbuf(nxt_go_run_ctx_t *ctx, nxt_go_msg_t *msg, nxt_buf_t *buf,
if (nxt_slow_path(msg->mmap_msg == NULL)) { if (nxt_slow_path(msg->mmap_msg == NULL)) {
if (n > 0) { if (n > 0) {
nxt_go_warn("failed to get plain buf #%d", (int)n); nxt_go_warn("failed to get plain buf #%d", (int) n);
return NXT_ERROR; return NXT_ERROR;
} }
@@ -44,15 +44,15 @@ nxt_go_ctx_msg_rbuf(nxt_go_run_ctx_t *ctx, nxt_go_msg_t *msg, nxt_buf_t *buf,
mmap_msg = msg->mmap_msg + n; mmap_msg = msg->mmap_msg + n;
if (nxt_slow_path(mmap_msg >= msg->end)) { if (nxt_slow_path(mmap_msg >= msg->end)) {
nxt_go_warn("no more data in shm #%d", (int)n); nxt_go_warn("no more data in shm #%d", (int) n);
return NXT_ERROR; return NXT_ERROR;
} }
if (nxt_slow_path(mmap_msg->mmap_id >= ctx->process->incoming.nelts)) { if (nxt_slow_path(mmap_msg->mmap_id >= ctx->process->incoming.nelts)) {
nxt_go_warn("incoming shared memory segment #%d not found " nxt_go_warn("incoming shared memory segment #%d not found "
"for process %d", (int)mmap_msg->mmap_id, "for process %d", (int) mmap_msg->mmap_id,
(int)msg->port_msg->pid); (int) msg->port_msg->pid);
return NXT_ERROR; return NXT_ERROR;
} }
@@ -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) {
@@ -464,9 +467,9 @@ nxt_go_ctx_read_str(nxt_go_run_ctx_t *ctx, nxt_str_t *str)
buf = &ctx->rbuf; buf = &ctx->rbuf;
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)) {
nxt_go_warn("read str: used size too small %d < %d", nxt_go_warn("read str: used size too small %d < %d",
(int)nxt_buf_mem_used_size(&buf->mem), (int)length); (int) nxt_buf_mem_used_size(&buf->mem), (int) length);
return NXT_ERROR; return NXT_ERROR;
} }
@@ -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;

View File

@@ -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)
@@ -168,7 +174,7 @@ func new_port(pid int, id int, t int, rcv int, snd int) *port {
pid: pid, pid: pid,
id: id, id: id,
}, },
t: t, t: t,
rcv: getUnixConn(rcv), rcv: getUnixConn(rcv),
snd: getUnixConn(snd), snd: getUnixConn(snd),
} }

View File

@@ -17,12 +17,12 @@ import (
) )
type request struct { type request struct {
req http.Request req http.Request
resp *response resp *response
c_req C.nxt_go_request_t c_req C.nxt_go_request_t
id C.uint32_t id C.uint32_t
msgs []*cmsg msgs []*cmsg
ch chan *cmsg ch chan *cmsg
} }
func (r *request) Read(p []byte) (n int, err error) { func (r *request) Read(p []byte) (n int, err error) {
@@ -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)
} }

View File

@@ -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);
@@ -483,7 +483,7 @@ nxt_app_msg_write(nxt_task_t *task, nxt_app_wmsg_t *msg, u_char *c, size_t size)
nxt_memcpy(dst, c, size); nxt_memcpy(dst, c, size);
dst[size] = 0; dst[size] = 0;
nxt_debug(task, "nxt_app_msg_write: %uz %*s", size, (int)size, c); nxt_debug(task, "nxt_app_msg_write: %uz %*s", size, (int) size, c);
} else { } else {
dst_length = 1; dst_length = 1;
@@ -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;
} }
@@ -589,8 +588,8 @@ nxt_app_msg_read_str(nxt_task_t *task, nxt_app_rmsg_t *msg, nxt_str_t *str)
buf->mem.pos += length; buf->mem.pos += length;
nxt_debug(task, "nxt_read_str: %d %*s", (int)length - 1, nxt_debug(task, "nxt_read_str: %d %*s", (int) length - 1,
(int)length - 1, str->start); (int) length - 1, str->start);
} else { } else {
str->start = NULL; str->start = NULL;
str->length = 0; str->length = 0;
@@ -690,7 +689,7 @@ nxt_app_msg_read_size(nxt_task_t *task, nxt_app_rmsg_t *msg, size_t *size)
buf->mem.pos = nxt_app_msg_read_length(buf->mem.pos, size); buf->mem.pos = nxt_app_msg_read_length(buf->mem.pos, size);
nxt_debug(task, "nxt_read_size: %d", (int)*size); nxt_debug(task, "nxt_read_size: %d", (int) *size);
return NXT_OK; return NXT_OK;
} }

View File

@@ -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) +

View File

@@ -154,7 +154,7 @@ nxt_devpoll_free(nxt_event_engine_t *engine)
nxt_debug(&engine->task, "devpoll %d free", fd); nxt_debug(&engine->task, "devpoll %d free", fd);
if (fd != -1 &&close(fd) != 0) { if (fd != -1 && close(fd) != 0) {
nxt_log(&engine->task, NXT_LOG_CRIT, "devpoll close(%d) failed %E", nxt_log(&engine->task, NXT_LOG_CRIT, "devpoll close(%d) failed %E",
fd, nxt_errno); fd, nxt_errno);
} }

View File

@@ -60,14 +60,14 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
nxt_sprintf(stream_buf, stream_buf + sizeof(stream_buf), nxt_sprintf(stream_buf, stream_buf + sizeof(stream_buf),
"%uD", port->process->init->stream); "%uD", port->process->init->stream);
setenv("NXT_GO_STREAM", (char *)stream_buf, 1); setenv("NXT_GO_STREAM", (char *) stream_buf, 1);
} }
nxt_debug(task, "port %PI, %ud, (%d, %d)", port->pid, port->id, nxt_debug(task, "port %PI, %ud, (%d, %d)", port->pid, port->id,
port->pair[0], port->pair[1]); port->pair[0], port->pair[1]);
p = nxt_sprintf(p, buf + sizeof(buf), "%PI,%ud,%d,%d,%d;", p = nxt_sprintf(p, buf + sizeof(buf), "%PI,%ud,%d,%d,%d;",
port->pid, port->id, (int)port->type, port->pid, port->id, (int) port->type,
port->pair[0], port->pair[1]); port->pair[0], port->pair[1]);
if (nxt_slow_path(nxt_sock_no_cloexec(port->pair[0]))) { if (nxt_slow_path(nxt_sock_no_cloexec(port->pair[0]))) {
@@ -83,7 +83,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
*p = '\0'; *p = '\0';
nxt_debug(task, "update NXT_GO_PORTS=%s", buf); nxt_debug(task, "update NXT_GO_PORTS=%s", buf);
setenv("NXT_GO_PORTS", (char *)buf, 1); setenv("NXT_GO_PORTS", (char *) buf, 1);
argv[0] = c->executable; argv[0] = c->executable;
argv[1] = NULL; argv[1] = NULL;

View File

@@ -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 || if (process->pid == nxt_pid
process->pid == pid || || process->pid == pid
nxt_queue_is_empty(&process->ports)) { || 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) {

View File

@@ -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;
} }

View File

@@ -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);
} }

View 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;
} }

View File

@@ -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;
@@ -584,7 +590,7 @@ nxt_port_mmap_write(nxt_task_t *task, nxt_port_t *port,
nxt_port_mmap_header_t *hdr; nxt_port_mmap_header_t *hdr;
nxt_debug(task, "prepare %z bytes message for transfer to process %PI " nxt_debug(task, "prepare %z bytes message for transfer to process %PI "
"via shared memory", sb->size, port->pid); "via shared memory", sb->size, port->pid);
bsize = sb->niov * sizeof(nxt_port_mmap_msg_t); bsize = sb->niov * sizeof(nxt_port_mmap_msg_t);
mmap_msg = port->mmsg_buf; mmap_msg = port->mmsg_buf;
@@ -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 */
} }

View File

@@ -67,8 +67,7 @@ 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(&reg->link); nxt_queue_remove(&reg->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(&reg->link); nxt_queue_remove(&reg->link);
} }

View File

@@ -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

View File

@@ -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);

View File

@@ -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)) {
@@ -373,7 +372,7 @@ nxt_python_run(nxt_task_t *task, nxt_app_rmsg_t *rmsg, nxt_app_wmsg_t *wmsg)
if (nxt_slow_path(PyBytes_Check(item) == 0)) { if (nxt_slow_path(PyBytes_Check(item) == 0)) {
nxt_log_error(NXT_LOG_ERR, task->log, nxt_log_error(NXT_LOG_ERR, task->log,
"the application returned not a bytestring object"); "the application returned not a bytestring object");
goto fail; goto fail;
} }
@@ -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;

View File

@@ -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);

View File

@@ -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;
} }