connection: Never call _dbus_condvar_wait_timeout() with negative timeout

Previously we were checking for -1 as the special-cased "block forever"
value, but as noted on dbus!524 it is a programming error to call
_dbus_condvar_wait_timeout() with any negative timeout.

Throughout DBusConnection the timeout is in fact constrained to be >= -1
(non-negative to have a timeout, or exactly -1 to block forever) but
checking for non-negative is presumably no more expensive than checking
for exactly -1, so let's be a little more defensive here, to make it
more obvious that we're doing this correctly.

This is the only caller of _dbus_condvar_wait_timeout() in our codebase.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2025-05-16 11:33:56 +01:00
parent cee059de0c
commit e3dcdc6227

View file

@ -1085,7 +1085,7 @@ _dbus_connection_acquire_io_path (DBusConnection *connection,
if (connection->io_path_acquired)
{
if (timeout_milliseconds != -1)
if (timeout_milliseconds >= 0)
{
_dbus_verbose ("waiting %d for IO path to be acquirable\n",
timeout_milliseconds);