Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c55485b

Browse files
committed
use PyBUF_LOCK instead of PyBUF_SIMPLE for bsddb data access as it'll often
be using the data buffer provided without the GIL held.
1 parent 74ca557 commit c55485b

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Modules/_bsddb.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,9 @@ static Py_buffer * _malloc_view(PyObject *obj)
312312
"Py_buffer malloc failed");
313313
return NULL;
314314
}
315-
/* XXX(gps): PyBUF_LOCKDATA is desired to prevent other theads from
316-
trashing the data buffer while we release the GIL during the db
317-
operation. see http://bugs.python.org/issue1035 */
318-
if (PyObject_GetBuffer(obj, view, PyBUF_SIMPLE) == -1) {
315+
/* We use PyBUF_LOCK to prevent other threads from trashing the data
316+
buffer while we release the GIL. http://bugs.python.org/issue1035 */
317+
if (PyObject_GetBuffer(obj, view, PyBUF_LOCK) == -1) {
319318
PyMem_Free(view);
320319
return NULL;
321320
}

0 commit comments

Comments
 (0)