Removed unwanted assertions.

This commit is contained in:
Max Romanov
2018-02-20 19:00:30 +03:00
parent ee39da0e00
commit babf67712e
5 changed files with 42 additions and 22 deletions

View File

@@ -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, buf = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
sizeof(pid)); sizeof(pid));
if (nxt_slow_path(buf == NULL)) {
nxt_assert(buf != NULL); continue;
}
buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid)); buf->mem.free = nxt_cpymem(buf->mem.free, &pid, sizeof(pid));

View File

@@ -313,7 +313,7 @@ nxt_port_process_ready_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
process->ready = 1; 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); port = nxt_process_port_first(process);

View File

@@ -221,6 +221,16 @@ nxt_port_incoming_port_mmap(nxt_task_t *task, nxt_process_t *process,
mmap_handler->hdr = hdr; 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); nxt_thread_mutex_lock(&process->incoming.mutex);
port_mmap = nxt_port_mmap_at(&process->incoming, hdr->id); 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; goto fail;
} }
nxt_assert(hdr->src_pid == process->pid);
nxt_assert(hdr->dst_pid == nxt_pid);
port_mmap->mmap_handler = mmap_handler; port_mmap->mmap_handler = mmap_handler;
nxt_port_mmap_handler_use(mmap_handler, 1); 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; end = (nxt_port_mmap_msg_t *) b->mem.free;
while (mmap_msg < end) { while (mmap_msg < end) {
nxt_assert(mmap_msg + 1 <= end);
nxt_debug(task, "mmap_msg={%D, %D, %D} from %PI", nxt_debug(task, "mmap_msg={%D, %D, %D} from %PI",
mmap_msg->mmap_id, mmap_msg->chunk_id, mmap_msg->size, mmap_msg->mmap_id, mmap_msg->chunk_id, mmap_msg->size,
msg->port_msg.pid); msg->port_msg.pid);

View File

@@ -676,7 +676,7 @@ nxt_port_frag_find(nxt_task_t *task, nxt_port_t *port, uint32_t stream,
return lhq.value; return lhq.value;
default: 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; 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, fmsg = nxt_port_frag_find(task, port, msg->port_msg.stream,
msg->port_msg.mf == 0); 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)) { 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); 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.nf = 0;
fmsg->port_msg.mf = 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) { if (msg->port_msg.mmap && orig_b != b) {
/* /*

View File

@@ -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), nxt_buf_used_size(msg->buf),
(size_t) nxt_buf_used_size(msg->buf), msg->buf->mem.pos); (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->conf->router = nxt_router;
tmcf->stream = msg->port_msg.stream; tmcf->stream = msg->port_msg.stream;
tmcf->port = nxt_runtime_port_find(task->thread->runtime, tmcf->port = nxt_runtime_port_find(task->thread->runtime,
msg->port_msg.pid, msg->port_msg.pid,
msg->port_msg.reply_port); 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); ret = nxt_router_conf_create(task, tmcf, b->mem.pos, b->mem.free);
if (nxt_fast_path(ret == NXT_OK)) { 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); 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; 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) { if (res == NXT_OK) {
port = ra->app_port; 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, nxt_port_rpc_ex_set_peer(task, task->thread->engine->port, rc,
port->pid); 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->processes == 0);
nxt_assert(app->idle_processes == 0); nxt_assert(app->idle_processes == 0);
nxt_assert(app->pending_processes == 0); nxt_assert(app->pending_processes == 0);
nxt_assert(nxt_queue_is_empty(&app->requests) != 0); nxt_assert(nxt_queue_is_empty(&app->requests));
nxt_assert(nxt_queue_is_empty(&app->ports) != 0); nxt_assert(nxt_queue_is_empty(&app->ports));
nxt_assert(nxt_queue_is_empty(&app->spare_ports) != 0); nxt_assert(nxt_queue_is_empty(&app->spare_ports));
nxt_assert(nxt_queue_is_empty(&app->idle_ports) != 0); nxt_assert(nxt_queue_is_empty(&app->idle_ports));
nxt_thread_mutex_destroy(&app->mutex); nxt_thread_mutex_destroy(&app->mutex);
nxt_free(app); 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) { 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); lnk = nxt_queue_first(&app->idle_ports);
port = nxt_queue_link_data(lnk, nxt_port_t, idle_link); port = nxt_queue_link_data(lnk, nxt_port_t, idle_link);