GNOME Bugzilla – Bug 586797
Add GCancellables to GSocket ops
Last modified: 2009-07-07 08:49:48 UTC
Currently, to implement cancellability correctly, all synchronous calls to GSocket must be preceded by a g_socket_condition_wait() call, (even though GSocket does this internally as well) and all asynchronous calls must do occasional manual g_cancellable_is_cancelled() checks. Since it's trivial to do these checks inside GSocket instead, and we don't particularly want to encourage people to use the APIs non-cancellably, move the cancellation support into GSocket and simplify the existing callers.
Created attachment 137276 [details] [review] Add GCancellables to GSocket ops
messed up with git bz a bit and lost part of the first comment... It made some sense to not have cancellables in the GSocket API initially, what with the whole "very thin wrapper over sockets" philosophy. But given that all the blocking GSocket operations now call g_socket_condition_wait() internally, it's basically just cruel to force the apps to call it themselves before calling the op as well. And some places weren't bothering (like the g_socket_connect() calls in GSocketClient, so those became non-cancellable in the synchronous version). Also, this makes it totally clear which operations can block and which ones can't.
even though i nak:ed a similar change I must say that this patch looks pretty minimal and has clear advantages, please commit.
committed with minor updates for recent gio changes
*** Bug 585905 has been marked as a duplicate of this bug. ***