diff options
author | Max Romanov <max.romanov@nginx.com> | 2018-02-20 19:00:30 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2018-02-20 19:00:30 +0300 |
commit | babf67712e4226527730e2fb8c96babdf5486ca5 (patch) | |
tree | 732d50d6a28ffb5c8263bdedc66c8c9a7d42ba6d | |
parent | ee39da0e00423d2e4f109f90142c3543e819c14d (diff) | |
download | unit-babf67712e4226527730e2fb8c96babdf5486ca5.tar.gz unit-babf67712e4226527730e2fb8c96babdf5486ca5.tar.bz2 |
Removed unwanted assertions.
-rw-r--r-- | src/nxt_main_process.c | 5 | ||||
-rw-r--r-- | src/nxt_port.c | 2 | ||||
-rw-r--r-- | src/nxt_port_memory.c | 15 | ||||
-rw-r--r-- | src/nxt_port_socket.c | 12 | ||||
-rw-r--r-- | src/nxt_router.c | 30 |
5 files changed, 42 insertions, 22 deletions
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c index f0b55c1b..27bf01f5 100644 --- a/src/nxt_main_process.c +++ b/src/nxt_main_process.c @@ -867,8 +867,9 @@ nxt_main_cleanup_worker_process(nxt_task_t *task, nxt_pid_t pid) buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool, sizeof(pid)); - - nxt_assert(buf != NULL); + if (nxt_slow_path(buf == NULL)) { + continue; + } buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid)); diff --git a/src/nxt_port.c b/src/nxt_port.c index 1fcb0244..12de8afb 100644 --- a/src/nxt_port.c +++ b/src/nxt_port.c @@ -313,7 +313,7 @@ nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) process->ready = 1; - nxt_assert(nxt_queue_is_empty(&process->ports) == 0); + nxt_assert(!nxt_queue_is_empty(&process->ports)); port = nxt_process_port_first(process); diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c index 31bab352..fbfefc32 100644 --- a/src/nxt_port_memory.c +++ b/src/nxt_port_memory.c @@ -221,6 +221,16 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process, mmap_handler->hdr = hdr; + if (nxt_slow_path(hdr->src_pid != process->pid + || hdr->dst_pid != nxt_pid)) + { + nxt_log(task, NXT_LOG_WARN, "unexpected pid in mmap header detected: " + "%PI != %PI or %PI != %PI", hdr->src_pid, process->pid, + hdr->dst_pid, nxt_pid); + + return NULL; + } + nxt_thread_mutex_lock(&process->incoming.mutex); port_mmap = nxt_port_mmap_at(&process->incoming, hdr->id); @@ -236,9 +246,6 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process, goto fail; } - nxt_assert(hdr->src_pid == process->pid); - nxt_assert(hdr->dst_pid == nxt_pid); - port_mmap->mmap_handler = mmap_handler; nxt_port_mmap_handler_use(mmap_handler, 1); @@ -843,8 +850,6 @@ nxt_port_mmap_read(nxt_task_t *task, nxt_port_recv_msg_t *msg) end = (nxt_port_mmap_msg_t *) b->mem.free; while (mmap_msg < end) { - nxt_assert(mmap_msg + 1 <= end); - nxt_debug(task, "mmap_msg={%D, %D, %D} from %PI", mmap_msg->mmap_id, mmap_msg->chunk_id, mmap_msg->size, msg->port_msg.pid); diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c index 04f9c30c..65096177 100644 --- a/src/nxt_port_socket.c +++ b/src/nxt_port_socket.c @@ -676,7 +676,7 @@ nxt_port_frag_find(nxt_task_t *task, nxt_port_t *port, uint32_t stream, return lhq.value; default: - nxt_log(task, NXT_LOG_WARN, "frag stream #%uD not found", stream); + nxt_log(task, NXT_LOG_INFO, "frag stream #%uD not found", stream); return NULL; } @@ -719,7 +719,9 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port, fmsg = nxt_port_frag_find(task, port, msg->port_msg.stream, msg->port_msg.mf == 0); - nxt_assert(fmsg != NULL); + if (nxt_slow_path(fmsg == NULL)) { + goto fmsg_failed; + } if (nxt_fast_path(fmsg->cancelled == 0)) { @@ -757,7 +759,9 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port, fmsg = nxt_port_frag_start(task, port, msg); - nxt_assert(fmsg != NULL); + if (nxt_slow_path(fmsg == NULL)) { + goto fmsg_failed; + } fmsg->port_msg.nf = 0; fmsg->port_msg.mf = 0; @@ -785,6 +789,8 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port, } } +fmsg_failed: + if (msg->port_msg.mmap && orig_b != b) { /* diff --git a/src/nxt_router.c b/src/nxt_router.c index 36f5264d..5e1b8353 100644 --- a/src/nxt_router.c +++ b/src/nxt_router.c @@ -746,16 +746,19 @@ nxt_router_conf_data_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg) nxt_buf_used_size(msg->buf), (size_t) nxt_buf_used_size(msg->buf), msg->buf->mem.pos); - b = nxt_buf_chk_make_plain(tmcf->conf->mem_pool, msg->buf, msg->size); - - nxt_assert(b != NULL); - tmcf->conf->router = nxt_router; tmcf->stream = msg->port_msg.stream; tmcf->port = nxt_runtime_port_find(task->thread->runtime, msg->port_msg.pid, msg->port_msg.reply_port); + b = nxt_buf_chk_make_plain(tmcf->conf->mem_pool, msg->buf, msg->size); + if (nxt_slow_path(b == NULL)) { + nxt_router_conf_error(task, tmcf); + + return; + } + ret = nxt_router_conf_create(task, tmcf, b->mem.pos, b->mem.free); if (nxt_fast_path(ret == NXT_OK)) { @@ -1731,7 +1734,9 @@ nxt_router_listen_socket_error(nxt_task_t *task, nxt_port_recv_msg_t *msg, in = nxt_buf_chk_make_plain(tmcf->mem_pool, msg->buf, msg->size); - nxt_assert(in != NULL); + if (nxt_slow_path(in == NULL)) { + return; + } p = in->mem.pos; @@ -2756,7 +2761,10 @@ nxt_router_response_error_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg, if (res == NXT_OK) { port = ra->app_port; - nxt_assert(port != NULL); + if (nxt_slow_path(port == NULL)) { + nxt_log(task, NXT_LOG_ERR, "port is NULL in cancelled ra"); + return; + } nxt_port_rpc_ex_set_peer(task, task->thread->engine->port, rc, port->pid); @@ -2865,10 +2873,10 @@ nxt_router_app_use(nxt_task_t *task, nxt_app_t *app, int i) nxt_assert(app->processes == 0); nxt_assert(app->idle_processes == 0); nxt_assert(app->pending_processes == 0); - nxt_assert(nxt_queue_is_empty(&app->requests) != 0); - nxt_assert(nxt_queue_is_empty(&app->ports) != 0); - nxt_assert(nxt_queue_is_empty(&app->spare_ports) != 0); - nxt_assert(nxt_queue_is_empty(&app->idle_ports) != 0); + nxt_assert(nxt_queue_is_empty(&app->requests)); + nxt_assert(nxt_queue_is_empty(&app->ports)); + nxt_assert(nxt_queue_is_empty(&app->spare_ports)); + nxt_assert(nxt_queue_is_empty(&app->idle_ports)); nxt_thread_mutex_destroy(&app->mutex); nxt_free(app); @@ -3349,7 +3357,7 @@ nxt_router_adjust_idle_timer(nxt_task_t *task, void *obj, void *data) while (app->idle_processes > app->spare_processes) { - nxt_assert(nxt_queue_is_empty(&app->idle_ports) == 0); + nxt_assert(!nxt_queue_is_empty(&app->idle_ports)); lnk = nxt_queue_first(&app->idle_ports); port = nxt_queue_link_data(lnk, nxt_port_t, idle_link); |