mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-02 15:27:59 +02:00
threads: Assert that timeout is non-negative
As noted in dbus!524 by source code inspection, the Unix/pthread implementation assumes that the timeout is non-negative and does not support a mode where it blocks forever (which we normally represent as a negative timeout, like POSIX poll(2)). This means that it would be a programming error if we ever call this with a negative timeout, so put an equivalent assertion in the platform-independent layer. We recommend that assertions are disabled in production builds, so it's "cheap" to have a redundant assertion here. Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
parent
626ae07151
commit
cee059de0c
1 changed files with 3 additions and 1 deletions
|
|
@ -257,7 +257,7 @@ _dbus_condvar_wait (DBusCondVar *cond,
|
|||
*
|
||||
* @param cond the condition variable
|
||||
* @param mutex the mutex
|
||||
* @param timeout_milliseconds the maximum time to wait
|
||||
* @param timeout_milliseconds the maximum time to wait, must be non-negative
|
||||
* @returns #FALSE if the timeout occurred, #TRUE if not
|
||||
*/
|
||||
dbus_bool_t
|
||||
|
|
@ -265,6 +265,8 @@ _dbus_condvar_wait_timeout (DBusCondVar *cond,
|
|||
DBusCMutex *mutex,
|
||||
int timeout_milliseconds)
|
||||
{
|
||||
_dbus_assert (timeout_milliseconds >= 0);
|
||||
|
||||
if (cond == NULL || mutex == NULL)
|
||||
return TRUE;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue