]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
connection: Never call _dbus_condvar_wait_timeout() with negative timeout
authorSimon McVittie <smcv@collabora.com>
Fri, 16 May 2025 10:33:56 +0000 (11:33 +0100)
committerSimon McVittie <smcv@collabora.com>
Fri, 23 May 2025 10:36:33 +0000 (10:36 +0000)
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>
dbus/dbus-connection.c

index 292275363bc4eb11cd916e6dcfedc52ff27be647..8c564deb4dc72043ad64b19c9062284866fa9494 100644 (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);