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