Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • D dbus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 247
    • Issues 247
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 34
    • Merge requests 34
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • dbus
  • dbus
  • Issues
  • #370

Closed
Open
Created Dec 20, 2021 by Ralf Habacker@rhabackerMaintainer

Multiple implementation of thread locks in Windows code

In the dbus Windows code there is

_dbus_win_startup_winsock (void)
{
...
  if (!_DBUS_LOCK (sysdeps))
    return FALSE;
...

and for example

dbus_bool_t
_dbus_daemon_is_session_bus_address_published()
...
lock = _dbus_global_lock (...);
...

Looking at the two implementations, it turned out that DBUS_LOCK() uses _dbus_lock(), which is based on _dbus_platform_rmutex_lock(), which uses WaitForSingleObject(). _dbus_global_lock() also uses WaitForSingleObject().

The main differences are that _dbus_global_lock() creates a named mutex for sharing the mutex between processes, uses a different return type and evaluates the results of WaitForSingleObject somehow.

I propose to integrate _dbus_global_lock()/_dbus_global_unlock() into the current _dbus_platform_rmutex_xxx functions, adjust the implementation (including #369 (closed)), create a new function for generating the named mutex e.g. _dbus_platform_rmutex_named_new (const char* name) as:

DBusRMutex *
_dbus_platform_rmutex_named_new (const char* name)
{
  HANDLE handle;
  handle = CreateMutex (NULL, FALSE, name);
  return (DBusRMutex *) handle;
}

and use that (and related) functions in the autolaunch related Windows code, to reduce this code duplication and future maintenance overhead.

Assignee
Assign to
Time tracking