event/dlb2: add dynamic logging
[dpdk.git] / lib / librte_telemetry / telemetry_legacy.c
index 2de9021..edd76ca 100644 (file)
@@ -2,10 +2,12 @@
  * Copyright(c) 2020 Intel Corporation
  */
 
+#ifndef RTE_EXEC_ENV_WINDOWS
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <pthread.h>
+#endif /* !RTE_EXEC_ENV_WINDOWS */
 
 /* we won't link against libbsd, so just always use DPDKs-specific strlcpy */
 #undef RTE_USE_LIBBSD
@@ -77,15 +79,18 @@ static int
 register_client(const char *cmd __rte_unused, const char *params,
                char *buffer __rte_unused, int buf_len __rte_unused)
 {
+#ifndef RTE_EXEC_ENV_WINDOWS
        pthread_t th;
        char data[BUF_SIZE];
        int fd;
        struct sockaddr_un addrs;
+#endif /* !RTE_EXEC_ENV_WINDOWS */
 
        if (!strchr(params, ':')) {
                fprintf(stderr, "Invalid data\n");
                return -1;
        }
+#ifndef RTE_EXEC_ENV_WINDOWS
        strlcpy(data, strchr(params, ':'), sizeof(data));
        memcpy(data, &data[strlen(":\"")], strlen(data));
        if (!strchr(data, '\"')) {
@@ -109,9 +114,12 @@ register_client(const char *cmd __rte_unused, const char *params,
        }
        pthread_create(&th, NULL, &legacy_client_handler,
                        (void *)(uintptr_t)fd);
+#endif /* !RTE_EXEC_ENV_WINDOWS */
        return 0;
 }
 
+#ifndef RTE_EXEC_ENV_WINDOWS
+
 static int
 send_error_response(int s, int err)
 {
@@ -217,7 +225,7 @@ legacy_client_handler(void *sock_id)
        int ret;
        char buffer_recv[BUF_SIZE];
        /* receive data is not null terminated */
-       int bytes = read(s, buffer_recv, sizeof(buffer_recv));
+       int bytes = read(s, buffer_recv, sizeof(buffer_recv) - 1);
 
        while (bytes > 0) {
                buffer_recv[bytes] = 0;
@@ -234,8 +242,10 @@ legacy_client_handler(void *sock_id)
                        if (ret < 0)
                                printf("\nCould not send error response\n");
                }
-               bytes = read(s, buffer_recv, sizeof(buffer_recv));
+               bytes = read(s, buffer_recv, sizeof(buffer_recv) - 1);
        }
        close(s);
        return NULL;
 }
+
+#endif /* !RTE_EXEC_ENV_WINDOWS */