[pywin32-checkins] pywin32/win32/src PyOVERLAPPED.cpp,1.8,1.9 win32file.i,1.47,1.48
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-06-28 12:36:12
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20512 Modified Files: PyOVERLAPPED.cpp win32file.i Log Message: Fix errors in OVERLAPPED.object reference counting for 'queued' completion status. Index: PyOVERLAPPED.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyOVERLAPPED.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyOVERLAPPED.cpp 7 Nov 2003 03:58:17 -0000 1.8 --- PyOVERLAPPED.cpp 28 Jun 2005 12:35:54 -0000 1.9 *************** *** 203,206 **** --- 203,209 ---- /*static*/ void PyOVERLAPPED::deallocFunc(PyObject *ob) { + // set memory to zero, so our clunky check for an invalid object in + // win32file has more chance of success. + memset(ob, 0, sizeof(PyOVERLAPPED)); delete (PyOVERLAPPED *)ob; } Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** win32file.i 2 Jun 2005 00:03:33 -0000 1.47 --- win32file.i 28 Jun 2005 12:35:59 -0000 1.48 *************** *** 1237,1241 **** // makes it impossible it has died, but other functions do not as they // don't know if the OVERLAPPED will end up in a IOCP) ! if (po->ob_refcnt<=0) { PyErr_SetString(PyExc_RuntimeError, "This overlapped object has lost all its references so was destroyed"); return NULL; --- 1237,1244 ---- // makes it impossible it has died, but other functions do not as they // don't know if the OVERLAPPED will end up in a IOCP) ! // Also check it is a valid write pointer (we don't write to it, but all ! // PyObjects are writable, so that extra check is worthwhile) ! // This is NOT foolproof - screw up reference counting and things may die! ! if (po->ob_refcnt<=0 || po->ob_type==0 || IsBadWritePtr(po, sizeof(PyOVERLAPPED))) { PyErr_SetString(PyExc_RuntimeError, "This overlapped object has lost all its references so was destroyed"); return NULL; *************** *** 1262,1269 **** if (!po) return FALSE; ! PyOVERLAPPED::sMyOverlapped *pMyOverlapped = (PyOVERLAPPED::sMyOverlapped *)po; // Add a fake reference so the object lives while in the queue, and add the flag Py_INCREF(ob); ! pMyOverlapped->isArtificialReference = TRUE; *ppOverlapped = po->GetOverlapped(); return TRUE; --- 1265,1273 ---- if (!po) return FALSE; ! ! PyOVERLAPPED *pO = (PyOVERLAPPED *)po; // Add a fake reference so the object lives while in the queue, and add the flag Py_INCREF(ob); ! pO->m_overlapped.isArtificialReference = TRUE; *ppOverlapped = po->GetOverlapped(); return TRUE; |