13
0

fix potentially crash-inducing race condition by removing event loops' x-thread channel from an event loop when it is destroyed

This commit is contained in:
Paul Davis 2016-10-17 14:48:15 -04:00
parent 157253c2c6
commit 8519677a24
2 changed files with 16 additions and 0 deletions

View File

@ -29,6 +29,14 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking)
CrossThreadChannel::~CrossThreadChannel ()
{
if (receive_source) {
/* this disconnects it from any main context it was attached in
in ::attach(), this prevent its callback from being invoked
after the destructor has finished.
*/
g_source_destroy (receive_source);
}
if (receive_channel) {
g_io_channel_unref (receive_channel);
receive_channel = 0;

View File

@ -89,6 +89,14 @@ CrossThreadChannel::CrossThreadChannel (bool non_blocking)
CrossThreadChannel::~CrossThreadChannel ()
{
if (receive_source) {
/* this disconnects it from any main context it was attached in
in ::attach(), this prevent its callback from being invoked
after the destructor has finished.
*/
g_source_destroy (receive_source);
}
/* glibmm hack */
if (receive_channel) {