Philip Withnall
a434bfbb3d
gdbusnameowning: Fix race between connection shutdown and NameLost
...
As with all D-Bus signal subscriptions, it’s possible for a signal
callback to be invoked in one thread (T1) while another thread (T2) is
unsubscribing from that signal. In this case, T1 is the main thread, and
T2 is the D-Bus connection worker thread which is unsubscribing all
signals as it’s in the process of closing.
Due to this possibility, all `user_data` for signal callbacks needs to
be referenced outside the lifecycle of the code which
subscribes/unsubscribes the signal. In other words, it’s not safe to
subscribe to a signal, store the subscription ID in a struct,
unsubscribe from the signal when freeing the struct, and dereference the
struct in the signal callback. The data passed to the signal callback
has to have its own strong reference.
Instead, it’s safe to subscribe to a signal and add a strong reference
to the struct, store the subscription ID in that struct, and unsubscribe
from the signal when the last external reference to your struct is
dropped. That unsubscription should break the refcount cycle between the
signal connection and the struct, and allow the struct to be completely
freed. Only with that approach is it safe to dereference the struct in
the signal callback, if there’s any possibility that the signal might be
unsubscribed from a separate thread.
The tests need specific additional main loop cycles to completely emit
the NameLost signal callback. Ideally they need refactoring, but this
will do (1000 test cycles passed).
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Fixes : #978
2020-01-20 15:13:52 +00:00
..
2018-12-18 11:43:08 +01:00
2017-07-13 19:03:39 -04:00
2018-09-23 17:01:04 +01:00
2019-01-15 15:11:43 +00:00
2019-01-15 15:11:43 +00:00
2017-10-11 10:22:23 +01:00
2019-12-17 20:56:49 +08:00
2018-10-23 09:45:12 -04:00
2013-10-24 13:55:33 -04:00
2014-01-01 17:59:20 -05:00
2019-03-12 21:53:43 +03:00
2019-02-20 10:38:29 +00:00
2019-03-08 19:46:20 +00:00
2018-12-17 17:16:03 +00:00
2013-07-11 13:49:20 -04:00
2018-12-17 17:16:03 +00:00
2018-12-17 17:16:03 +00:00
2018-12-17 17:16:04 +00:00
2018-12-17 17:16:03 +00:00
2019-06-28 13:05:07 +01:00
2019-06-28 13:05:07 +01:00
2018-12-17 17:16:04 +00:00
2014-09-09 14:11:38 -04:00
2015-08-31 13:59:48 -04:00
2013-09-29 17:48:40 -04:00
2019-02-13 08:49:42 +00:00
2014-01-01 22:01:15 -05:00
2013-12-15 21:07:12 -05:00
2019-11-25 12:55:18 +01:00
2020-01-15 09:37:41 -08:00
2019-06-03 12:16:50 +01:00
2016-04-26 15:20:16 +02:00
2015-08-31 13:59:48 -04:00
2014-06-28 14:06:36 -04:00
2018-02-16 17:38:26 +00:00
2018-09-04 20:24:25 +02:00
2019-12-17 21:03:03 +08:00
2019-03-12 21:53:43 +03:00
2019-10-26 14:06:31 +01:00
2019-04-26 12:12:31 +01:00
2020-01-07 11:20:45 +00:00
2019-11-21 10:49:31 +00:00
2018-04-26 15:19:17 +01:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2019-12-04 14:06:23 +01:00
2019-09-05 17:13:08 +01:00
2015-05-11 20:24:56 +01:00
2018-09-13 13:16:40 +02:00
2018-01-03 11:08:37 +00:00
2019-04-25 09:25:49 +01:00
2019-03-12 21:54:47 +03:00
2019-10-08 13:53:01 +01:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2019-12-11 11:04:10 +01:00
2019-07-03 20:28:36 -07:00
2018-04-27 16:46:19 +01:00
2019-12-11 11:04:10 +01:00
2017-05-29 19:53:34 +02:00
2017-04-10 10:38:31 +01:00
2018-10-04 10:45:45 +02:00
2018-10-04 10:45:45 +02:00
2019-06-11 11:06:36 +01:00
2017-04-10 10:38:31 +01:00
2018-07-09 13:28:02 +02:00
2017-05-29 19:53:34 +02:00
2019-12-18 16:39:56 +00:00
2017-05-29 19:53:34 +02:00
2019-01-28 14:37:22 +00:00
2020-01-20 15:13:52 +00:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2018-06-29 12:13:32 +01:00
2019-11-04 13:31:14 +00:00
2017-05-29 19:53:34 +02:00
2018-11-10 03:53:32 +00:00
2017-05-29 19:53:34 +02:00
2019-03-07 13:57:38 +00:00
2019-11-18 17:53:55 +00:00
2019-12-11 11:04:10 +01:00
2019-12-17 20:56:49 +08:00
2017-05-29 19:53:34 +02:00
2020-01-15 09:37:41 -08:00
2019-12-17 20:56:49 +08:00
2018-09-12 15:42:11 +00:00
2017-05-29 19:53:34 +02:00
2019-03-07 13:57:38 +00:00
2019-09-21 10:48:23 +02:00
2018-12-05 18:27:16 +08:00
2018-05-22 14:34:17 +05:30
2015-07-23 04:22:59 -04:00
2019-07-15 11:01:04 +00:00
2019-09-25 08:37:22 +02:00
2019-03-05 15:14:58 +01:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2018-08-19 20:04:41 +02:00
2019-01-15 15:11:43 +00:00
2019-08-21 20:08:04 +03:00
2019-02-27 09:20:28 -05:00
2018-12-19 14:54:27 +00:00
2019-05-31 23:35:27 +01:00
2019-10-02 10:12:40 -07:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2017-09-11 22:14:18 +01:00
2016-07-11 17:42:41 -04:00
2015-02-17 16:27:46 -05:00
2019-10-30 15:19:34 +00:00
2019-12-11 11:44:42 +00:00
2019-12-11 11:44:42 +00:00
2019-12-11 11:44:42 +00:00
2019-01-24 16:25:56 +02:00
2020-01-15 18:04:14 +00:00
2018-12-17 17:16:04 +00:00
2019-10-10 14:32:18 +01:00
2018-12-11 16:09:29 -05:00
2018-06-21 15:32:04 +02:00
2019-10-10 14:32:18 +01:00
2018-09-13 11:44:16 +01:00
2018-04-10 10:35:45 +01:00
2013-07-14 11:36:45 -04:00
2019-12-17 20:59:22 +08:00
2018-06-22 22:02:31 +03:00
2018-06-22 22:02:31 +03:00
2018-12-14 17:07:22 +01:00
2018-12-11 16:09:29 -05:00
2017-05-29 19:53:34 +02:00
2018-09-12 15:42:11 +00:00
2019-04-26 12:12:31 +01:00
2019-06-24 10:58:51 +08:00
2019-07-15 11:01:04 +00:00
2019-07-29 12:27:29 +01:00
2017-05-29 19:53:34 +02:00
2018-06-29 12:13:32 +01:00
2018-09-04 20:24:25 +02:00
2018-12-11 16:12:48 -05:00
2015-10-13 15:42:14 +01:00
2019-04-25 09:25:49 +01:00
2017-05-29 19:53:34 +02:00
2019-04-25 09:25:49 +01:00
2019-02-21 18:15:49 +00:00
2020-01-07 15:07:37 +00:00
2019-12-04 14:06:23 +01:00
2017-05-29 19:53:34 +02:00
2019-12-02 14:27:11 +00:00
2019-11-15 10:37:42 +00:00
2019-01-10 13:50:26 -05:00
2018-12-05 18:27:16 +08:00
2018-12-19 16:43:21 +00:00
2019-09-02 20:47:20 +01:00
2017-05-29 19:53:34 +02:00
2017-05-29 19:53:34 +02:00
2017-11-29 17:50:27 +00:00
2017-05-29 19:53:34 +02:00
2016-06-04 08:24:22 -04:00
2019-10-18 17:02:57 +01:00
2015-04-22 18:56:50 +08:00
2019-10-02 10:12:40 -07:00
2018-09-03 13:55:57 +10:00
2019-07-25 15:23:21 +01:00
2019-01-17 16:31:10 +00:00
2018-06-20 12:16:34 +01:00
2019-01-24 16:26:05 +02:00
2016-06-28 15:57:49 +02:00
2020-01-15 18:04:14 +00:00
2014-08-02 12:41:14 +00:00