1df6c8
From 7e5d8dcb4f557eaca259e8d81cf34d651907396c Mon Sep 17 00:00:00 2001
1df6c8
From: Pranith Kumar K <pkarampu@redhat.com>
1df6c8
Date: Thu, 24 Oct 2019 12:24:35 +0530
1df6c8
Subject: [PATCH 320/335] gf-event: Handle unix volfile-servers
1df6c8
1df6c8
Problem:
1df6c8
glfsheal program uses unix-socket-based volfile server.
1df6c8
volfile server will be the path to socket in this case.
1df6c8
gf_event expects this to be hostname in all cases. So getaddrinfo
1df6c8
will fail on the unix-socket path, events won't be sent in this case.
1df6c8
1df6c8
Fix:
1df6c8
In case of unix sockets, default to localhost
1df6c8
1df6c8
upstream-patch: https://review.gluster.org/c/glusterfs/+/23606
1df6c8
BUG: 1758923
1df6c8
Change-Id: I60d27608792c29d83fb82beb5fde5ef4754bece8
1df6c8
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
1df6c8
Reviewed-on: https://code.engineering.redhat.com/gerrit/185851
1df6c8
Tested-by: RHGS Build Bot <nigelb@redhat.com>
1df6c8
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
1df6c8
---
1df6c8
 libglusterfs/src/events.c | 11 ++++++++++-
1df6c8
 1 file changed, 10 insertions(+), 1 deletion(-)
1df6c8
1df6c8
diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c
1df6c8
index 9d33783..4e2f8f9 100644
1df6c8
--- a/libglusterfs/src/events.c
1df6c8
+++ b/libglusterfs/src/events.c
1df6c8
@@ -43,6 +43,7 @@ _gf_event(eventtypes_t event, const char *fmt, ...)
1df6c8
     struct addrinfo *result = NULL;
1df6c8
     xlator_t *this = THIS;
1df6c8
     int sin_family = AF_INET;
1df6c8
+    char *volfile_server_transport = NULL;
1df6c8
 
1df6c8
     /* Global context */
1df6c8
     ctx = THIS->ctx;
1df6c8
@@ -62,8 +63,16 @@ _gf_event(eventtypes_t event, const char *fmt, ...)
1df6c8
     memset(&hints, 0, sizeof(hints));
1df6c8
     hints.ai_family = AF_UNSPEC;
1df6c8
 
1df6c8
+    if (ctx) {
1df6c8
+        volfile_server_transport = ctx->cmd_args.volfile_server_transport;
1df6c8
+    }
1df6c8
+
1df6c8
+    if (!volfile_server_transport) {
1df6c8
+        volfile_server_transport = "tcp";
1df6c8
+    }
1df6c8
     /* Get Host name to send message */
1df6c8
-    if (ctx && ctx->cmd_args.volfile_server) {
1df6c8
+    if (ctx && ctx->cmd_args.volfile_server &&
1df6c8
+        (strcmp(volfile_server_transport, "unix"))) {
1df6c8
         /* If it is client code then volfile_server is set
1df6c8
            use that information to push the events. */
1df6c8
         if ((getaddrinfo(ctx->cmd_args.volfile_server, NULL, &hints,
1df6c8
-- 
1df6c8
1.8.3.1
1df6c8