提交 4525de73 编写于 作者: N Nikolay Shirokovskiy

tools: console: check if console was shutdown in callbacks

On error in main thread virConsoleShutdown is called which
deletes fd watches/stream callback and yet callbacks can
be called after. Thus we can incorrectly allocate
terminalToStream.data memory and get memory leak for example.
Let's check if console was shutdown in the very beginning of
callbacks.
Reviewed-by: NCole Robinson <crobinso@redhat.com>
Signed-off-by: NNikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
上级 cb7c1cdd
......@@ -139,6 +139,10 @@ virConsoleEventOnStream(virStreamPtr st,
virObjectLock(con);
/* we got late event after console was shutdown */
if (!con->st)
goto cleanup;
if (events & VIR_STREAM_EVENT_READABLE) {
size_t avail = con->streamToTerminal.length -
con->streamToTerminal.offset;
......@@ -219,6 +223,10 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED,
virObjectLock(con);
/* we got late event after console was shutdown */
if (!con->st)
goto cleanup;
if (events & VIR_EVENT_HANDLE_READABLE) {
size_t avail = con->terminalToStream.length -
con->terminalToStream.offset;
......@@ -279,6 +287,10 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED,
virObjectLock(con);
/* we got late event after console was shutdown */
if (!con->st)
goto cleanup;
if (events & VIR_EVENT_HANDLE_WRITABLE &&
con->streamToTerminal.offset) {
ssize_t done;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册