eal: switch to architecture specific pause function
[dpdk.git] / lib / librte_distributor / rte_distributor.c
index 06df13d..32dd18e 100644 (file)
@@ -42,6 +42,8 @@
 #include <rte_string_fns.h>
 #include <rte_eal_memconfig.h>
 #include <rte_compat.h>
+#include <rte_pause.h>
+
 #include "rte_distributor_private.h"
 #include "rte_distributor.h"
 #include "rte_distributor_v20.h"
@@ -555,7 +557,7 @@ total_outstanding(const struct rte_distributor *d)
 int
 rte_distributor_flush_v1705(struct rte_distributor *d)
 {
-       const unsigned int flushed = total_outstanding(d);
+       unsigned int flushed;
        unsigned int wkr;
 
        if (d->alg_type == RTE_DIST_ALG_SINGLE) {
@@ -563,6 +565,8 @@ rte_distributor_flush_v1705(struct rte_distributor *d)
                return rte_distributor_flush_v20(d->d_v20);
        }
 
+       flushed = total_outstanding(d);
+
        while (total_outstanding(d) > 0)
                rte_distributor_process(d, NULL, 0);
 
@@ -590,6 +594,7 @@ rte_distributor_clear_returns_v1705(struct rte_distributor *d)
        if (d->alg_type == RTE_DIST_ALG_SINGLE) {
                /* Call the old API */
                rte_distributor_clear_returns_v20(d->d_v20);
+               return;
        }
 
        /* throw away returns, so workers can exit */
@@ -621,9 +626,14 @@ rte_distributor_create_v1705(const char *name,
 
        if (alg_type == RTE_DIST_ALG_SINGLE) {
                d = malloc(sizeof(struct rte_distributor));
+               if (d == NULL) {
+                       rte_errno = ENOMEM;
+                       return NULL;
+               }
                d->d_v20 = rte_distributor_create_v20(name,
                                socket_id, num_workers);
                if (d->d_v20 == NULL) {
+                       free(d);
                        /* rte_errno will have been set */
                        return NULL;
                }