From: Michael Chase-S. <mc...@us...> - 2013-04-18 02:45:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "sfcb - Small Footprint CIM Broker". The branch, master has been updated via 55887c1db42af7da05efb54b5afffd7bd59bf3b2 (commit) from 26268169668ec7f7ef549965f2135cd8fe4b286f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 55887c1db42af7da05efb54b5afffd7bd59bf3b2 Author: Michael Chase-Salerno <br...@li...> Date: Wed Apr 17 22:44:26 2013 -0400 [#sfcb-tix:41] Global IndicationService ----------------------------------------------------------------------- Summary of changes: instance.c | 7 +++ interopServerProvider.c | 129 +++++++++-------------------------------------- sfcbmacs.h | 1 + support.h | 1 + 4 files changed, 33 insertions(+), 105 deletions(-) diff --git a/instance.c b/instance.c index 5d3507f..1cb5755 100644 --- a/instance.c +++ b/instance.c @@ -145,6 +145,13 @@ memLinkInstance(CMPIInstance *ci) memLinkEncObj(i, &i->mem_state); } +void +memUnlinkInstance(CMPIInstance *ci) +{ + struct native_instance *i = (struct native_instance *) ci; + memUnlinkEncObj(i->mem_state); +} + static int __contained_list(char **list, const char *name) { diff --git a/interopServerProvider.c b/interopServerProvider.c index a2afdfc..4760229 100644 --- a/interopServerProvider.c +++ b/interopServerProvider.c @@ -58,6 +58,7 @@ static const CMPIBroker *_broker; static CMPIStatus invClassSt = { CMPI_RC_ERR_INVALID_CLASS, NULL }; +static CMPIInstance *ISinst; //Global instance for IndicationService // ------------------------------------------------------------------ @@ -453,25 +454,8 @@ IndServiceProviderGetInstance(CMPIInstanceMI * mi, _SFCB_RETURN(st); } -#ifdef SETTABLERETRY - - /* check if it exists first */ - CMPIContext *ctxLocal; - ctxLocal = native_clone_CMPIContext(ctx); - CMPIValue val; - val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL,0); - ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string); - - ci = CBGetInstance(_broker, ctxLocal, ref, properties, &st); - -#else - - ci = CMNewInstance(_broker, op, &st); - - makeIndService(ci); - -#endif - + ci = ISinst->ft->clone(ISinst, &st); + memLinkInstance(ci); if (properties) { ci->ft->setPropertyFilter(ci, properties, NULL); } @@ -493,37 +477,8 @@ IndServiceProviderEnumInstances(CMPIInstanceMI * mi, _SFCB_ENTER(TRACE_PROVIDERS, "IndServiceProviderEnumInstances"); -#ifdef SETTABLERETRY - - CMPIObjectPath *op; - CMPIEnumeration *indServices = NULL; - CMPIContext *ctxLocal; - ctxLocal = native_clone_CMPIContext(ctx); - CMPIValue val; - CMPIInstance *ci=NULL; - val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL,0); - ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string); - - op = CMNewObjectPath(_broker, "root/interop", "CIM_IndicationService", - NULL); - indServices = CBEnumInstances(_broker, ctxLocal, op, properties, &st); - - while (CMHasNext(indServices, NULL)) { - ci=CMGetNext(indServices, NULL).value.inst; - if (properties) { - ci->ft->setPropertyFilter(ci, properties, NULL); - } - CMReturnInstance(rslt, ci); - } + CMReturnInstance(rslt, ISinst); CMReturnDone(rslt); - - if (ctxLocal) - CMRelease(ctxLocal); - -#else - st = IndServiceProviderGetInstance(mi, ctx, rslt, NULL, properties); -#endif - _SFCB_RETURN(st); } @@ -726,6 +681,7 @@ static CMPIStatus ServerProviderCleanup(CMPIInstanceMI * mi, const CMPIContext *ctx, CMPIBoolean terminate) { + CMRelease(ISinst); return okSt; } @@ -831,11 +787,12 @@ ServerProviderModifyInstance(CMPIInstanceMI * mi, const char **properties) { CMPIStatus rc = notSupSt; - CMPIContext *ctxLocal; - CMPIValue val; if (!CMClassPathIsA(_broker, cop, "cim_indicationservice", NULL)) return rc; + // Check that we have the right OP for IndicationService + if ( objectpathCompare(cop,ISinst->ft->getObjectPath(ISinst,NULL))) + return notFoundSt; // Get the settable props int settable=0; @@ -859,15 +816,11 @@ ServerProviderModifyInstance(CMPIInstanceMI * mi, if (settable > 0) return rc; // Ok, all is well to continue with the operation... - ctxLocal = native_clone_CMPIContext(ctx); - val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL, 0); - ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string); - rc = CBModifyInstance(_broker, ctxLocal, cop, ci, properties); - if (ctxLocal) - CMRelease(ctxLocal); + // Just replace the global instance with the new one. + ISinst=ci->ft->clone(ci,NULL); CMReturnInstance(rslt, ci); - return rc; -} + return okSt; +} /* ServerProviderDeleteInstance */ static CMPIStatus notSupCMPI_DI(ServerProvider); @@ -879,34 +832,12 @@ void ServerProviderInitInstances(const CMPIContext *ctx) { - /* only applicable if we're relying on InternalProvider */ -#ifdef SETTABLERETRY - CMPIStatus st; - CMPIInstance *ci; - CMPIObjectPath *op; - - CMPIValue val; - CMPIContext *ctxLocal; - - ctxLocal = native_clone_CMPIContext(ctx); - val.string = sfcb_native_new_CMPIString("$DefaultProvider$", NULL, 0); - ctxLocal->ft->addEntry(ctxLocal, "rerouteToProvider", &val, CMPI_string); - - op = makeIndServiceOP(); - - /* a brutal way to update values; because of this, changes don't persist */ - CBDeleteInstance(_broker,ctxLocal,op); - ci = CMNewInstance(_broker, op, &st); - - makeIndService(ci); - - op = CMGetObjectPath(ci, &st); - - CBCreateInstance(_broker, ctxLocal, op, ci, &st); - CMRelease(ctxLocal); -#endif - + CMPIObjectPath *ISop = makeIndServiceOP(); + // This instance is always recreated, changes don't persist + ISinst = CMNewInstance(_broker, ISop, &st); + makeIndService(ISinst); + memUnlinkInstance(ISinst); // Prevent cleanup of the instance return; } @@ -1168,18 +1099,14 @@ makeElementConforms(CMPIAssociationMI * mi, CMPIObjectPath * rpop, const char **propertyList, const char *target) { - CMPIEnumeration *isenm = NULL; CMPIStatus rc = { CMPI_RC_OK, NULL }; CMPIInstance *eci = NULL; - // Get the single instance of IndicationService - isenm = _broker->bft->enumerateInstanceNames(_broker, ctx, isop, &rc); - CMPIData isinst = CMGetNext(isenm, &rc); - // Get the IndicationProfile instance of RegisteredProfile CMAddKey(rpop, "InstanceID", "CIM:SFCB_IP", CMPI_chars); // Create an instance eci = CMNewInstance(_broker, ecop, &rc); - CMSetProperty(eci, "ManagedElement", &(isinst.value), CMPI_ref); + CMPIValue ISval = {.ref = ISinst->ft->getObjectPath(ISinst,NULL) }; + CMSetProperty(eci, "ManagedElement", &(ISval), CMPI_ref); CMSetProperty(eci, "ConformantStandard", &(rpop), CMPI_ref); if (strcasecmp(target, "Refs") == 0) { if (propertyList) { @@ -1191,8 +1118,6 @@ makeElementConforms(CMPIAssociationMI * mi, } if (eci) CMRelease(eci); - if (isenm) - CMRelease(isenm); CMReturnDone(rslt); CMReturn(CMPI_RC_OK); } @@ -1323,8 +1248,6 @@ static CMPIStatus handleAssocHostedService(CMPIAssociationMI* mi, && (CMClassPathIsA(_broker, cop, "cim_system", &rc) == 1)) { // A CIM_System was passed in so wee need to return either the // CIM_IndicationService instance or a CIM_HostedService association - // - // // instance if (((strcasecmp(target, "Assocs") == 0) || (strcasecmp(target, "AssocNames") == 0)) @@ -1332,20 +1255,16 @@ static CMPIStatus handleAssocHostedService(CMPIAssociationMI* mi, || (strcasecmp(resultClass, "CIM_IndicationService") == 0))) { // Return the CIM_IndicationService instance - CMPIEnumeration* isenm = - _broker->bft->enumerateInstances(_broker, ctx, isop, NULL, - &rc); - CMPIData inst = CMGetNext(isenm, &rc); + CMPIInstance *inst = ISinst->ft->clone(ISinst,NULL); + memLinkInstance(inst); if (strcasecmp(target, "Assocs") == 0) { if (propertyList) { - CMSetPropertyFilter(inst.value.inst, propertyList, NULL); + CMSetPropertyFilter(inst, propertyList, NULL); } - CMReturnInstance(rslt, (inst.value.inst)); + CMReturnInstance(rslt,inst); } else { - CMReturnObjectPath(rslt, CMGetObjectPath(inst.value.inst, NULL)); + CMReturnObjectPath(rslt, CMGetObjectPath(inst, NULL)); } - if (isenm) - CMRelease(isenm); } else if (resultClass == NULL || (strcasecmp(resultClass, "CIM_HostedService") == 0)) { // Return the CIM_HostedService instance diff --git a/sfcbmacs.h b/sfcbmacs.h index c583c6b..3a1d5c6 100644 --- a/sfcbmacs.h +++ b/sfcbmacs.h @@ -4,6 +4,7 @@ static CMPIStatus __attribute__ ((unused)) notSupSt = { CMPI_RC_ERR_NOT_SUPPORTED, NULL }; static CMPIStatus __attribute__ ((unused)) okSt = { CMPI_RC_OK, NULL }; +static CMPIStatus __attribute__ ((unused)) notFoundSt = { CMPI_RC_ERR_NOT_FOUND, NULL }; #define notSupCMPI_EQ(pfx) \ pfx##ExecQuery(CMPIInstanceMI __attribute__ ((unused)) *mi, \ diff --git a/support.h b/support.h index b98a1f9..92adf78 100644 --- a/support.h +++ b/support.h @@ -196,6 +196,7 @@ void *memAddEncObj(int mode, void *ptr, size_t size, int *memId); void memUnlinkEncObj(int memId); void memLinkEncObj(void *ptr, int *memId); void memLinkInstance(CMPIInstance *ci); +void memUnlinkInstance(CMPIInstance *ci); UtilList *memAddUtilList(UtilList* ul); void *markHeap(); hooks/post-receive -- sfcb - Small Footprint CIM Broker |