diff options
author | Aravinda VK <avishwan@redhat.com> | 2016-08-18 14:51:44 +0530 |
---|---|---|
committer | Aravinda VK <avishwan@redhat.com> | 2016-08-24 01:23:06 -0700 |
commit | d1aa35c3619847922e092b7dbfb201bceea8fa33 (patch) | |
tree | a2f936c481b9201b63a4bf77f1346946f69cb8a3 /events | |
parent | 4aa52061a51b97c4f865b402f977b3b43f5471a7 (diff) |
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 <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/15198
Smoke: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Diffstat (limited to 'events')
-rw-r--r-- | events/Makefile.am | 4 | ||||
-rw-r--r-- | events/src/Makefile.am | 15 | ||||
-rw-r--r-- | events/src/eventsapiconf.py.in | 1 | ||||
-rw-r--r-- | events/src/gf_event.py | 5 | ||||
-rw-r--r-- | events/tools/Makefile.am | 5 |
5 files changed, 22 insertions, 8 deletions
diff --git a/events/Makefile.am b/events/Makefile.am index 04a74efc228..264bb742a80 100644 --- a/events/Makefile.am +++ b/events/Makefile.am @@ -1,6 +1,8 @@ SUBDIRS = src tools - +EXTRA_DIST = eventskeygen.py noinst_PYTHON = eventskeygen.py +if BUILD_EVENTS install-data-hook: $(INSTALL) -d -m 755 $(DESTDIR)@GLUSTERD_WORKDIR@/events +endif diff --git a/events/src/Makefile.am b/events/src/Makefile.am index 423bc8891fb..d292fbebc12 100644 --- a/events/src/Makefile.am +++ b/events/src/Makefile.am @@ -6,18 +6,21 @@ BUILT_SOURCES = eventtypes.py CLEANFILES = eventtypes.py eventsdir = $(libexecdir)/glusterfs/events +events_PYTHON = __init__.py gf_event.py eventsapiconf.py eventtypes.py \ + utils.py + +eventtypes.py: + $(PYTHON) $(top_srcdir)/events/eventskeygen.py PY_HEADER + +if BUILD_EVENTS eventspeerscriptdir = $(libexecdir)/glusterfs eventsconfdir = $(sysconfdir)/glusterfs eventsconf_DATA = eventsconfig.json -events_PYTHON = __init__.py eventsapiconf.py eventtypes.py handlers.py \ - utils.py gf_event.py +events_PYTHON += handlers.py events_SCRIPTS = glustereventsd.py eventspeerscript_SCRIPTS = peer_eventsapi.py -eventtypes.py: $(top_srcdir)/events/eventskeygen.py - $(PYTHON) $(top_srcdir)/events/eventskeygen.py PY_HEADER - install-exec-hook: $(mkdir_p) $(DESTDIR)$(sbindir) rm -f $(DESTDIR)$(sbindir)/glustereventsd @@ -30,3 +33,5 @@ install-exec-hook: uninstall-hook: rm -f $(DESTDIR)$(sbindir)/glustereventsd rm -f $(DESTDIR)$(sbindir)/gluster-eventsapi + +endif diff --git a/events/src/eventsapiconf.py.in b/events/src/eventsapiconf.py.in index 702e1d21820..03dd0e8d5d7 100644 --- a/events/src/eventsapiconf.py.in +++ b/events/src/eventsapiconf.py.in @@ -20,3 +20,4 @@ EVENTSD = "glustereventsd" CONFIG_KEYS = ["log_level"] BOOL_CONFIGS = [] RESTART_CONFIGS = [] +EVENTS_ENABLED = @EVENTS_ENABLED@ diff --git a/events/src/gf_event.py b/events/src/gf_event.py index 0924a65dddb..20dfc8a4f17 100644 --- a/events/src/gf_event.py +++ b/events/src/gf_event.py @@ -13,7 +13,7 @@ import socket import time -from eventsapiconf import SERVER_ADDRESS +from eventsapiconf import SERVER_ADDRESS, EVENTS_ENABLED from eventtypes import all_events from utils import logger, setup_logger @@ -23,6 +23,9 @@ setup_logger() def gf_event(event_type, **kwargs): + if EVENTS_ENABLED == 0: + return + if not isinstance(event_type, int) or event_type >= len(all_events): logger.error("Invalid Event Type: {0}".format(event_type)) return diff --git a/events/tools/Makefile.am b/events/tools/Makefile.am index 7d5e331e4e1..fb6770cf070 100644 --- a/events/tools/Makefile.am +++ b/events/tools/Makefile.am @@ -1,3 +1,6 @@ +EXTRA_DIST = eventsdash.py + +if BUILD_EVENTS scriptsdir = $(datadir)/glusterfs/scripts scripts_SCRIPTS = eventsdash.py -EXTRA_DIST = eventsdash.py +endif |