Improved 'invalid file descriptor' diagnostic.
Unit router process may send mmap file decritptor to the application process for further information exchange. During this process there may be various errors, which should be described in application error log. If file descriptor cannot be properly transferred with 'new mmap' message, fd variable will be assigned to -1 and further syscalls using this file descriptor will fail. For 'new port' message fd is checked in the same way. This commit adds early 'invalid file descriptor' diagnostic and write corresponding message to error log. Found by Coverity (CID 308515).
This commit is contained in:
@@ -598,6 +598,13 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (nxt_slow_path(fd < 0)) {
|
||||||
|
nxt_unit_alert(ctx, "#%"PRIu32": invalid fd %d for new port",
|
||||||
|
port_msg->stream, fd);
|
||||||
|
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
new_port_msg = recv_msg.start;
|
new_port_msg = recv_msg.start;
|
||||||
|
|
||||||
nxt_unit_debug(ctx, "#%"PRIu32": new_port: %d,%d fd %d",
|
nxt_unit_debug(ctx, "#%"PRIu32": new_port: %d,%d fd %d",
|
||||||
@@ -622,6 +629,13 @@ nxt_unit_process_msg(nxt_unit_ctx_t *ctx, nxt_unit_port_id_t *port_id,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case _NXT_PORT_MSG_MMAP:
|
case _NXT_PORT_MSG_MMAP:
|
||||||
|
if (nxt_slow_path(fd < 0)) {
|
||||||
|
nxt_unit_alert(ctx, "#%"PRIu32": invalid fd %d for mmap",
|
||||||
|
port_msg->stream, fd);
|
||||||
|
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
rc = nxt_unit_incoming_mmap(ctx, port_msg->pid, fd);
|
rc = nxt_unit_incoming_mmap(ctx, port_msg->pid, fd);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user