rgmanager: DBus notifications for service state changes
PATCH 1/5 rgmanager: DBus notifications for service state changes
Clean cherry-pick in to RHEL6 branch
Resolves: rhbz#657756
--- rgmanager/include/rg_dbus.h | 14 ++++ rgmanager/man/rgmanager.8 | 2 + rgmanager/src/daemons/Makefile | 7 +- rgmanager/src/daemons/main.c | 88 ++++++++++++++++++++- rgmanager/src/daemons/update-dbus.c | 144 +++++++++++++++++++++++++++++++++++ 5 files changed, 250 insertions(+), 5 deletions(-) create mode 100644 rgmanager/include/rg_dbus.h create mode 100644 rgmanager/src/daemons/update-dbus.c
rgmanager/include/rg_dbus.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifdef DBUS +#ifndef _RGM_DBUS_H +#define _RGM_DBUS_H + +int rgm_dbus_init (void ); +int rgm_dbus_release (void ); +int rgm_dbus_notify (const char *svcname, +const char *svcstatus, +const char *svcflags, +const char *svcowner, +const char *svclast); + +#endif +#endif
rgmanager/man/rgmanager.8 +2 -0
@@ -371,6 +371,8 @@ will leave the virtual machine running. Run in the foreground (do not fork). .IP \-d Enable debug-level logging. +.IP \-D +Disable DBus signals which are normally sent when services change state. .IP \-w Disable internal process monitoring (for debugging). .IP \-N
rgmanager/src/daemons/Makefile +5 -2
@@ -29,6 +29,7 @@ OBJS1= fo_domain.o \ service_op.o \ slang_event.o \ event_config.o \ + update-dbus.o \ watchdog.o OBJS2= test-noccs.o \
@@ -40,12 +41,13 @@ OBJS2= test-noccs.o \ rg_locks-noccs.o \ event_config-noccs.o -CFLAGS += -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE +CFLAGS += -DDBUS -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE CFLAGS += -fPIC CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${logtincdir} CFLAGS += `xml2-config --cflags` -I${slangincdir} CFLAGS += -I$(S)/../../include CFLAGS += -I${incdir} +CFLAGS += `pkg-config --cflags dbus-1` NOCCS_CFLAGS += -DNO_CCS
@@ -59,6 +61,7 @@ DLM_LDFLAGS += -L${dlmlibdir} -ldlm XML2_LDFLAGS += `xml2-config --libs` SLANG_LDFLAGS += -L${slanglibdir} -lslang EXTRA_LDFLAGS += -lpthread +DBUS_LDFLAGS += `pkg-config --libs dbus-1` LDDEPS += ../clulib/libclulib.a
@@ -66,7 +69,7 @@ ${TARGET1}: ${OBJS1} ${LDDEPS} $(CC) -o $@ $^ $(CCS_LDFLAGS) $(CMAN_LDFLAGS) \ $(DLM_LDFLAGS) $(XML2_LDFLAGS) \ $(SLANG_LDFLAGS) $(EXTRA_LDFLAGS) \ - $(LOGSYS_LDFLAGS) $(LD_FLAGS) + $(LOGSYS_LDFLAGS) $(LD_FLAGS) $(DBUS_LDFLAGS) # # Our test program links against the local allocator so that
rgmanager/src/daemons/main.c +85 -3
136 lines not on this page · raw message
rgmanager/src/daemons/update-dbus.c new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 2/5 rgmanager: Clean up dbus notifications
Clean cherry-pick in to RHEL6 branch
Resolves: rhbz#657756
--- rgmanager/include/rg_dbus.h | 20 ++++-- rgmanager/src/daemons/Makefile | 2 +- rgmanager/src/daemons/main.c | 82 +-------------------------- rgmanager/src/daemons/update-dbus.c | 105 ++++++++++++++++++++++++++++++++--- 4 files changed, 115 insertions(+), 94 deletions(-)
rgmanager/include/rg_dbus.h +13 -7
@@ -1,14 +1,20 @@ -#ifdef DBUS #ifndef _RGM_DBUS_H#define _RGM_DBUS_Hint rgm_dbus_init (void );int rgm_dbus_release (void ); -int rgm_dbus_notify (const char *svcname, -const char *svcstatus, -const char *svcflags, -const char *svcowner, -const char *svclast); +extern int rgm_dbus_notify; -#endif +#ifdef DBUS + +#define RGM_DBUS_DEFAULT 1 +#define RGM_DBUS_UPDATE (rgm_dbus_notify?rgm_dbus_update:0) +int32_t rgm_dbus_update (char *key,uint64_t view,void *data,uint32_t size); + +#else + +#define RGM_DBUS_DEFAULT 0 +#define RGM_DBUS_UPDATE NULL + +#endif /* DBUS */ #endif
rgmanager/src/daemons/Makefile +1 -1
@@ -41,7 +41,7 @@ OBJS2= test-noccs.o \ rg_locks-noccs.o \ event_config-noccs.o -CFLAGS += -DDBUS -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE +CFLAGS += -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE CFLAGS += -fPIC CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${logtincdir} CFLAGS += `xml2-config --cflags` -I${slangincdir}
rgmanager/src/daemons/main.c +4 -78
120 lines not on this page · raw message
rgmanager/src/daemons/update-dbus.c +97 -8
155 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 3/5 rgmanager: Retry dbus if we get disconnected
In reply to Lon HohbergerClean cherry-pick in to RHEL6 branch
Resolves: rhbz#657756
--- rgmanager/src/daemons/main.c | 9 ++++- rgmanager/src/daemons/update-dbus.c | 60 ++++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 21 deletions(-)
rgmanager/src/daemons/main.c +7 -2
@@ -684,6 +684,8 @@ event_loop(msgctx_t *localctx, msgctx_t *clusterctx)dump_internal_state ("/var/lib/cluster/rgmanager-dump" ); } +rgm_dbus_init (); +while (running && (tv.tv_sec || tv.tv_usec)) {FD_ZERO (&rfds); max =-1 ;
@@ -1035,8 +1037,11 @@ main(int argc, char **argv)configure_rgmanager (-1 , debug, &cluster_timeout);logt_print (LOG_NOTICE ,"Resource Group Manager Starting\n" ); -if (rgm_dbus_notify &&rgm_dbus_init () !=0 ) -logt_print (LOG_NOTICE ,"Failed to initialize DBus\n" ); +if (rgm_dbus_notify &&rgm_dbus_init () !=0 ) { + rgm_dbus_notify =0 ; +logt_print (LOG_NOTICE ,"Failed to initialize DBus; " +"notifications disabled\n" ); + }if (init_resource_groups (0 , do_init) !=0 ) {logt_print (LOG_CRIT ,"#8: Couldn't initialize services\n" );
rgmanager/src/daemons/update-dbus.c +41 -19
148 lines not on this page · raw message
Signature · 1 line
1.7.2.3
PATCH 4/5 rgmanager: minor dbus cleanups
In reply to Lon HohbergerClean cherry-pick in to RHEL6 branch
Resolves: rhbz#657756
--- rgmanager/src/daemons/update-dbus.c | 31 +++++++++++++++++++++---------- 1 files changed, 21 insertions(+), 10 deletions(-)
rgmanager/src/daemons/update-dbus.c +21 -10
@@ -47,7 +47,7 @@ rgm_dbus_init(void) dbc =dbus_bus_get_private (DBUS_BUS_SYSTEM , &err);if (!dbc) { -logt_print (LOG_ERR , +logt_print (LOG_DEBUG ,"DBus Failed to initialize: dbus_bus_get: %s\n" , err.message);dbus_error_free (&err);
@@ -72,7 +72,7 @@ rgm_dbus_init(void)#ifdef DBUS static int -_rgm_dbus_release (int err) +_rgm_dbus_release (void ) {pthread_t t;
@@ -83,7 +83,7 @@ _rgm_dbus_release(int err)* to wake up, so just have it poll XXX */ /* if the thread left because the dbus connection died, -this block is avoided since the thread exits */ +this block is avoided */ if (th) { t = th; th =0 ;
@@ -94,15 +94,13 @@ _rgm_dbus_release(int err)dbus_connection_unref (db); db =NULL ; -if (err) -logt_print (LOG_ERR ,"DBus Connection Lost\n" ); -else -logt_print (LOG_DEBUG ,"DBus Released\n" ); +logt_print (LOG_DEBUG ,"DBus Released\n" );return 0 ; }#endif +/* Clean shutdown (e.g. when exiting */ int rgm_dbus_release(void)#ifdef DBUS
@@ -110,7 +108,7 @@ rgm_dbus_release(void)int ret;pthread_mutex_lock (&mu); - ret =_rgm_dbus_release (0 ); + ret =_rgm_dbus_release ();pthread_mutex_unlock (&mu);return ret; }
@@ -122,6 +120,9 @@ rgm_dbus_release(void)#ifdef DBUS +/* Auto-flush thread. Since sending only guarantees queueing, +* we need this thread to push things out over dbus in the +* background */ static void *_dbus_auto_flush (void *arg) {
@@ -154,8 +155,15 @@ _rgm_dbus_notify(const char *svcname,pthread_mutex_lock (&mu); +/* Check to ensure the connection is still valid. If it +* isn't, clean up and shut down the dbus connection. +* +* The main rgmanager thread will periodically try to +* reinitialize the dbus notification subsystem unless +* the administrator ran rgmanager with the -D command +* line option. +*/ if (dbus_connection_get_is_connected (db) != TRUE) { -_rgm_dbus_release (1 ); goto out_unlock; }
@@ -192,6 +200,9 @@ out_free: } +/* +* view-formation callback function +*/ int32_t rgm_dbus_update (char *key,uint64_t view,void *data,uint32_t size) {
@@ -242,7 +253,7 @@ rgm_dbus_update(char *key, uint64_t view, void *data, uint32_t size)if (ret <0 ) {logt_print (LOG_ERR ,"Error sending update for %s; " -"notifications disabled\n" , key); +"DBus notifications disabled\n" , key);rgm_dbus_release (); }
Signature · 1 line
1.7.2.3
PATCH 5/5 rgmanager: Match fenced's option to disable DBus
In reply to Lon HohbergerClean cherry-pick in to RHEL6 branch
Resolves: rhbz#657756
--- rgmanager/man/rgmanager.8 | 2 +- rgmanager/src/daemons/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
rgmanager/man/rgmanager.8 +1 -1
@@ -371,7 +371,7 @@ will leave the virtual machine running. Run in the foreground (do not fork). .IP \-d Enable debug-level logging. -.IP \-D +.IP \-q Disable DBus signals which are normally sent when services change state. .IP \-w Disable internal process monitoring (for debugging).
rgmanager/src/daemons/main.c +2 -2
@@ -951,7 +951,7 @@ main(int argc, char **argv)pthread_t th;cman_handle_t clu =NULL ; -while ((rv =getopt (argc, argv,"wfdND" )) !=EOF ) { +while ((rv =getopt (argc, argv,"wfdNq" )) !=EOF ) {switch (rv) {case 'w' : wd =0 ;
@@ -965,7 +965,7 @@ main(int argc, char **argv)case 'f' : foreground =1 ;break ; -case 'D' : +case 'q' : rgm_dbus_notify =0 ;break ;default :
Signature · 1 line
1.7.2.3
PATCH 2/5 rgmanager: Clean up dbus notifications
In reply to Lon Hohbergerrgmanager/src/daemons/Makefile OBJS2= test-noccs.o \ · line 47
Quoted 13 lines · Lon Hohberger
rgmanager/src/daemons/Makefile +1
-1@@ -41,7 +41,7 @@ OBJS2= test-noccs.o \ rg_locks-noccs.o \ event_config-noccs.o -CFLAGS += -DDBUS -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE +CFLAGS += -DSHAREDIR=\"${sharedir}\" -D_GNU_SOURCE CFLAGS += -fPIC CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${logtincdir} CFLAGS += `xml2-config --cflags` -I${slangincdir}
Oops -- for RHEL6 branch, this part needs to be removed; we need the -DDBUS.
-- Lon