Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 861
    • Issues 861
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 39
    • Merge requests 39
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !2764

GCancellable: Ensure it is always cancelled on connect callback

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Marco Trevisan requested to merge 3v1n0/glib:fix-cancellable-connect-race into main Jun 21, 2022
  • Overview 8
  • Commits 1
  • Pipelines 6
  • Changes 2

When a cancellable is cancelled when we call g_cancellable_connect we used to immediately call the provided callback, while this is fine we actually had race in case the cancellable was about to be reset or in the middle of a cancellation.

In fact it could happen that when we released the mutex, another thread could reset the cancellable just before the callback is actually called and so leading to call it with g_cancellable_cancelled() == FALSE.

So to handle this, make disconnect and reset function to wait for connection emission to finish, not to break their assumptions.

This can be tested using some "brute-force" tests where multiple threads are racing to connect and disconnect while others are cancelling and resetting a cancellable, ensuring that all works as we expect.


We're coming from !2759 (diffs, comment 1483096)

Edited Jun 21, 2022 by Marco Trevisan
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: fix-cancellable-connect-race