Ensure that the cloned environment is retained until all environment objects
that were cloned from it have been destroyed.
This commit is contained in:
parent
3e6a6ef8b2
commit
2fc59ecb8d
@ -13,7 +13,7 @@ typedef struct {
|
|||||||
int maxBytesPerCharacter;
|
int maxBytesPerCharacter;
|
||||||
int fixedWidth;
|
int fixedWidth;
|
||||||
ub4 maxStringBytes;
|
ub4 maxStringBytes;
|
||||||
int cloned;
|
PyObject *cloneEnv;
|
||||||
} udt_Environment;
|
} udt_Environment;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -78,7 +78,7 @@ static udt_Environment *Environment_New(
|
|||||||
env->fixedWidth = 1;
|
env->fixedWidth = 1;
|
||||||
env->maxBytesPerCharacter = CXORA_BYTES_PER_CHAR;
|
env->maxBytesPerCharacter = CXORA_BYTES_PER_CHAR;
|
||||||
env->maxStringBytes = MAX_STRING_CHARS * CXORA_BYTES_PER_CHAR;
|
env->maxStringBytes = MAX_STRING_CHARS * CXORA_BYTES_PER_CHAR;
|
||||||
env->cloned = 0;
|
env->cloneEnv = NULL;
|
||||||
|
|
||||||
// create the error handle
|
// create the error handle
|
||||||
status = OCIHandleAlloc(handle, (dvoid**) &env->errorHandle,
|
status = OCIHandleAlloc(handle, (dvoid**) &env->errorHandle,
|
||||||
@ -174,7 +174,8 @@ static udt_Environment *Environment_Clone(
|
|||||||
env->maxBytesPerCharacter = cloneEnv->maxBytesPerCharacter;
|
env->maxBytesPerCharacter = cloneEnv->maxBytesPerCharacter;
|
||||||
env->maxStringBytes = cloneEnv->maxStringBytes;
|
env->maxStringBytes = cloneEnv->maxStringBytes;
|
||||||
env->fixedWidth = cloneEnv->fixedWidth;
|
env->fixedWidth = cloneEnv->fixedWidth;
|
||||||
env->cloned = 1;
|
Py_INCREF(cloneEnv);
|
||||||
|
env->cloneEnv = (PyObject*) cloneEnv;
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,8 +190,9 @@ static void Environment_Free(
|
|||||||
{
|
{
|
||||||
if (environment->errorHandle)
|
if (environment->errorHandle)
|
||||||
OCIHandleFree(environment->errorHandle, OCI_HTYPE_ERROR);
|
OCIHandleFree(environment->errorHandle, OCI_HTYPE_ERROR);
|
||||||
if (environment->handle && !environment->cloned)
|
if (environment->handle && !environment->cloneEnv)
|
||||||
OCIHandleFree(environment->handle, OCI_HTYPE_ENV);
|
OCIHandleFree(environment->handle, OCI_HTYPE_ENV);
|
||||||
|
Py_CLEAR(environment->cloneEnv);
|
||||||
PyObject_DEL(environment);
|
PyObject_DEL(environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user