summaryrefslogtreecommitdiff
path: root/dbus/dbus-sysdeps-pthread.c
Commit message (Collapse)AuthorAgeFilesLines
* Add SPDX license marker for the AFL-2.1 OR GPL-2.0-or-later licenseRalf Habacker2023-01-041-0/+2
| | | | | | | | | The full license texts are not added because they were already added in a previous commit. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> see #394
* trivial: Remove trailing whitespace from copyright noticesSimon McVittie2018-12-171-3/+3
| | | | | | | | | | | | | | We don't usually mass-remove trailing whitespace from the actual source code because it would complicate cherry-picking bug fixes to older branches, but that reasoning doesn't really apply to the comments containing copyright and licensing notices. Removing trailing whitespace makes it much easier to move code around: we have a commit hook that rejects commits containing trailing whitespace, but that commit hook counts moving a file as a delete + add pair, so it objects to moving code that contains trailing whitespace. Signed-off-by: Simon McVittie <smcv@collabora.com>
* Remove trailing newlines from _dbus_warn, _dbus_warn_check_failedSimon McVittie2016-09-301-1/+1
| | | | | | | They used to be needed, but are not needed any more, and we were never completely consistent about including them in any case. Signed-off-by: Simon McVittie <smcv@debian.org>
* Display thread id in _dbus_verbose to be able to see threading issues.Ralf Habacker2016-05-131-0/+18
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=95191 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* Revert "Add a statically-initialized implementation of _dbus_lock() on glibc ↵Simon McVittie2013-08-301-47/+0
| | | | | | | | | | systems" This reverts commit 83aaa9f359e90d3b8cae5d17f6d9ba4600cff68b. This wasn't right: because it looked for a symbol from pthread.h, modules could end up disagreeing about whether threading was enabled or not.
* Add a statically-initialized implementation of _dbus_lock() on glibc systemsSimon McVittie2013-06-171-0/+47
| | | | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk> Reviewed-by: Anas Nashif <anas.nashif@intel.com>
* dbus_threads_init_default, dbus_threads_init: be safe to call at any timeSimon McVittie2013-05-101-0/+14
| | | | | | | | | | | | | | On Unix, we use a pthreads mutex, which can be allocated and initialized in global memory. On Windows, we use a CRITICAL_SECTION, together with a call to InitializeCriticalSection() from the constructor of a global static C++ object (thanks to Ralf Habacker for suggesting this approach). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus_threads_init: call _dbus_threads_init_platform_specific()Simon McVittie2013-05-091-1/+2
| | | | | | | | | | | | This reverses the relationship between these two functions. Previously, dbus_threads_init() wouldn't allocate dbus_cond_event_tls on Windows, call check_monotonic_clock on Unix, or call _dbus_check_setuid on Unix. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Alban Crequy <alban.crequy@collabora.co.uk> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
* dbus-sysdeps-pthread.c: don't fail if !HAVE_MONOTONIC_CLOCK under -Werror=unusedSimon McVittie2012-11-191-0/+2
| | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=47239
* hardening: Ensure _dbus_check_setuid() is initialized threadsafe mannerColin Walters2012-09-281-0/+5
| | | | | | This is a highly theoretical concern, but we might as well. https://bugs.freedesktop.org/show_bug.cgi?id=52202
* Remove _dbus_condvar_wake_all and both of its implementationsSimon McVittie2012-02-211-6/+0
| | | | | | | | Neither was used, and the Windows version could lead to live-locks. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43744 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=44609 Reviewed-by: Thiago Macieira <thiago@kde.org>
* Never use non-libdbus threading primitivesSimon McVittie2012-02-211-99/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lets us simplify considerably, by assuming that we always have both recursive and suitable-for-condition-variable mutexes. The Windows implementation has been compiled (on 32-bit mingw-w64) but not tested. Justification for the approach used on Windows, and in particular, using the existing "non-recursive" locks as if they were recursive: * We've been using them in conjunction with condition variables all along, so they'd better be suitable * On fd.o #36204, Ralf points out that mutexes created via CreateMutex are, in fact, recursive * Havoc's admonitions about requiring "Java-style" recursive locking (waiting for a condition variable while holding a recursive lock requires releasing that lock n times) turn out not to apply to either of our uses of DBusCondVar in DBusConnection, because the lock is only held for a short time, without calling into user code; indeed, our Unix implementation isn't recursive anyway, so if the Windows implementation reaches the deadlocking situation somehow (waiting for condition variable while locked more than once), the Unix implementation would already have deadlocked on the same code path (trying to lock more than once) One possible alternative to a CreateMutex mutex for use with condition variables would be a CRITICAL_SECTION. I'm not going to implement this, but Windows developers are welcome to do so. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=36204 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43744 Reviewed-by: Thiago Macieira <thiago@kde.org>
* Use actual recursive pthreads mutexes, rather than NIH'ing them, wrongSimon McVittie2012-02-211-99/+50
| | | | | | | | | | | | | | | Very loosely based on a patch from Sigmund Augdal. For the moment, we make PTHREAD_MUTEX_RECURSIVE a hard requirement: it's required by POSIX 2008 Base and SUSv2. If your (non-Windows) platform doesn't have PTHREAD_MUTEX_RECURSIVE, please report a bug on freedesktop.org bugzilla with details of the platform in question. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=43744 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Thiago Macieira <thiago@kde.org>
* Consistently include <config.h> in all C source files and never in header files.Marcus Brinkmann2010-03-191-0/+1
|
* Bug 18121 - Use a monotonic clock for pthread timeoutsColin Walters2009-07-101-2/+41
| | | | | | | | Patch based on one from Keith Mok <ek9852@gmail.com>, some followup work from Janne Karhunen <Janne.Karhunen@gmail.com>. We don't want condition variable timeouts to be affected by the system clock. Use the POSIX CLOCK_MONOTONIC if available.
* Bug 21161 - Update the FSF addressTobias Mueller2009-07-101-1/+1
| | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org>
* 2007-07-13 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-07-141-1/+1
| | | | * Add indent-tabs-mode: nil to all file headers.
* 2007-06-15 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-06-151-0/+4
| | | | | | | | | | | | | | * dbus/dbus-sysdeps.c (_dbus_set_errno_to_zero) (_dbus_get_is_errno_nonzero, _dbus_get_is_errno_eintr) (_dbus_strerror_from_errno): family of functions to abstract errno, though these are somewhat bogus (really we should make our socket wrappers not use errno probably - the issue is that any usage of errno that isn't socket-related probably is not cross-platform, so should either be in a unix-only file that can use errno directly, or is a bug - these general errno wrappers hide issues of this nature in non-socket code, while socket-specific API changes would not since sockets are allowed cross-platform)
* * dbus/dbus-sysdeps-pthread.c (_dbus_pthread_mutex_lock,Thiago Macieira2006-11-191-1/+4
| | | | | | | | _dbus_pthread_condvar_wait, _dbus_pthread_condvar_wait_timeout): set pmutex->holder to pthread_self() after coming back from a conditional variable wait as well as in one codepath where it was forgotten. Approved by: Havoc Pennington.
* 2006-10-27 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-281-2/+3
| | | | | | | | | | | | | | | | | | | | | * dbus/dbus-test.c: enclose more of the file in the DBUS_BUILD_TESTS check. * dbus/dbus-sysdeps-pthread.c (PTHREAD_CHECK): fix for DBUS_DISABLE_ASSERT case. * dbus/dbus-connection.c (dbus_connection_get_unix_user): document that it only works on the server side * dbus/dbus-bus.c: add a global lock covering the BusData we attach to each connection (internal_bus_get): lock our access to the BusData (dbus_bus_register): lock the entire registration process with _DBUS_LOCK(bus_datas). If we get the lock and registration is already complete, silently return (vs. previous behavior of aborting). (dbus_bus_set_unique_name): lock the BusData (dbus_bus_get_unique_name): lock the BusData
* 2006-10-27 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-271-9/+19
| | | | | | | | * dbus/dbus-sysdeps-pthread.c: make the "count" and "holder" variables volatile, suggested by Thiago. Document struct fields. (PTHREAD_CHECK): remove pthread error checking if assertions are disabled, should reduce the no-assertions case to the bare minimum code.
* 2006-10-26 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-271-18/+93
| | | | | | | | * dbus/dbus-sysdeps-pthread.c (_dbus_pthread_mutex_lock): change to be recursive (_dbus_pthread_mutex_unlock): make it recursive (_dbus_pthread_condvar_wait): save/restore the recursion count (_dbus_pthread_condvar_wait_timeout): save/restore the recursion count
* 2006-10-26 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-271-32/+96
| | | | | | | | | * doc/dbus-specification.xml: clarify the UUID text slightly * dbus/dbus-sysdeps-pthread.c: check for and mostly abort on pthread errors. Add DBusMutexPThread and DBusCondVarPThread in preparation for being able to extend them for e.g. recursive mutexes.
* 2006-10-26 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-271-0/+167
* dbus/dbus-threads.[hc]: Documentation improvements. Clarify how condition variables relate to recursive mutexes. * dbus/dbus-sysdeps-pthread.c, dbus/dbus-sysdeps-win-thread.c, dbus/dbus-threads.c: Split the platforms-specific thread implementations into their own files. * dbus/dbus-sysdeps-pthread.c (_dbus_pthread_condvar_wait_timeout): invert the return value, it was backward. Not that anything uses it.