mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-05 12:18:13 +02:00
Don't allocate DBusTimeout for pending call when passed INT_MAX
* dbus/dbus-pending-call.c (_dbus_pending_call_new_unlocked): When passed INT_MAX, do not clamp the value and do not allocate a timeout for the call (_dbus_pending_call_get_timeout_unlocked): Document that this may return NULL. Signed-off-by: Scott James Remnant <scott@ubuntu.com>
This commit is contained in:
parent
e5eb472d11
commit
92dd55c903
1 changed files with 24 additions and 19 deletions
|
|
@ -83,7 +83,7 @@ static dbus_int32_t notify_user_data_slot = -1;
|
|||
* Creates a new pending reply object.
|
||||
*
|
||||
* @param connection connection where reply will arrive
|
||||
* @param timeout_milliseconds length of timeout, -1 for default
|
||||
* @param timeout_milliseconds length of timeout, -1 for default, INT_MAX for no timeout
|
||||
* @param timeout_handler timeout handler, takes pending call as data
|
||||
* @returns a new #DBusPendingCall or #NULL if no memory.
|
||||
*/
|
||||
|
|
@ -100,12 +100,11 @@ _dbus_pending_call_new_unlocked (DBusConnection *connection,
|
|||
if (timeout_milliseconds == -1)
|
||||
timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;
|
||||
|
||||
/* it would probably seem logical to pass in _DBUS_INT_MAX for
|
||||
* infinite timeout, but then math in
|
||||
* _dbus_connection_block_for_reply would get all overflow-prone, so
|
||||
* smack that down.
|
||||
/* clamp the timeout otherwise math in
|
||||
* _dbus_connection_block_for_reply would get all overflow-prone
|
||||
*/
|
||||
if (timeout_milliseconds > _DBUS_ONE_HOUR_IN_MILLISECONDS * 6)
|
||||
if ((timeout_milliseconds > _DBUS_ONE_HOUR_IN_MILLISECONDS * 6) &&
|
||||
(timeout_milliseconds < _DBUS_INT_MAX))
|
||||
timeout_milliseconds = _DBUS_ONE_HOUR_IN_MILLISECONDS * 6;
|
||||
|
||||
if (!dbus_pending_call_allocate_data_slot (¬ify_user_data_slot))
|
||||
|
|
@ -119,24 +118,30 @@ _dbus_pending_call_new_unlocked (DBusConnection *connection,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
timeout = _dbus_timeout_new (timeout_milliseconds,
|
||||
timeout_handler,
|
||||
pending, NULL);
|
||||
|
||||
if (timeout == NULL)
|
||||
if (timeout_milliseconds != _DBUS_INT_MAX)
|
||||
{
|
||||
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
|
||||
dbus_free (pending);
|
||||
return NULL;
|
||||
timeout = _dbus_timeout_new (timeout_milliseconds,
|
||||
timeout_handler,
|
||||
pending, NULL);
|
||||
|
||||
if (timeout == NULL)
|
||||
{
|
||||
dbus_pending_call_free_data_slot (¬ify_user_data_slot);
|
||||
dbus_free (pending);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pending->timeout = timeout;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
pending->timeout = NULL;
|
||||
}
|
||||
|
||||
pending->refcount.value = 1;
|
||||
pending->connection = connection;
|
||||
_dbus_connection_ref_unlocked (pending->connection);
|
||||
|
||||
pending->timeout = timeout;
|
||||
|
||||
|
||||
_dbus_data_slot_list_init (&pending->slot_list);
|
||||
|
||||
return pending;
|
||||
|
|
@ -255,7 +260,7 @@ _dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
|
|||
* Retrives the timeout
|
||||
*
|
||||
* @param pending the pending_call
|
||||
* @returns a timeout object
|
||||
* @returns a timeout object or NULL if call has no timeout
|
||||
*/
|
||||
DBusTimeout *
|
||||
_dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue