[Python-checkins] python/dist/src/Modules _bsddb.c,1.21,1.22

greg at users.sourceforge.net greg at users.sourceforge.net
Sun Nov 2 03:06:32 EST 2003


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv22559/Modules
Modified Files:
	_bsddb.c 
Log Message:
Fix a tuple memory leak when raising DB, DBEnv and DBCursor "object
has been closed" exceptions.
Adds a DBCursorClosedError exception in the closed cursor case for
future use in fixing the legacy bsddb interface deadlock problems
due to its use of cursors with DB_INIT_LOCK | DB_THREAD support
enabled.
Index: _bsddb.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** _bsddb.c	1 Oct 2003 06:48:51 -0000	1.21
--- _bsddb.c	2 Nov 2003 08:06:29 -0000	1.22
***************
*** 149,152 ****
--- 149,153 ----
 
 static PyObject* DBError; /* Base class, all others derive from this */
+ static PyObject* DBCursorClosedError; /* raised when trying to use a closed cursor object */
 static PyObject* DBKeyEmptyError; /* DB_KEYEMPTY */
 static PyObject* DBKeyExistError; /* DB_KEYEXIST */
***************
*** 259,283 ****
 #define RETURN_NONE() Py_INCREF(Py_None); return Py_None;
 
! #define CHECK_DB_NOT_CLOSED(dbobj) \
! if (dbobj->db == NULL) { \
! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \
! "DB object has been closed")); \
! return NULL; \
 }
 
! #define CHECK_ENV_NOT_CLOSED(env) \
! if (env->db_env == NULL) { \
! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \
! "DBEnv object has been closed"));\
! return NULL; \
! }
 
! #define CHECK_CURSOR_NOT_CLOSED(curs) \
! if (curs->dbc == NULL) { \
! PyErr_SetObject(DBError, Py_BuildValue("(is)", 0, \
! "DBCursor object has been closed"));\
! return NULL; \
! }
 
 
 
--- 260,280 ----
 #define RETURN_NONE() Py_INCREF(Py_None); return Py_None;
 
! #define _CHECK_OBJECT_NOT_CLOSED(nonNull, pyErrObj, name) \
! if ((nonNull) == NULL) { \
! PyObject *errTuple = NULL; \
! errTuple = Py_BuildValue("(is)", 0, #name " object has been closed"); \
! PyErr_SetObject((pyErrObj), errTuple); \
! 	Py_DECREF(errTuple); \
! return NULL; \
 }
 
! #define CHECK_DB_NOT_CLOSED(dbobj) \
! _CHECK_OBJECT_NOT_CLOSED(dbobj->db, DBError, DB)
 
! #define CHECK_ENV_NOT_CLOSED(env) \
! _CHECK_OBJECT_NOT_CLOSED(env->db_env, DBError, DBEnv)
 
+ #define CHECK_CURSOR_NOT_CLOSED(curs) \
+ _CHECK_OBJECT_NOT_CLOSED(curs->dbc, DBCursorClosedError, DBCursor)
 
 
***************
*** 4718,4721 ****
--- 4715,4719 ----
 MAKE_EX(DBIncompleteError);
 #endif
+ MAKE_EX(DBCursorClosedError);
 MAKE_EX(DBKeyEmptyError);
 MAKE_EX(DBKeyExistError);


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /