diff options
Diffstat (limited to 'cpp/src/qpid/sys')
| -rw-r--r-- | cpp/src/qpid/sys/ClusterSafe.cpp | 6 | ||||
| -rw-r--r-- | cpp/src/qpid/sys/ClusterSafe.h | 17 |
2 files changed, 21 insertions, 2 deletions
diff --git a/cpp/src/qpid/sys/ClusterSafe.cpp b/cpp/src/qpid/sys/ClusterSafe.cpp index 498a46d865..e051591afd 100644 --- a/cpp/src/qpid/sys/ClusterSafe.cpp +++ b/cpp/src/qpid/sys/ClusterSafe.cpp @@ -32,8 +32,12 @@ bool inCluster = false; QPID_TSS bool inContext = false; } +bool isClusterSafe() { return !inCluster || inContext; } + +bool isCluster() { return inCluster; } + void assertClusterSafe() { - if (inCluster && !inContext) { + if (!isClusterSafe()) { QPID_LOG(critical, "Modified cluster state outside of cluster context"); ::abort(); } diff --git a/cpp/src/qpid/sys/ClusterSafe.h b/cpp/src/qpid/sys/ClusterSafe.h index abb9ad0fff..f3382307d0 100644 --- a/cpp/src/qpid/sys/ClusterSafe.h +++ b/cpp/src/qpid/sys/ClusterSafe.h @@ -42,6 +42,20 @@ namespace sys { QPID_COMMON_EXTERN void assertClusterSafe(); /** + * In a non-clustered broker, returns true. + * + * In a clustered broker returns true if we are in a context where it + * is safe to modify cluster state. + * + * This function is in the common library rather than the cluster + * library because it is called by code in the broker library. + */ +QPID_COMMON_EXTERN bool isClusterSafe(); + +/** Return true in a clustered broker */ +QPID_COMMON_EXTERN bool isCluster(); + +/** * Base class for classes that encapsulate state which is replicated * to all members of a cluster. Acts as a marker for clustered state * and provides functions to assist detecting bugs in cluster @@ -53,7 +67,8 @@ struct ClusterSafeScope { }; /** - * Enable cluster-safe assertions. By defaul they are no-ops. + * Enable cluster-safe assertions. By default they are no-ops. + * Called by cluster code. */ void enableClusterSafe(); |
