From d1aa35c3619847922e092b7dbfb201bceea8fa33 Mon Sep 17 00:00:00 2001 From: Aravinda VK Date: Thu, 18 Aug 2016 14:51:44 +0530 Subject: eventsapi: Fix disable-events issue Events related sources are not loaded in libglusterfs when configure is run with --disable-events option. Due to this every call of gf_event should be guarded with USE_EVENTS macro. To prevent this, USE_EVENTS macro was included in events.c itself(Patch #15054) Instead of disabling building entire directory "events", selectively disabled the code. So that constants and empty function gf_event is exposed. Code will not fail even if gf_event is called when events is disabled. BUG: 1368042 Change-Id: Ia6abfe9c1e46a7640c4d8ff5ccf0e9c30c87f928 Signed-off-by: Aravinda VK Reviewed-on: http://review.gluster.org/15198 Smoke: Gluster Build System Reviewed-by: Niels de Vos CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System --- libglusterfs/src/Makefile.am | 14 ++++++-------- libglusterfs/src/events.c | 9 ++++++--- libglusterfs/src/events.h | 27 +++++++++++++++++++++++++++ libglusterfs/src/events.h.in | 23 ----------------------- libglusterfs/src/glusterfs.h | 4 ---- 5 files changed, 39 insertions(+), 38 deletions(-) create mode 100644 libglusterfs/src/events.h delete mode 100644 libglusterfs/src/events.h.in (limited to 'libglusterfs') diff --git a/libglusterfs/src/Makefile.am b/libglusterfs/src/Makefile.am index 1fdd5a70fa4..d1ffbad5cc7 100644 --- a/libglusterfs/src/Makefile.am +++ b/libglusterfs/src/Makefile.am @@ -37,7 +37,7 @@ libglusterfs_la_SOURCES = dict.c xlator.c logging.c \ nodist_libglusterfs_la_SOURCES = y.tab.c graph.lex.c defaults.c nodist_libglusterfs_la_HEADERS = y.tab.h glusterfs-fops.h -BUILT_SOURCES = graph.lex.c defaults.c glusterfs-fops.h +BUILT_SOURCES = graph.lex.c defaults.c glusterfs-fops.h eventtypes.h libglusterfs_la_HEADERS = common-utils.h defaults.h default-args.h \ dict.h glusterfs.h hashfn.h timespec.h logging.h xlator.h \ @@ -51,7 +51,7 @@ libglusterfs_la_HEADERS = common-utils.h defaults.h default-args.h \ glfs-message-id.h template-component-messages.h strfd.h \ syncop-utils.h parse-utils.h libglusterfs-messages.h tw.h \ lvm-defaults.h quota-common-utils.h rot-buffs.h \ - compat-uuid.h upcall-utils.h throttle-tbf.h + compat-uuid.h upcall-utils.h throttle-tbf.h events.h libglusterfs_ladir = $(includedir)/glusterfs @@ -71,14 +71,12 @@ libglusterfs_la_SOURCES += $(CONTRIBDIR)/uuid/clear.c \ $(CONTRIBDIR)/uuid/unpack.c endif -if BUILD_EVENTS -BUILT_SOURCES += eventtypes.h -libglusterfs_la_SOURCES += events.c - -libglusterfs_la_HEADERS += events.h eventtypes.h -eventtypes.h: $(top_srcdir)/events/eventskeygen.py +eventtypes.h: $(PYTHON) $(top_srcdir)/events/eventskeygen.py C_HEADER + +if BUILD_EVENTS +libglusterfs_la_SOURCES += events.c endif libgfchangelog_HEADERS = changelog.h diff --git a/libglusterfs/src/events.c b/libglusterfs/src/events.c index 2df8c29026c..f93934de0fb 100644 --- a/libglusterfs/src/events.c +++ b/libglusterfs/src/events.c @@ -20,11 +20,15 @@ #include "mem-pool.h" #include "events.h" + +#define EVENT_PATH DATADIR "/run/gluster/events.sock" +#define EVENTS_MSG_MAX 2048 + + int -gf_event (int event, char *fmt, ...) +gf_event (eventtypes_t event, char *fmt, ...) { int ret = 0; -#if (USE_EVENTS) int sock = -1; char eventstr[EVENTS_MSG_MAX] = ""; struct sockaddr_un server; @@ -80,6 +84,5 @@ gf_event (int event, char *fmt, ...) out: sys_close(sock); GF_FREE(msg); -#endif return ret; } diff --git a/libglusterfs/src/events.h b/libglusterfs/src/events.h new file mode 100644 index 00000000000..6b280a0066f --- /dev/null +++ b/libglusterfs/src/events.h @@ -0,0 +1,27 @@ +/* + Copyright (c) 2016 Red Hat, Inc. + This file is part of GlusterFS. + + This file is licensed to you under your choice of the GNU Lesser + General Public License, version 3 or any later version (LGPLv3 or + later), or the GNU General Public License, version 2 (GPLv2), in all + cases as published by the Free Software Foundation. +*/ + +#ifndef __EVENTS_H__ +#define __EVENTS_H__ + +#include "eventtypes.h" + +#ifdef USE_EVENTS +int +gf_event (eventtypes_t event, char *fmt, ...); +#else +static inline int +gf_event (eventtypes_t event, char *fmt, ...) +{ + return 0; +} +#endif /* USE_EVENTS */ + +#endif /* __EVENTS_H__ */ diff --git a/libglusterfs/src/events.h.in b/libglusterfs/src/events.h.in deleted file mode 100644 index 37692bef732..00000000000 --- a/libglusterfs/src/events.h.in +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (c) 2016 Red Hat, Inc. - This file is part of GlusterFS. - - This file is licensed to you under your choice of the GNU Lesser - General Public License, version 3 or any later version (LGPLv3 or - later), or the GNU General Public License, version 2 (GPLv2), in all - cases as published by the Free Software Foundation. -*/ - -#ifndef __EVENTS_H__ -#define __EVENTS_H__ - -#include - -#include "eventtypes.h" - -#define EVENT_PATH "@localstatedir@/run/gluster/events.sock" -#define EVENTS_MSG_MAX 2048 - -extern int gf_event(int key, char *fmt, ...); - -#endif /* __EVENTS_H__ */ diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index d11cbdcb8ee..8d387bafb3b 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -37,10 +37,6 @@ #include "lkowner.h" #include "compat-uuid.h" -#if (USE_EVENTS) -#include "events.h" -#endif - #define GF_YES 1 #define GF_NO 0 -- cgit