summaryrefslogtreecommitdiffstats
path: root/src/indmanager
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@redhat.com>2013-11-19 14:42:48 +0100
committerTomas Bzatek <tbzatek@redhat.com>2013-11-19 16:47:06 +0100
commit32d213a06e73650073031fb59539d565adea3ec0 (patch)
tree5952d2a41a8bb302e9141a1e067754b9f44e8823 /src/indmanager
parent21ea2fe00a690bbc01ab241eea60d1d0a3f4349b (diff)
downloadopenlmi-providers-32d213a06e73650073031fb59539d565adea3ec0.tar.gz
openlmi-providers-32d213a06e73650073031fb59539d565adea3ec0.tar.xz
openlmi-providers-32d213a06e73650073031fb59539d565adea3ec0.zip
indmanager: Do initial poll for newly added filters
Indications are often started on CIMOM startup if there are some registered persistently (or failed their cleanup). This will start several indication managers as needed. When a new filter is registered, it needs initial values for polling mode. This is normally done on manage thread iteration but in this case, when indication manager is already running, it doesn't get filled and any change event will go unnoticed since we don't have anything to compare new values against. This change will immediately fill actual values for newly added filters in case indications have been already started.
Diffstat (limited to 'src/indmanager')
-rw-r--r--src/indmanager/ind_manager.c99
1 files changed, 52 insertions, 47 deletions
diff --git a/src/indmanager/ind_manager.c b/src/indmanager/ind_manager.c
index cae141b..2a23835 100644
--- a/src/indmanager/ind_manager.c
+++ b/src/indmanager/ind_manager.c
@@ -382,6 +382,53 @@ bool equal_ops(CMPIObjectPath *op1, CMPIObjectPath *op2)
strcmp(CN_STR_FROM_OP(op1), CN_STR_FROM_OP(op2)) == 0);
}
+// Pair enumerations. This enum will become prev enum and new this enum
+// will be created by new obtained by object path
+bool pair_enumeration(IMManager *manager, IMEnumerationPair *epair)
+{
+ CMPIEnumeration *aux_e = CBEnumInstances(manager->broker,
+ manager->ctx_manage, epair->op, NULL, NULL);
+ if (!aux_e) {
+ return false;
+ }
+ CMPIArray *new_e = CMClone(CMToArray(aux_e, NULL), NULL);
+ if (!epair->prev_enum && !epair->this_enum) {
+ epair->prev_enum = CMClone(new_e, NULL);
+ epair->this_enum = new_e;
+ return true;
+ }
+ if (epair->prev_enum) {
+ CMRelease(epair->prev_enum);
+ }
+ epair->prev_enum = epair->this_enum;
+ epair->this_enum = new_e;
+ return true;
+}
+
+// When the filter is added there is no enum pairs created
+// This function will generate pairs where they are missing
+bool first_poll(IMManager *manager, IMError *err)
+{
+ DEBUG("IM first poll called");
+ if (!manager) {
+ *err = IM_ERR_MANAGER;
+ return false;
+ }
+ if (!manager->enums) {
+ // Nothing to poll
+ return true;
+ }
+ IMEnumerationPair *epair = NULL;
+ for (epair = manager->enums->first; epair; epair = epair->next) {
+ if (epair->this_enum == NULL && epair->prev_enum == NULL) {
+ if (!pair_enumeration(manager, epair)) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
// Try to find enumeration with given object path
// if found increase reference count
// if not found add it to the end of list with ref count = 1
@@ -422,6 +469,11 @@ bool add_enumeration(IMManager *manager, CMPIObjectPath *op, IMError *err)
new_ime->ref_count = 1;
new_ime->prev_enum = NULL;
new_ime->this_enum = NULL;
+ if (manager->ctx_manage) {
+ /* Fill the enumeration with values valid at the time the filter was registered and
+ * only if we're adding new filter when indications have been started already */
+ pair_enumeration(manager, new_ime);
+ }
if (!last) { // there isn't any enumeration yet
manager->enums->first = new_ime;
} else {
@@ -430,53 +482,6 @@ bool add_enumeration(IMManager *manager, CMPIObjectPath *op, IMError *err)
return true;
}
-// Pair enumerations. This enum will become prev enum and new this enum
-// will be created by new obtained by object path
-bool pair_enumeration(IMManager *manager, IMEnumerationPair *epair)
-{
- CMPIEnumeration *aux_e = CBEnumInstances(manager->broker,
- manager->ctx_manage, epair->op, NULL, NULL);
- if (!aux_e) {
- return false;
- }
- CMPIArray *new_e = CMClone(CMToArray(aux_e, NULL), NULL);
- if (!epair->prev_enum && !epair->this_enum) {
- epair->prev_enum = CMClone(new_e, NULL);
- epair->this_enum = new_e;
- return true;
- }
- if (epair->prev_enum) {
- CMRelease(epair->prev_enum);
- }
- epair->prev_enum = epair->this_enum;
- epair->this_enum = new_e;
- return true;
-}
-
-// When the filter is added there is no enum pairs created
-// This function will generate pairs where they are missing
-bool first_poll(IMManager *manager, IMError *err)
-{
- DEBUG("IM first poll called");
- if (!manager) {
- *err = IM_ERR_MANAGER;
- return false;
- }
- if (!manager->enums) {
- // Nothing to poll
- return true;
- }
- IMEnumerationPair *epair = NULL;
- for (epair = manager->enums->first; epair; epair = epair->next) {
- if (epair->this_enum == NULL && epair->prev_enum == NULL) {
- if (!pair_enumeration(manager, epair)) {
- return false;
- }
- }
- }
- return true;
-}
-
bool _im_poll(IMManager *manager, IMError *err)
{
DEBUG("IM poll called");