return r;
assert_se(prioq_pop(nl->reply_callbacks_prioq) == c);
- c->timeout = 0;
hashmap_remove(nl->reply_callbacks, UINT32_TO_PTR(c->serial));
slot = container_of(c, sd_netlink_slot, reply_callback);
if (!c)
return 0;
- if (c->timeout != 0) {
+ if (c->timeout != USEC_INFINITY)
prioq_remove(nl->reply_callbacks_prioq, c, &c->prioq_idx);
- c->timeout = 0;
- }
r = sd_netlink_message_get_type(m, &type);
if (r < 0)
return r;
}
-static usec_t calc_elapse(uint64_t usec) {
- if (usec == UINT64_MAX)
- return 0;
-
+static usec_t timespan_to_timestamp(usec_t usec) {
if (usec == 0)
usec = NETLINK_DEFAULT_TIMEOUT_USEC;
static int timeout_compare(const void *a, const void *b) {
const struct reply_callback *x = a, *y = b;
- if (x->timeout != 0 && y->timeout == 0)
- return -1;
-
- if (x->timeout == 0 && y->timeout != 0)
- return 1;
-
return CMP(x->timeout, y->timeout);
}
return r;
slot->reply_callback.callback = callback;
- slot->reply_callback.timeout = calc_elapse(usec);
+ slot->reply_callback.timeout = timespan_to_timestamp(usec);
k = sd_netlink_send(nl, m, &slot->reply_callback.serial);
if (k < 0)
if (r < 0)
return r;
- if (slot->reply_callback.timeout != 0) {
+ if (slot->reply_callback.timeout != USEC_INFINITY) {
r = prioq_put(nl->reply_callbacks_prioq, &slot->reply_callback, &slot->reply_callback.prioq_idx);
if (r < 0) {
(void) hashmap_remove(nl->reply_callbacks, UINT32_TO_PTR(slot->reply_callback.serial));
assert_return(nl, -EINVAL);
assert_return(!netlink_pid_changed(nl), -ECHILD);
- timeout = calc_elapse(usec);
+ timeout = timespan_to_timestamp(usec);
for (;;) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL;
/* received message, so try to process straight away */
continue;
- if (timeout > 0) {
+ if (timeout != USEC_INFINITY) {
usec_t n;
n = now(CLOCK_MONOTONIC);