gcancellable: Make g_cancellable_is_cancelled() thread safe
Submitted by Philip Withnall
I realise g_cancellable_is_cancelled() is somewhat of an opportunistic function, but without locking it might be possible for two threads to see inconsistent states of a shared GCancellable if the cancelled state is transmitted out-of-band between them (so that the thread calling g_cancellable_is_cancelled() never takes the cancellable_mutex while checking, but knows from this OOB mechanism that the GCancellable is supposed to be cancelled).
That said, this is just a theoretical failure, and I haven’t seen it cause problems in practice. So I guess either the attached patch should be applied, or a comment should be added explaining why g_cancellable_is_cancelled() doesn’t need any locking.