mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-23 16:10:03 +01:00
Merge branch 'backport-1158-dbus-race-glib-2-62' into 'glib-2-62'
Backport !1158 “Fix use-after-free when calling g_dbus_connection_flush_sync()” to glib-2-62 See merge request GNOME/glib!1162
This commit is contained in:
commit
9191ab92f6
@ -408,6 +408,7 @@ typedef struct
|
|||||||
GMutex mutex;
|
GMutex mutex;
|
||||||
GCond cond;
|
GCond cond;
|
||||||
guint64 number_to_wait_for;
|
guint64 number_to_wait_for;
|
||||||
|
gboolean finished;
|
||||||
GError *error;
|
GError *error;
|
||||||
} FlushData;
|
} FlushData;
|
||||||
|
|
||||||
@ -1158,6 +1159,7 @@ flush_data_list_complete (const GList *flushers,
|
|||||||
f->error = error != NULL ? g_error_copy (error) : NULL;
|
f->error = error != NULL ? g_error_copy (error) : NULL;
|
||||||
|
|
||||||
g_mutex_lock (&f->mutex);
|
g_mutex_lock (&f->mutex);
|
||||||
|
f->finished = TRUE;
|
||||||
g_cond_signal (&f->cond);
|
g_cond_signal (&f->cond);
|
||||||
g_mutex_unlock (&f->mutex);
|
g_mutex_unlock (&f->mutex);
|
||||||
}
|
}
|
||||||
@ -1787,6 +1789,7 @@ _g_dbus_worker_flush_sync (GDBusWorker *worker,
|
|||||||
g_mutex_init (&data->mutex);
|
g_mutex_init (&data->mutex);
|
||||||
g_cond_init (&data->cond);
|
g_cond_init (&data->cond);
|
||||||
data->number_to_wait_for = worker->write_num_messages_written + pending_writes;
|
data->number_to_wait_for = worker->write_num_messages_written + pending_writes;
|
||||||
|
data->finished = FALSE;
|
||||||
g_mutex_lock (&data->mutex);
|
g_mutex_lock (&data->mutex);
|
||||||
|
|
||||||
schedule_writing_unlocked (worker, NULL, data, NULL);
|
schedule_writing_unlocked (worker, NULL, data, NULL);
|
||||||
@ -1796,14 +1799,10 @@ _g_dbus_worker_flush_sync (GDBusWorker *worker,
|
|||||||
if (data != NULL)
|
if (data != NULL)
|
||||||
{
|
{
|
||||||
/* Wait for flush operations to finish. */
|
/* Wait for flush operations to finish. */
|
||||||
g_mutex_lock (&worker->write_lock);
|
while (!data->finished)
|
||||||
while (worker->write_num_messages_flushed < data->number_to_wait_for)
|
|
||||||
{
|
{
|
||||||
g_mutex_unlock (&worker->write_lock);
|
|
||||||
g_cond_wait (&data->cond, &data->mutex);
|
g_cond_wait (&data->cond, &data->mutex);
|
||||||
g_mutex_lock (&worker->write_lock);
|
|
||||||
}
|
}
|
||||||
g_mutex_unlock (&worker->write_lock);
|
|
||||||
|
|
||||||
g_mutex_unlock (&data->mutex);
|
g_mutex_unlock (&data->mutex);
|
||||||
g_cond_clear (&data->cond);
|
g_cond_clear (&data->cond);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user