From: Konrad R. <kon...@us...> - 2005-04-19 16:05:01
|
Update of /cvsroot/sblim/indication_helper In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5765 Modified Files: ind_helper.c ind_helper.h Log Message: [ 1183083] CMPI-BASE: Indication Provider delivers only first occurence Added a new flag to ind_reg_pollfnc so that the developer can determine what behaviour he/she wants. Index: ind_helper.h =================================================================== RCS file: /cvsroot/sblim/indication_helper/ind_helper.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- ind_helper.h 2 Feb 2005 19:06:51 -0000 1.1.1.1 +++ ind_helper.h 19 Apr 2005 16:04:16 -0000 1.2 @@ -24,6 +24,102 @@ #define IND_TIME_DEFAULT 10; +/* + The mechanism by which the check function is being compared against. + Currently there are two logics, as explained below. +*/ +typedef Uint32 IndCheckBehaviour; + +/* +The polling function (defined as the <li>check</li) will +be pooled and the value passed in +to the parameter will be checked against the previous value +that was returned earlier. If there is a change, the library +will immediately call all of the property functions, create +an instance and attempt to deliever it (if the evaluation of +the instance against the indication filter is true). + +This detection mechanism is also comonly called 'edge level +detection' or 'trigger detection'. It means that the CIM +Listener will not be bombarded with indications but only +when state changes. + +For example, if the monitor function was passing these +values through its parameter: + +0,3,3,3,3,3,0,1,1,1,1,1,0,0,0 + ^ ^ ^ ^ +(rise) (doww&rise) (level down) + +There would only be four indications sent (of course, pending +the evaluation of the constructed instance agains the indication filter). + +Caveat: On the first call to the monitor function, the +previous state is not known. The library considers this +first call as the seed call and does not deliever the +instance. Please make sure to structure your code +accordingly and have a check for the first call. + +Note: The function prototype for the monitor function is the +same as for retrieving the property values. This means you +can use the same function for both purposes. For example, +assume you have a property named 'OperationStatus' that +returns two values: 2 (OK) or 4 (Stressed). The value of +this property could be the driver for triggering the +indication. Thus you could do this: + +ind_reg_pollfnc("CIM_ModifyInstance", "OperationalStatus", +check_os, 10); +ind_set_property_f("root/cimv2","CIM_ModifyInstance","Operational +Instance", +check_os); + +*/ +#define IND_BEHAVIOUR_LEVEL_EDGE 32 + +/* +The polling function (defined as the <li>check</li) will +be pooled and the value passed in through the parameter +will be checked against the "no-event" value - zero. Any value +other than "no-event" triggers the process of attempting to +send an indication (if the evaluation of the instance against the +indication filter is true, of course). + +For example, if the monitor function was passing these +values through its parameter: + +0,3,3,3,3,3,0,1,1,1,1,1,0,0,0 + ^^^^^^^^^ ^^^^^^^^^ + 5x event 5x event + +That means that there would be 10 indications sent (any value +that is not zero is considered as the go for the indication +creation). + +Note that there is no need to have a previous state by the +"check" function (as opposed to the LEVEL type behaviour). The +library assumes it is 0 (any of the integer values). + +Usually the check functions look something akin to this: + +IndErrorT check(CMPIData *v) +{ + + ind_new = check_OperationalStatus(&ind_OperationalStatus); + + v->state = CMPI_goodValue; + v->type = CMPI_uint16; + v->value.uint16 = ind_new; + + // Resetting it to no-event state. + ind_new = 0; + return IND_OK; + +} + +*/ + +#define IND_BEHAVIOUR_AGAINST_ZERO 64 /** * Return codes. */ @@ -125,6 +221,9 @@ * @param timer Polling interval in seconds. If you have no * need for fine-grain optimization use the 'IND_TIME_DEFAULT' * value. + * @param logic The logic for polling function. There are currently + * two logics: IND_BEHAVIOUR_LEVEL_EDGE and IND_BEHAVIOUR_AGAINST_ZERO. + * Please see the comments for those defines to find the full description. * * @return IND_INVALID_ARGS The 'cn' or 'pn' values are zero length. * @return IND_MUTEX Problem locking the internal list. This is a serious @@ -139,7 +238,8 @@ IndErrorT ind_reg_pollfnc(const char *cn, char *pn, IndErrorT (*check) (CMPIData *), - IndTimeT timer ); + IndTimeT timer, + IndCheckBehaviour logic); /** * Register the polling function. This routine will call @@ -157,6 +257,9 @@ * @param timer Polling interval in seconds. If you have no * need for fine-grain optimization use the 'IND_TIME_DEFAULT' * value. + * @param logic The logic for polling function. There are currently + * two logics: IND_BEHAVIOUR_LEVEL_EDGE and IND_BEHAVIOUR_AGAINST_ZERO. + * Please see the comments for those defines to find the full description. * * @return IND_INVALID_ARGS The 'cn' or 'pn' values are zero length. * @return IND_MUTEX Problem locking the internal list. This is a serious @@ -172,7 +275,8 @@ const char *cn, char *pn, IndErrorT (*check) (CMPIData *), - IndTimeT timer ); + IndTimeT timer, + IndCheckBehaviour logic); /** Index: ind_helper.c =================================================================== RCS file: /cvsroot/sblim/indication_helper/ind_helper.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ind_helper.c 23 Mar 2005 21:47:08 -0000 1.6 +++ ind_helper.c 19 Apr 2005 16:04:15 -0000 1.7 @@ -35,13 +35,14 @@ #if defined(DEBUG) -#define IND_HLP_DEBUG(X) fprintf(stderr, "%s:%d:[%s]\n", __FILE__, __LINE__, X); fflush(stderr); +#define IND_HLP_DEBUG(X) fprintf(stderr, "%s:%d:[%s]\n", __FILE__, __LINE__, X); fflush(stderr); #else #define IND_HLP_DEBUG(X) #endif #define DEFAULT_NAMESPACE "root/cimv2" [...3262 lines suppressed...] { - IND_HLP_DEBUG("String released."); - if (data->value.string) { - CMRelease(data->value.string); - data->value.string = NULL; - } + IND_HLP_DEBUG ("String released."); + if (data->value.string) + { + CMRelease (data->value.string); + data->value.string = NULL; + } } - - IND_HLP_DEBUG("_releaseDataValue exited."); + + IND_HLP_DEBUG ("_releaseDataValue exited."); return IND_OK; } - |