This member is written in _g_dbus_worker_stop from arbitrary threads, and
read by the worker thread, so it should be accessed atomically.
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=651268
Bug-NB: NB#271520
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Signed-off-by: David Zeuthen <davidz@redhat.com>
SharedThreadData *shared_thread_data;
SharedThreadData *shared_thread_data;
+ /* really a boolean, but GLib 2.28 lacks atomic boolean ops */
+ volatile gint stopped;
/* TODO: frozen (e.g. G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING) currently
* only affects messages received from the other peer (since GDBusServer is the
/* TODO: frozen (e.g. G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING) currently
* only affects messages received from the other peer (since GDBusServer is the
gboolean remote_peer_vanished,
GError *error)
{
gboolean remote_peer_vanished,
GError *error)
{
+ if (!g_atomic_int_get (&worker->stopped))
worker->disconnected_callback (worker, remote_peer_vanished, error, worker->user_data);
}
worker->disconnected_callback (worker, remote_peer_vanished, error, worker->user_data);
}
_g_dbus_worker_emit_message_received (GDBusWorker *worker,
GDBusMessage *message)
{
_g_dbus_worker_emit_message_received (GDBusWorker *worker,
GDBusMessage *message)
{
+ if (!g_atomic_int_get (&worker->stopped))
worker->message_received_callback (worker, message, worker->user_data);
}
worker->message_received_callback (worker, message, worker->user_data);
}
GDBusMessage *message)
{
GDBusMessage *ret;
GDBusMessage *message)
{
GDBusMessage *ret;
+ if (!g_atomic_int_get (&worker->stopped))
ret = worker->message_about_to_be_sent_callback (worker, message, worker->user_data);
else
ret = message;
ret = worker->message_about_to_be_sent_callback (worker, message, worker->user_data);
else
ret = message;
g_mutex_lock (worker->read_lock);
/* If already stopped, don't even process the reply */
g_mutex_lock (worker->read_lock);
/* If already stopped, don't even process the reply */
+ if (g_atomic_int_get (&worker->stopped))
void
_g_dbus_worker_stop (GDBusWorker *worker)
{
void
_g_dbus_worker_stop (GDBusWorker *worker)
{
- worker->stopped = TRUE;
+ g_atomic_int_set (&worker->stopped, TRUE);
/* Cancel any pending operations and schedule a close of the underlying I/O
* stream in the worker thread
/* Cancel any pending operations and schedule a close of the underlying I/O
* stream in the worker thread