提交 2fd84d39 编写于 作者: P Peter Krempa 提交者: Cole Robinson

conf: Remove console stream callback only when freeing console helper

Commit ba226d33 tried to fix crash of
the daemon when a domain with an open console was destroyed. The fix was
wrong as it tried to remove the callback also when the stream was
aborted, where at that point the fd stream driver was already freed and
removed.

This patch clears the callbacks with a helper right before the hash is
freed, so that it doesn't interfere with other codepaths where the
stream object is freed.
(cherry picked from commit 45edefc7)
上级 69cba17c
......@@ -222,9 +222,6 @@ static void virConsoleHashEntryFree(void *data,
const char *pty = name;
virStreamPtr st = data;
/* remove callback from stream */
virFDStreamSetInternalCloseCb(st, NULL, NULL, NULL);
/* free stream reference */
virStreamFree(st);
......@@ -292,6 +289,18 @@ error:
return NULL;
}
/**
* Helper to clear stream callbacks when freeing the hash
*/
static void virConsoleFreeClearCallbacks(void *payload,
const void *name ATTRIBUTE_UNUSED,
void *data ATTRIBUTE_UNUSED)
{
virStreamPtr st = payload;
virFDStreamSetInternalCloseCb(st, NULL, NULL, NULL);
}
/**
* Free structures for handling open console streams.
*
......@@ -303,6 +312,7 @@ void virConsoleFree(virConsolesPtr cons)
return;
virMutexLock(&cons->lock);
virHashForEach(cons->hash, virConsoleFreeClearCallbacks, NULL);
virHashFree(cons->hash);
virMutexUnlock(&cons->lock);
virMutexDestroy(&cons->lock);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册