|
From: <ba...@us...> - 2009-02-26 04:03:54
|
Revision: 1165
http://omc.svn.sourceforge.net/omc/?rev=1165&view=rev
Author: bartw
Date: 2009-02-26 04:03:49 +0000 (Thu, 26 Feb 2009)
Log Message:
-----------
Pass cleanup function along to providers so they can perform necessary
cleanup. Allow them to specify that they don't want to be unloaded.
Modified Paths:
--------------
cmpi-bindings/trunk/src/cmpi_provider.c
cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
Modified: cmpi-bindings/trunk/src/cmpi_provider.c
===================================================================
--- cmpi-bindings/trunk/src/cmpi_provider.c 2009-01-27 21:42:25 UTC (rev 1164)
+++ cmpi-bindings/trunk/src/cmpi_provider.c 2009-02-26 04:03:49 UTC (rev 1165)
@@ -212,7 +212,35 @@
const CMPIContext * context,
CMPIBoolean terminating)
{
- CMPIStatus status = {CMPI_RC_OK, NULL}; /* Return status of CIM operations. */
+ _SBLIM_TRACE(1,("Cleanup() called, miHdl %p, miHdl->instance %p, context %p, terminating %d",
+ miHdl, miHdl->instance, context, terminating));
+ CMPIStatus status = {CMPI_RC_OK, NULL};
+
+ // If an instance/method provider is loaded, but only an instance operation
+ // is called, Cleanup() will be called twice (once for instance, once
+ // for method). However, since only instance operations were requested,
+ // miHdl->instance won't be set for one of the calls to Cleanup().
+ if (miHdl->instance != Target_Null)
+ {
+ Target_Type _context;
+ Target_Type _terminating;
+
+ TARGET_THREAD_BEGIN_BLOCK;
+ _context = SWIG_NewPointerObj((void*) context,
+ SWIGTYPE_p__CMPIContext, 0);
+ _terminating = Target_Bool(terminating);
+
+ TargetCall(miHdl, &status, "cleanup", 2, _context, _terminating);
+ TARGET_THREAD_END_BLOCK;
+ _SBLIM_TRACE(1,("Cleanup() %d", status.rc));
+ }
+
+ if (!terminating && (status.rc == CMPI_RC_DO_NOT_UNLOAD ||
+ status.rc == CMPI_RC_NEVER_UNLOAD))
+ {
+ _SBLIM_TRACE(1,("Cleanup() Provider requested not to be unloaded."));
+ return status;
+ }
if (miHdl != NULL)
{
@@ -224,7 +252,6 @@
free(miHdl);
miHdl = NULL;
}
-
TargetCleanup();
_SBLIM_TRACE(1,("Cleanup() %s", (status.rc == CMPI_RC_OK)? "succeeded":"failed"));
Modified: cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py
===================================================================
--- cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2009-01-27 21:42:25 UTC (rev 1164)
+++ cmpi-bindings/trunk/swig/python/cmpi_pywbem_bindings.py 2009-02-26 04:03:49 UTC (rev 1165)
@@ -673,6 +673,18 @@
return (0, '')
+ def cleanup(self, ctx, terminating):
+ env = ProviderEnvironment(self, ctx)
+ try:
+ if not terminating:
+ if not self.proxy.MI_canunload(env):
+ return (cmpi.CMPI_RC_DO_NOT_UNLOAD, '')
+ self.proxy.MI_shutdown(env)
+ except pywbem.CIMError, args:
+ return args[:2]
+
+ return (0, '')
+
# conversion routines
#######################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|