mk: build with _GNU_SOURCE defined by default
[dpdk.git] / drivers / net / mlx5 / mlx5_socket.c
index 955306d..0010617 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  * Copyright 2016 6WIND S.A.
+ * Copyright 2016 Mellanox Technologies, Ltd
  */
 
-#define _GNU_SOURCE
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -33,8 +32,13 @@ mlx5_socket_init(struct rte_eth_dev *dev)
        };
        int ret;
        int flags;
-       struct stat file_stat;
 
+       /*
+        * Close the last socket that was used to communicate
+        * with the secondary process
+        */
+       if (priv->primary_socket)
+               mlx5_socket_uninit(dev);
        /*
         * Initialise the socket to communicate with the secondary
         * process.
@@ -59,9 +63,7 @@ mlx5_socket_init(struct rte_eth_dev *dev)
        }
        snprintf(sun.sun_path, sizeof(sun.sun_path), "/var/tmp/%s_%d",
                 MLX5_DRIVER_NAME, priv->primary_socket);
-       ret = stat(sun.sun_path, &file_stat);
-       if (!ret)
-               claim_zero(remove(sun.sun_path));
+       remove(sun.sun_path);
        ret = bind(priv->primary_socket, (const struct sockaddr *)&sun,
                   sizeof(sun));
        if (ret < 0) {
@@ -296,7 +298,7 @@ mlx5_socket_connect(struct rte_eth_dev *dev)
        }
        ret = *fd;
        close(socket_fd);
-       return 0;
+       return ret;
 error:
        if (socket_fd != -1)
                close(socket_fd);