eal/linux: fix return after alarm registration failure
authorThomas Monjalon <thomas@monjalon.net>
Wed, 26 Jun 2019 10:12:00 +0000 (12:12 +0200)
committerThomas Monjalon <thomas@monjalon.net>
Thu, 27 Jun 2019 15:25:05 +0000 (17:25 +0200)
When adding an alarm, if an error happen when registering
the common alarm callback, it is not considered as a major failure.
The alarm is then inserted in the list.
However it was returning an error code after inserting the alarm.

The error code is not set anymore to be consistent with the behaviour.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Reviewed-by: David Marchand <david.marchand@redhat.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_eal/linux/eal/eal_alarm.c

index 840ede7..0924c92 100644 (file)
@@ -137,9 +137,10 @@ rte_eal_alarm_set(uint64_t us, rte_eal_alarm_callback cb_fn, void *cb_arg)
 
        rte_spinlock_lock(&alarm_list_lk);
        if (!handler_registered) {
-               ret |= rte_intr_callback_register(&intr_handle,
-                               eal_alarm_callback, NULL);
-               handler_registered = (ret == 0) ? 1 : 0;
+               /* registration can fail, callback can be registered later */
+               if (rte_intr_callback_register(&intr_handle,
+                               eal_alarm_callback, NULL) == 0)
+                       handler_registered = 1;
        }
 
        if (LIST_EMPTY(&alarm_list))