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