[SCM] CTDB repository - branch 1.2.40 updated - ctdb-1.2.53-3-gb746729
Amitay Isaacs
amitay at samba.org
Tue Oct 30 00:53:15 MDT 2012
The branch, 1.2.40 has been updated
via b7467294465b6225982c90315df20a8699ccf812 (commit)
via c116d0b107873d679fd6246ef3dd2fbcdbe46b56 (commit)
via 49e66cf4009c8f8816baa83a4bd4408c540b389c (commit)
from 046f8799361794997cedae3d4ff812216661e04e (commit)
http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=1.2.40
- Log -----------------------------------------------------------------
commit b7467294465b6225982c90315df20a8699ccf812
Author: Amitay Isaacs <amitay at gmail.com>
Date: Tue Oct 30 12:39:00 2012 +1100
New Version 1.2.54
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
commit c116d0b107873d679fd6246ef3dd2fbcdbe46b56
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Sep 3 12:39:36 2012 +1000
scripts: Remove duplicate code from init script to set tunables
The tunable variables defined in CTDB configuration file are currently
set up from init script as well as part of "setup" event in 00.ctdb
eventscript. Remove the duplication of this code and set tunable
variables only from setup event. During the "setup" event, it's possible
that ctdb tool commands can timeout if CTDB daemon is not ready. To guard
against such eventuality, wait till "ctdb ping" command succeeds before
executing any other ctdb tool commands.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Cherry-picked-from: 632c1b9c1cc2e242376358ce49fd2022b3f27aa2
Conflicts:
config/events.d/00.ctdb
commit 49e66cf4009c8f8816baa83a4bd4408c540b389c
Author: Amitay Isaacs <amitay at gmail.com>
Date: Mon Oct 29 14:56:10 2012 +1100
daemon: Protect against double free of callback state while shutting down
When CTDB is shut down and monitoring has been stopped, monitor_context
gets freed and all the callback states hanging off it. This includes
callback state for current_monitor, if the current monitor event has
not yet finished. As a result, when the shutdown event is called,
current_monitor->callback state is not NULL, but it's actually freed
and it's a dangling reference.
So before executing callback function and freeing callback state check
if ctdb->monitor->monitor_context is not NULL.
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
-----------------------------------------------------------------------
Summary of changes:
config/ctdb.init | 14 +-------------
config/events.d/00.ctdb | 39 +++++++++++++++++++++++++++++++--------
include/ctdb_private.h | 1 +
packaging/RPM/ctdb.spec.in | 5 ++++-
server/ctdb_monitor.c | 7 +++++++
server/eventscript.c | 5 +++--
6 files changed, 47 insertions(+), 24 deletions(-)
Changeset truncated at 500 lines:
diff --git a/config/ctdb.init b/config/ctdb.init
index 7c75726..4fe01e3 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -217,16 +217,6 @@ EOF
done
}
-set_ctdb_variables () {
- # set any tunables from the config file
- set | grep ^CTDB_SET_ | cut -d_ -f3- |
- while read v; do
- varname=`echo $v | cut -d= -f1`
- value=`echo $v | cut -d= -f2`
- ctdb setvar $varname $value || RETVAL=1
- done || exit 1
-}
-
set_retval() {
return $1
}
@@ -311,9 +301,7 @@ start() {
esac
if [ $RETVAL -eq 0 ] ; then
- if wait_until_ready ; then
- set_ctdb_variables
- else
+ if ! wait_until_ready ; then
RETVAL=1
pkill -9 -f $ctdbd >/dev/null 2>&1
fi
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 4f97185..5ad74bf 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -30,6 +30,32 @@ update_config_from_tdb() {
}
}
+set_ctdb_variables () {
+ # set any tunables from the config file
+ set | grep ^CTDB_SET_ | cut -d_ -f3- |
+ while read v; do
+ varname=`echo $v | cut -d= -f1`
+ value=`echo $v | cut -d= -f2`
+ ctdb setvar $varname $value || return 1
+ echo "Set $varname to $value"
+ done
+}
+
+wait_until_ready () {
+ _timeout="${1:-10}" # default is 10 seconds
+
+ _count=0
+ while ! ctdb ping >/dev/null 2>&1 ; do
+ if [ $_count -ge $_timeout ] ; then
+ return 1
+ fi
+ sleep 1
+ _count=$(($_count + 1))
+ done
+}
+
+ctdb_check_args "$@"
+
case "$1" in
init)
# make sure we have a blank state directory for the scripts to work with
@@ -42,14 +68,11 @@ case "$1" in
;;
setup)
- # set any tunables from the config file
- set | grep ^CTDB_SET_ | cut -d_ -f3- |
- while read v; do
- varname=`echo $v | cut -d= -f1`
- value=`echo $v | cut -d= -f2`
- ctdb setvar $varname $value || exit 1
- echo "Set $varname to $value"
- done || exit 1
+ # Make sure CTDB daemon is ready to process requests
+ if wait_until_ready ; then
+ # set any tunables from the config file
+ set_ctdb_variables
+ fi || exit 1
;;
startup)
diff --git a/include/ctdb_private.h b/include/ctdb_private.h
index b5bd45c..c54e1b0 100644
--- a/include/ctdb_private.h
+++ b/include/ctdb_private.h
@@ -1275,6 +1275,7 @@ int ctdb_repack(struct ctdb_context *ctdb, int argc, const char **argv);
void ctdb_block_signal(int signum);
void ctdb_unblock_signal(int signum);
int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
+bool ctdb_stopped_monitoring(struct ctdb_context *ctdb);
int ctdb_set_child_logging(struct ctdb_context *ctdb);
void ctdb_lockdown_memory(struct ctdb_context *ctdb);
diff --git a/packaging/RPM/ctdb.spec.in b/packaging/RPM/ctdb.spec.in
index 0e36858..3ded827 100644
--- a/packaging/RPM/ctdb.spec.in
+++ b/packaging/RPM/ctdb.spec.in
@@ -3,7 +3,7 @@ Name: ctdb
Summary: Clustered TDB
Vendor: Samba Team
Packager: Samba Team <samba at samba.org>
-Version: 1.2.53
+Version: 1.2.54
Release: 1GITHASH
Epoch: 0
License: GNU GPL version 3
@@ -146,6 +146,9 @@ development libraries for ctdb
%changelog
+* Wed Oct 30 2012 : Version 1.2.54
+ - Protect against double free of active monitor callback state during shutdown
+ - Remove duplicate code to set tunables from initscript
* Fri Oct 26 2012 : Version 1.2.53
- Initscript: backup corrupt non-persistent database before starting CTDB
* Fri Oct 05 2012 : Version 1.2.52
diff --git a/server/ctdb_monitor.c b/server/ctdb_monitor.c
index e897452..c735601 100644
--- a/server/ctdb_monitor.c
+++ b/server/ctdb_monitor.c
@@ -526,3 +526,10 @@ int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb)
return ctdb->monitor->monitoring_mode;
}
+/*
+ * Check if monitoring has been stopped
+ */
+bool ctdb_stopped_monitoring(struct ctdb_context *ctdb)
+{
+ return (ctdb->monitor->monitor_context == NULL ? true : false);
+}
diff --git a/server/eventscript.c b/server/eventscript.c
index c42aaa4..2f86fdd 100644
--- a/server/eventscript.c
+++ b/server/eventscript.c
@@ -756,8 +756,9 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
if (ctdb->current_monitor) {
struct ctdb_event_script_state *ms = talloc_get_type(ctdb->current_monitor, struct ctdb_event_script_state);
- /* cancel it */
- if (ms->callback != NULL) {
+ /* Cancel current monitor callback state only if monitoring
+ * context ctdb->monitor->monitor_context has not been freed */
+ if (ms->callback != NULL && !ctdb_stopped_monitoring(ctdb)) {
ms->callback->fn(ctdb, -ECANCELED, ms->callback->private_data);
talloc_free(ms->callback);
}
--
CTDB repository
More information about the samba-cvs
mailing list