openbsd-ports/x11/dbus/patches/patch-dbus_dbus-connection_c
2011-09-09 09:00:25 +00:00

78 lines
3.6 KiB
Plaintext

$OpenBSD: patch-dbus_dbus-connection_c,v 1.9 2011/09/09 09:00:25 ajacoutot Exp $
From FreeBSD:
Linux is more relaxed when it comes to the timeout argument to poll(2).
Linux will accept aby negative number to mean an infinite timeout.
OpenBSD will only accept INFTIM (-1). Make sure we do not pass an
arbitrary negative number to poll(2) to avoid an infinite EINVAL loop.
--- dbus/dbus-connection.c.orig Fri Jul 29 15:03:47 2011
+++ dbus/dbus-connection.c Fri Sep 9 10:51:13 2011
@@ -2356,7 +2356,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
DBusConnection *connection;
dbus_uint32_t client_serial;
DBusTimeout *timeout;
- int timeout_milliseconds, elapsed_milliseconds;
+ int timeout_milliseconds, elapsed_milliseconds, remain_milliseconds;
_dbus_assert (pending != NULL);
@@ -2437,7 +2437,11 @@ _dbus_connection_block_pending_call (DBusPendingCall *
_dbus_get_current_time (&tv_sec, &tv_usec);
elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 +
(tv_usec - start_tv_usec) / 1000;
-
+ if (timeout_milliseconds != -1)
+ remain_milliseconds = timeout_milliseconds - elapsed_milliseconds;
+ else
+ remain_milliseconds = -1;
+
if (!_dbus_connection_get_is_connected_unlocked (connection))
{
DBusMessage *error_msg;
@@ -2463,7 +2467,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
*/
_dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n");
- _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds);
+ _dbus_memory_pause_based_on_timeout (remain_milliseconds);
}
else
{
@@ -2472,7 +2476,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
pending,
DBUS_ITERATION_DO_READING |
DBUS_ITERATION_BLOCK,
- timeout_milliseconds - elapsed_milliseconds);
+ remain_milliseconds);
}
goto recheck_status;
@@ -2481,7 +2485,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
_dbus_verbose ("dbus_connection_send_with_reply_and_block(): clock set backward\n");
else if (elapsed_milliseconds < timeout_milliseconds)
{
- _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", timeout_milliseconds - elapsed_milliseconds);
+ _dbus_verbose ("dbus_connection_send_with_reply_and_block(): %d milliseconds remain\n", remain_milliseconds);
if (status == DBUS_DISPATCH_NEED_MEMORY)
{
@@ -2491,7 +2495,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
*/
_dbus_verbose ("dbus_connection_send_with_reply_and_block() waiting for more memory\n");
- _dbus_memory_pause_based_on_timeout (timeout_milliseconds - elapsed_milliseconds);
+ _dbus_memory_pause_based_on_timeout (remain_milliseconds);
}
else
{
@@ -2500,7 +2504,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *
NULL,
DBUS_ITERATION_DO_READING |
DBUS_ITERATION_BLOCK,
- timeout_milliseconds - elapsed_milliseconds);
+ remain_milliseconds);
}
goto recheck_status;