@@ -596,6 +596,8 @@ static PyObject *cxoConnection_changePassword(cxoConnection *conn,
596596 int status ;
597597
598598 // parse the arguments
599+ if (cxoConnection_isConnected (conn ) < 0 )
600+ return NULL ;
599601 if (!PyArg_ParseTuple (args , "OO" , & oldPasswordObj , & newPasswordObj ))
600602 return NULL ;
601603
@@ -1027,6 +1029,8 @@ static int cxoConnection_setCallTimeout(cxoConnection* conn, PyObject *value,
10271029//-----------------------------------------------------------------------------
10281030static PyObject * cxoConnection_getType (cxoConnection * conn , PyObject * nameObj )
10291031{
1032+ if (cxoConnection_isConnected (conn ) < 0 )
1033+ return NULL ;
10301034 return (PyObject * ) cxoObjectType_newByName (conn , nameObj );
10311035}
10321036
@@ -1082,6 +1086,8 @@ static PyObject *cxoConnection_getVersion(cxoConnection *conn, void *unused)
10821086 char buffer [25 ];
10831087 int status ;
10841088
1089+ if (cxoConnection_isConnected (conn ) < 0 )
1090+ return NULL ;
10851091 Py_BEGIN_ALLOW_THREADS
10861092 status = dpiConn_getServerVersion (conn -> handle , NULL , NULL , & versionInfo );
10871093 Py_END_ALLOW_THREADS
@@ -1181,10 +1187,13 @@ static PyObject *cxoConnection_close(cxoConnection *conn, PyObject *args)
11811187 Py_BEGIN_ALLOW_THREADS
11821188 status = dpiConn_close (conn -> handle , mode , (char * ) tagBuffer .ptr ,
11831189 tagBuffer .size );
1190+ if (status == DPI_SUCCESS )
1191+ dpiConn_release (conn -> handle );
11841192 Py_END_ALLOW_THREADS
11851193 cxoBuffer_clear (& tagBuffer );
11861194 if (status < 0 )
11871195 return cxoError_raiseAndReturnNull ();
1196+ conn -> handle = NULL ;
11881197
11891198 Py_RETURN_NONE ;
11901199}
@@ -1300,6 +1309,8 @@ static PyObject *cxoConnection_newCursor(cxoConnection *conn, PyObject *args,
13001309 PyObject * createArgs , * result , * arg ;
13011310 Py_ssize_t numArgs = 0 , i ;
13021311
1312+ if (cxoConnection_isConnected (conn ) < 0 )
1313+ return NULL ;
13031314 if (args )
13041315 numArgs = PyTuple_GET_SIZE (args );
13051316 createArgs = PyTuple_New (1 + numArgs );
@@ -1342,6 +1353,8 @@ static PyObject *cxoConnection_cancel(cxoConnection *conn, PyObject *args)
13421353static PyObject * cxoConnection_newEnqueueOptions (cxoConnection * conn ,
13431354 PyObject * args )
13441355{
1356+ if (cxoConnection_isConnected (conn ) < 0 )
1357+ return NULL ;
13451358 return (PyObject * ) cxoEnqOptions_new (conn , NULL );
13461359}
13471360
@@ -1353,6 +1366,8 @@ static PyObject *cxoConnection_newEnqueueOptions(cxoConnection *conn,
13531366static PyObject * cxoConnection_newDequeueOptions (cxoConnection * conn ,
13541367 PyObject * args )
13551368{
1369+ if (cxoConnection_isConnected (conn ) < 0 )
1370+ return NULL ;
13561371 return (PyObject * ) cxoDeqOptions_new (conn , NULL );
13571372}
13581373
@@ -1379,6 +1394,8 @@ static PyObject *cxoConnection_newMessageProperties(cxoConnection *conn,
13791394 & payloadObj , & correlationObj , & delay , & exceptionQObj , & expiration ,
13801395 & priority ))
13811396 return NULL ;
1397+ if (cxoConnection_isConnected (conn ) < 0 )
1398+ return NULL ;
13821399
13831400 // create new message properties object
13841401 props = cxoMsgProps_new (conn , NULL );
@@ -1481,6 +1498,8 @@ static PyObject *cxoConnection_dequeue(cxoConnection *conn, PyObject* args,
14811498 & nameObj , & cxoPyTypeDeqOptions , & optionsObj , & cxoPyTypeMsgProps ,
14821499 & propertiesObj , & cxoPyTypeObject , & payloadObj ))
14831500 return NULL ;
1501+ if (cxoConnection_isConnected (conn ) < 0 )
1502+ return NULL ;
14841503 if (cxoBuffer_fromObject (& nameBuffer , nameObj ,
14851504 conn -> encodingInfo .encoding ) < 0 )
14861505 return NULL ;
@@ -1526,6 +1545,8 @@ static PyObject *cxoConnection_enqueue(cxoConnection *conn, PyObject* args,
15261545 & nameObj , & cxoPyTypeEnqOptions , & optionsObj , & cxoPyTypeMsgProps ,
15271546 & propertiesObj , & cxoPyTypeObject , & payloadObj ))
15281547 return NULL ;
1548+ if (cxoConnection_isConnected (conn ) < 0 )
1549+ return NULL ;
15291550 if (cxoBuffer_fromObject (& nameBuffer , nameObj ,
15301551 conn -> encodingInfo .encoding ) < 0 )
15311552 return NULL ;
@@ -1566,6 +1587,8 @@ static PyObject *cxoConnection_queue(cxoConnection *conn, PyObject* args,
15661587 if (!PyArg_ParseTupleAndKeywords (args , keywordArgs , "O|O!" , keywordList ,
15671588 & nameObj , & cxoPyTypeObjectType , & typeObj ))
15681589 return NULL ;
1590+ if (cxoConnection_isConnected (conn ) < 0 )
1591+ return NULL ;
15691592 if (cxoBuffer_fromObject (& nameBuffer , nameObj ,
15701593 conn -> encodingInfo .encoding ) < 0 )
15711594 return NULL ;
@@ -1596,6 +1619,8 @@ static PyObject *cxoConnection_queue(cxoConnection *conn, PyObject* args,
15961619static PyObject * cxoConnection_contextManagerEnter (cxoConnection * conn ,
15971620 PyObject * args )
15981621{
1622+ if (cxoConnection_isConnected (conn ) < 0 )
1623+ return NULL ;
15991624 Py_INCREF (conn );
16001625 return (PyObject * ) conn ;
16011626}
@@ -1743,6 +1768,8 @@ static PyObject *cxoConnection_subscribe(cxoConnection *conn, PyObject* args,
17431768 & params .groupingValue , & params .groupingType , & name ,
17441769 & clientInitiatedObj ))
17451770 return NULL ;
1771+ if (cxoConnection_isConnected (conn ) < 0 )
1772+ return NULL ;
17461773 if (cxoUtils_getBooleanValue (clientInitiatedObj , 0 ,
17471774 & params .clientInitiated ) < 0 )
17481775 return NULL ;
@@ -1832,6 +1859,8 @@ static PyObject *cxoConnection_unsubscribe(cxoConnection *conn, PyObject* args,
18321859 if (!PyArg_ParseTupleAndKeywords (args , keywordArgs , "O!" , keywordList ,
18331860 & cxoPyTypeSubscr , & subscrObj ))
18341861 return NULL ;
1862+ if (cxoConnection_isConnected (conn ) < 0 )
1863+ return NULL ;
18351864
18361865 // destroy ODPI-C subscription
18371866 subscr = (cxoSubscr * ) subscrObj ;
0 commit comments