summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--auto/modules/php2
-rw-r--r--src/go/unit/nxt_go_port.c8
-rw-r--r--src/go/unit/nxt_go_port_memory.c8
-rw-r--r--src/go/unit/nxt_go_process.c15
-rw-r--r--src/go/unit/nxt_go_run_ctx.c30
-rw-r--r--src/go/unit/port.go16
-rw-r--r--src/go/unit/request.go34
-rw-r--r--src/nxt_application.c15
-rw-r--r--src/nxt_application.h2
-rw-r--r--src/nxt_devpoll_engine.c2
-rw-r--r--src/nxt_go.c6
-rw-r--r--src/nxt_main_process.c22
-rw-r--r--src/nxt_php_sapi.c7
-rw-r--r--src/nxt_port.c25
-rw-r--r--src/nxt_port_hash.c7
-rw-r--r--src/nxt_port_memory.c28
-rw-r--r--src/nxt_port_rpc.c16
-rw-r--r--src/nxt_port_socket.c8
-rw-r--r--src/nxt_process.c1
-rw-r--r--src/nxt_python_wsgi.c6
-rw-r--r--src/nxt_router.c48
-rw-r--r--src/nxt_runtime.c5
22 files changed, 186 insertions, 125 deletions
diff --git a/auto/modules/php b/auto/modules/php
index 00a1015e..f3d59087 100644
--- a/auto/modules/php
+++ b/auto/modules/php
@@ -65,7 +65,7 @@ $echo "checking for PHP ..." >> $NXT_AUTOCONF_ERR
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"
diff --git a/src/go/unit/nxt_go_port.c b/src/go/unit/nxt_go_port.c
index a46a33d1..e866a242 100644
--- a/src/go/unit/nxt_go_port.c
+++ b/src/go/unit/nxt_go_port.c
@@ -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;
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;
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;
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;
}
- buf_end = ((char *)buf) + buf_size;
+ buf_end = ((char *) buf) + buf_size;
payload = port_msg + 1;
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) {
- nxt_go_warn("unknown message type (%d)", (int)port_msg->type);
+ nxt_go_warn("unknown message type (%d)", (int) port_msg->type);
goto fail;
}
diff --git a/src/go/unit/nxt_go_port_memory.c b/src/go/unit/nxt_go_port_memory.c
index e63ca16c..c2a63a42 100644
--- a/src/go/unit/nxt_go_port_memory.c
+++ b/src/go/unit/nxt_go_port_memory.c
@@ -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);
#if (NXT_HAVE_MEMFD_CREATE)
+
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
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);
#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);
@@ -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)) {
nxt_go_warn("shm_unlink(%s) failed %d", name, errno);
}
+
#endif
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));
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);
diff --git a/src/go/unit/nxt_go_process.c b/src/go/unit/nxt_go_process.c
index c7ce052d..c2b2c01c 100644
--- a/src/go/unit/nxt_go_process.c
+++ b/src/go/unit/nxt_go_process.c
@@ -35,10 +35,10 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
process = nxt_go_array_at(&processes, i);
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) {
- 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) {
*pos = i;
@@ -49,6 +49,7 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
if (pid < process->pid) {
r = i;
+
} else {
l = i + 1;
}
@@ -60,7 +61,7 @@ nxt_go_find_process(nxt_pid_t pid, uint32_t *pos)
*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;
}
@@ -78,8 +79,8 @@ nxt_go_get_process(nxt_pid_t pid)
nxt_go_array_add(&processes);
process = nxt_go_array_at(&processes, pos);
- nxt_go_debug("init process #%d (%p) at %d", (int)pid, process,
- (int)pos);
+ nxt_go_debug("init process #%d (%p) at %d",
+ (int) pid, process, (int) pos);
if (pos < processes.nelts - 1) {
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);
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) {
- nxt_go_warn("fstat(%d) failed %d", (int)fd, errno);
+ nxt_go_warn("fstat(%d) failed %d", (int) fd, errno);
return;
}
diff --git a/src/go/unit/nxt_go_run_ctx.c b/src/go/unit/nxt_go_run_ctx.c
index cca8273e..0dd72f8b 100644
--- a/src/go/unit/nxt_go_run_ctx.c
+++ b/src/go/unit/nxt_go_run_ctx.c
@@ -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 (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;
}
@@ -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;
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;
}
if (nxt_slow_path(mmap_msg->mmap_id >= ctx->process->incoming.nelts)) {
nxt_go_warn("incoming shared memory segment #%d not found "
- "for process %d", (int)mmap_msg->mmap_id,
- (int)msg->port_msg->pid);
+ "for process %d", (int) mmap_msg->mmap_id,
+ (int) msg->port_msg->pid);
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;
mmap_msg += 1;
}
+
} else {
msg->mmap_msg = 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) {
msg->start_offset += ctx->r.body.preread_size;
+
} else {
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;
- hdr = nxt_go_port_mmap_get(ctx->process,
- ctx->msg.port_msg->reply_port, &c);
+ hdr = nxt_go_port_mmap_get(ctx->process, ctx->msg.port_msg->reply_port, &c);
if (nxt_slow_path(hdr == NULL)) {
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--;
}
- if (nchunks != 0 &&
- min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start)) {
-
+ if (nchunks != 0
+ && min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start))
+ {
c--;
while (c >= start) {
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;
+
} else {
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;
}
}
+
} while (nxt_go_port_mmap_increase_buf(buf, len, 1) == NXT_OK);
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;
- 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",
- (int)nxt_buf_mem_used_size(&buf->mem), (int)length);
+ (int) nxt_buf_mem_used_size(&buf->mem), (int) length);
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;
- nxt_go_debug("read_str: %d %.*s", (int)length - 1, (int)length - 1,
- str->start);
+ nxt_go_debug("read_str: %d %.*s",
+ (int) length - 1, (int) length - 1, str->start);
+
} else {
str->start = NULL;
str->length = 0;
diff --git a/src/go/unit/port.go b/src/go/unit/port.go
index a8faa2a0..74b5e8fe 100644
--- a/src/go/unit/port.go
+++ b/src/go/unit/port.go
@@ -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
-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{
pid: int(pid),
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)
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 {
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
-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()
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 {
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,
id: id,
},
- t: t,
+ t: t,
rcv: getUnixConn(rcv),
snd: getUnixConn(snd),
}
diff --git a/src/go/unit/request.go b/src/go/unit/request.go
index aa6d1145..75c06ef5 100644
--- a/src/go/unit/request.go
+++ b/src/go/unit/request.go
@@ -17,12 +17,12 @@ import (
)
type request struct {
- req http.Request
- resp *response
- c_req C.nxt_go_request_t
- id C.uint32_t
- msgs []*cmsg
- ch chan *cmsg
+ req http.Request
+ resp *response
+ c_req C.nxt_go_request_t
+ id C.uint32_t
+ msgs []*cmsg
+ ch chan *cmsg
}
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 */ {
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)
}
@@ -124,7 +125,9 @@ func (r *request) push(m *cmsg) {
}
//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)
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
-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.req.Proto = C.GoStringN(proto.start, proto.length)
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
-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.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
@@ -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
-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)
}
diff --git a/src/nxt_application.c b/src/nxt_application.c
index ef84a9ec..d795c230 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -297,8 +297,8 @@ nxt_app_start(nxt_task_t *task, void *data)
nxt_app = nxt_app_module_load(task, lang->file);
}
- if (app_conf->working_directory != NULL &&
- app_conf->working_directory[0] != 0)
+ if (app_conf->working_directory != NULL
+ && app_conf->working_directory[0] != 0)
{
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);
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 {
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);
- 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;
}
@@ -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;
- nxt_debug(task, "nxt_read_str: %d %*s", (int)length - 1,
- (int)length - 1, str->start);
+ nxt_debug(task, "nxt_read_str: %d %*s", (int) length - 1,
+ (int) length - 1, str->start);
} else {
str->start = NULL;
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);
- nxt_debug(task, "nxt_read_size: %d", (int)*size);
+ nxt_debug(task, "nxt_read_size: %d", (int) *size);
return NXT_OK;
}
diff --git a/src/nxt_application.h b/src/nxt_application.h
index 38bd79f2..3f5c01b5 100644
--- a/src/nxt_application.h
+++ b/src/nxt_application.h
@@ -230,6 +230,7 @@ nxt_app_msg_write_length(u_char *dst, size_t length)
if (length < 128) {
*dst = length;
dst++;
+
} else {
dst[0] = 0x80U | (length >> 24);
dst[1] = 0xFFU & (length >> 16);
@@ -282,6 +283,7 @@ nxt_app_msg_read_length(u_char *src, size_t *length)
if (src[0] < 128) {
*length = src[0];
src++;
+
} else {
*length = ((src[0] & 0x7fU) << 24) +
(src[1] << 16) +
diff --git a/src/nxt_devpoll_engine.c b/src/nxt_devpoll_engine.c
index faa6368a..07b08189 100644
--- a/src/nxt_devpoll_engine.c
+++ b/src/nxt_devpoll_engine.c
@@ -154,7 +154,7 @@ nxt_devpoll_free(nxt_event_engine_t *engine)
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",
fd, nxt_errno);
}
diff --git a/src/nxt_go.c b/src/nxt_go.c
index 37f4de01..6ca73957 100644
--- a/src/nxt_go.c
+++ b/src/nxt_go.c
@@ -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),
"%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,
port->pair[0], port->pair[1]);
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]);
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';
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[1] = NULL;
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 305daf8f..ded19055 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -488,8 +488,8 @@ nxt_main_stop_worker_processes(nxt_task_t *task, nxt_runtime_t *rt)
nxt_port_t *port;
nxt_process_t *process;
- nxt_runtime_process_each(rt, process)
- {
+ nxt_runtime_process_each(rt, process) {
+
if (nxt_pid != process->pid) {
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_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);
if (!nxt_exiting) {
- nxt_runtime_process_each(rt, process)
- {
- if (process->pid == nxt_pid ||
- process->pid == pid ||
- nxt_queue_is_empty(&process->ports)) {
+ nxt_runtime_process_each(rt, process) {
+
+ if (process->pid == nxt_pid
+ || process->pid == pid
+ || nxt_queue_is_empty(&process->ports))
+ {
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,
-1, init->stream, 0, buf);
- }
- nxt_runtime_process_loop;
+ } nxt_runtime_process_loop;
}
if (nxt_exiting) {
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index 08b8ba01..ba7a5aad 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -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,
"(ABS_MODE) php script \"%V\" root: \"%V\"",
script, root);
+
} else {
nxt_log_error(NXT_LOG_INFO, task->log,
"(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 (h->path.start[h->path.length - 1] == '/') {
script_name = nxt_php_index;
+
} else {
script_name.length = 0;
}
@@ -313,6 +315,7 @@ nxt_php_read_request(nxt_task_t *task, nxt_app_rmsg_t *rmsg,
}
p[0] = '\0';
+
} else {
ctx->script = nxt_php_path;
}
@@ -397,6 +400,7 @@ nxt_php_run(nxt_task_t *task,
if (nxt_php_path.start != NULL) {
nxt_debug(task, "run script %V in absolute mode", &nxt_php_path);
+
} else {
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) {
rc = nxt_app_msg_write_raw(ctx->task, ctx->wmsg, data, len);
+
} else {
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("SCRIPT_NAME", nxt_php_script);
+
} else {
NXT_PHP_SET("PHP_SELF", 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.length = host.length - server_name.length - 1;
+
} else {
server_port = def_port;
}
diff --git a/src/nxt_port.c b/src/nxt_port.c
index 1f50caa1..8adbcde4 100644
--- a/src/nxt_port.c
+++ b/src/nxt_port.c
@@ -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",
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) {
continue;
}
port = nxt_process_port_first(process);
- if (port->type == NXT_PROCESS_MAIN ||
- port->type == NXT_PROCESS_CONTROLLER ||
- port->type == NXT_PROCESS_ROUTER) {
-
+ if (port->type == NXT_PROCESS_MAIN
+ || port->type == NXT_PROCESS_CONTROLLER
+ || port->type == NXT_PROCESS_ROUTER)
+ {
(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_runtime_process_each(rt, process)
- {
+ nxt_runtime_process_each(rt, process) {
+
if (nxt_pid == process->pid) {
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,
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.
*/
if (nxt_file_redirect(log_file, msg->fd) == NXT_OK) {
-
if (slot == 0) {
(void) nxt_file_stderr(log_file);
}
diff --git a/src/nxt_port_hash.c b/src/nxt_port_hash.c
index e9158f5d..93e46cd3 100644
--- a/src/nxt_port_hash.c
+++ b/src/nxt_port_hash.c
@@ -23,9 +23,10 @@ nxt_port_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
port = data;
pid_port_id = (nxt_pid_port_id_t *) lhq->key.start;
- if (lhq->key.length == sizeof(nxt_pid_port_id_t) &&
- pid_port_id->pid == port->pid &&
- pid_port_id->port_id == port->id) {
+ if (lhq->key.length == sizeof(nxt_pid_port_id_t)
+ && pid_port_id->pid == port->pid
+ && pid_port_id->port_id == port->id)
+ {
return NXT_OK;
}
diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c
index 7cdd7c58..82d96004 100644
--- a/src/nxt_port_memory.c
+++ b/src/nxt_port_memory.c
@@ -241,6 +241,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
*p = '\0';
#if (NXT_HAVE_MEMFD_CREATE)
+
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
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);
#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);
@@ -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_errno);
}
+
#endif
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;
}
- mem = nxt_mem_mmap(NULL, PORT_MMAP_SIZE,
- PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ mem = nxt_mem_mmap(NULL, PORT_MMAP_SIZE, PROT_READ | PROT_WRITE,
+ MAP_SHARED, fd, 0);
if (nxt_slow_path(mem == MAP_FAILED)) {
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)) {
port_mmap = incoming->elts;
hdr = port_mmap[id].hdr;
+
} else {
nxt_log(task, NXT_LOG_WARN,
"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--;
}
- if (nchunks != 0 &&
- min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start)) {
-
+ if (nchunks != 0
+ && min_size > free_size + PORT_MMAP_CHUNK_SIZE * (c - start))
+ {
c--;
while (c >= start) {
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);
return NXT_ERROR;
+
} else {
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;
- nxt_debug(task, "incoming mmap buf allocation: %p [%p,%d] %PI,%d,%d", b,
- b->mem.start, b->mem.end - b->mem.start,
+ nxt_debug(task, "incoming mmap buf allocation: %p [%p,%d] %PI,%d,%d",
+ b, b->mem.start, b->mem.end - b->mem.start,
hdr->pid, hdr->id, mmap_msg->chunk_id);
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_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);
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)) {
- nxt_log_error(NXT_LOG_ERR, task->log, "failed to find buf for "
- "iobuf[%d]", i);
+ nxt_log_error(NXT_LOG_ERR, task->log,
+ "failed to find buf for iobuf[%d]", i);
return;
/* TODO clear b and exit */
}
diff --git a/src/nxt_port_rpc.c b/src/nxt_port_rpc.c
index 6f31a296..c5821439 100644
--- a/src/nxt_port_rpc.c
+++ b/src/nxt_port_rpc.c
@@ -67,8 +67,7 @@ nxt_port_rpc_register_handler(nxt_task_t *task, nxt_port_t *port,
nxt_port_rpc_reg_t *reg;
nxt_lvlhsh_query_t lhq;
-
- nxt_assert(port->pair[0] != -1);
+ nxt_assert(port->pair[0] != -1);
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) {
ret = nxt_lvlhsh_delete(&port->rpc_streams, &lhq);
+
} else {
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) {
reg->error_handler(task, msg, reg->data);
+
} else {
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 "
"peer %PI", reg->peer);
}
+
} else {
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);
if (nxt_slow_path(ret != NXT_OK)) {
- nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
- "handler for stream #%uD", stream);
+ nxt_log_error(NXT_LOG_ERR, task->log,
+ "rpc: failed to delete handler for stream #%uD",
+ stream);
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);
if (nxt_slow_path(ret != NXT_OK)) {
- nxt_log_error(NXT_LOG_ERR, task->log, "rpc: failed to delete "
- "peer %PI", reg->peer);
+ nxt_log_error(NXT_LOG_ERR, task->log,
+ "rpc: failed to delete peer %PI", reg->peer);
}
+
} else {
nxt_queue_remove(&reg->link);
}
diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c
index 82a6e0aa..3f7ad954 100644
--- a/src/nxt_port_socket.c
+++ b/src/nxt_port_socket.c
@@ -176,10 +176,10 @@ nxt_port_socket_write(nxt_task_t *task, nxt_port_t *port, nxt_uint_t type,
continue;
}
- if (msg->port_msg.stream == stream &&
- msg->port_msg.reply_port == reply_port &&
- msg->port_msg.last == 0 &&
- msg->opened) {
+ if (msg->port_msg.stream == stream
+ && msg->port_msg.reply_port == reply_port
+ && msg->port_msg.last == 0
+ && msg->opened) {
/*
* An fd is ignored since a file descriptor
diff --git a/src/nxt_process.c b/src/nxt_process.c
index f7430e5a..186e898d 100644
--- a/src/nxt_process.c
+++ b/src/nxt_process.c
@@ -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_runtime_process_remove(rt, p);
+
} else {
nxt_port_mmaps_destroy(p->incoming, 0);
nxt_port_mmaps_destroy(p->outgoing, 0);
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index c29aa426..d9f2f376 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -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);
} else {
-
iterator = PyObject_GetIter(result);
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)) {
nxt_log_error(NXT_LOG_ERR, task->log,
- "the application returned not a bytestring object");
+ "the application returned not a bytestring object");
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,
"Python failed to set the \"%s\" environ value", name);
rc = NXT_ERROR;
+
} else {
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.length = host.length - server_name.length - 1;
+
} else {
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)) {
rc = nxt_python_write(ctx, (u_char *) PyBytes_AS_STRING(str),
PyBytes_GET_SIZE(str), flush, last);
+
} else {
if (!PyUnicode_Check(str)) {
return NXT_ERROR;
diff --git a/src/nxt_router.c b/src/nxt_router.c
index b91aa9ae..fbc8d9c4 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -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_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_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[] = {
NULL, /* NXT_PORT_MSG_QUIT */
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;
nxt_conn_write(task->thread->engine, c);
+
} else {
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_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;
nxt_conn_write(task->thread->engine, c);
+
} else {
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--;
- 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);
}
@@ -2221,19 +2224,21 @@ nxt_router_app_free(nxt_task_t *task, nxt_app_t *app)
app->live, app->workers, app->pending_workers,
nxt_queue_is_empty(&app->requests));
- if (app->live == 0 && app->workers == 0 &&
- app->pending_workers == 0 &&
- nxt_queue_is_empty(&app->requests)) {
-
+ if (app->live == 0
+ && app->workers == 0
+ && app->pending_workers == 0
+ && nxt_queue_is_empty(&app->requests))
+ {
nxt_thread_mutex_destroy(&app->mutex);
nxt_free(app);
return 1;
}
- if (app->live == 1 && nxt_queue_is_empty(&app->requests) == 0 &&
- (app->workers + app->pending_workers < app->max_workers)) {
-
+ if (app->live == 1
+ && nxt_queue_is_empty(&app->requests) == 0
+ && app->workers + app->pending_workers < app->max_workers)
+ {
lnk = nxt_queue_first(&app->requests);
nxt_queue_remove(lnk);
@@ -2515,10 +2520,10 @@ nxt_router_conn_http_header_parse(nxt_task_t *task, void *obj, void *data)
return;
}
- if (joint->socket_conf->max_body_size > 0 &&
- (size_t) h->parsed_content_length >
- joint->socket_conf->max_body_size) {
-
+ if (joint->socket_conf->max_body_size > 0
+ && (size_t) h->parsed_content_length
+ > joint->socket_conf->max_body_size)
+ {
nxt_router_gen_error(task, c, 413, "Content-Length too big");
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) {
size = joint->socket_conf->large_header_buffer_size;
- if (size <= (size_t) nxt_buf_mem_used_size(&buf->mem) ||
- ap->r.header.bufs >= joint->socket_conf->large_header_buffers) {
+ if (size <= (size_t) nxt_buf_mem_used_size(&buf->mem)
+ || ap->r.header.bufs
+ >= joint->socket_conf->large_header_buffers)
+ {
nxt_router_gen_error(task, c, 413,
"Too long request headers");
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->target);
+
if (h->path.start == h->target.start) {
NXT_WRITE(&eof);
+
} else {
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->target);
+
if (h->path.start == h->target.start) {
NXT_WRITE(&eof);
+
} else {
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->target);
+
if (h->path.start == h->target.start) {
NXT_WRITE(&eof);
+
} else {
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_conn_write(task->thread->engine, c);
+
} else {
nxt_debug(task, "router conn %p no more data to write, last = %d", obj,
last);
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index d18eab0a..f569f3f2 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -1571,8 +1571,9 @@ nxt_runtime_lvlhsh_pid_test(nxt_lvlhsh_query_t *lhq, void *data)
process = data;
- if (lhq->key.length == sizeof(nxt_pid_t) &&
- *(nxt_pid_t *) lhq->key.start == process->pid) {
+ if (lhq->key.length == sizeof(nxt_pid_t)
+ && *(nxt_pid_t *) lhq->key.start == process->pid)
+ {
return NXT_OK;
}