[pywin32-checkins] pywin32/win32/src win32file.i,1.45,1.46
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-04-12 02:56:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18491/src Modified Files: win32file.i Log Message: Fix [ 1178513 ] Invalid handle with win32file.CreateIoCompletionPort This function now correctly returns the existing handle when one is passed Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** win32file.i 7 Jan 2005 00:11:03 -0000 1.45 --- win32file.i 12 Apr 2005 02:56:44 -0000 1.46 *************** *** 226,236 **** #ifndef MS_WINCE // @pyswig <o PyHANDLE>|CreateIoCompletionPort|Can associate an instance of an opened file with a newly created or an existing input/output (I/O) completion port; or it can create an I/O completion port without associating it with a file. ! PyHANDLE CreateIoCompletionPort ( ! HANDLE FileHandle, // @pyparm <o PyHANDLE>|handle||file handle to associate with the I/O completion port ! HANDLE INPUT_NULLOK, // @pyparm <o PyHANDLE>|existing||handle to the I/O completion port ! DWORD CompletionKey, // @pyparm int|completionKey||per-file completion key for I/O completion packets ! DWORD NumberOfConcurrentThreads // @pyparm int|numThreads||number of threads allowed to execute concurrently ! ); // @pyswig |DefineDosDevice|Lets an application define, redefine, or delete MS-DOS device names. --- 226,275 ---- #ifndef MS_WINCE + // CreateIoCompletionPort gets special treatment due to its special result + // code handling. + + %{ // @pyswig <o PyHANDLE>|CreateIoCompletionPort|Can associate an instance of an opened file with a newly created or an existing input/output (I/O) completion port; or it can create an I/O completion port without associating it with a file. ! // @rdesc If an existing handle to a completion port is passed, the result ! // of this function will be that same handle. See MSDN for more details. ! PyObject *MyCreateIoCompletionPort(PyObject *self, PyObject *args) ! { ! PyObject *obFileHandle, *obExistingHandle; ! int key, nt; ! PyObject *obRet = NULL; ! if (!PyArg_ParseTuple(args, "OOii:CreateIoCompletionPort", ! &obFileHandle, // @pyparm <o PyHANDLE>|handle||file handle to associate with the I/O completion port ! &obExistingHandle, // @pyparm <o PyHANDLE>|existing||handle to the I/O completion port ! &key, // @pyparm int|completionKey||per-file completion key for I/O completion packets ! &nt)) // @pyparm int|numThreads||number of threads allowed to execute concurrently ! return NULL; ! HANDLE hFile, hExisting; ! if (!PyWinObject_AsHANDLE(obFileHandle, &hFile, FALSE)) ! return NULL; ! if (!PyWinObject_AsHANDLE(obExistingHandle, &hExisting, TRUE)) ! return NULL; ! if (hExisting) { ! obRet = obExistingHandle; ! Py_INCREF(obRet); ! } ! HANDLE hRet; ! Py_BEGIN_ALLOW_THREADS ! hRet = CreateIoCompletionPort(hFile, hExisting, key, nt); ! Py_END_ALLOW_THREADS ! if (!hRet) { ! Py_XDECREF(obRet); ! return PyWin_SetAPIError("CreateIoCompletionPort"); ! } ! if (obRet==NULL) // New handle returned ! obRet = PyWinObject_FromHANDLE(hRet); ! else ! // it better have returned the same object! ! assert(hRet == hExisting); ! return obRet; ! } ! ! %} ! ! %native (CreateIoCompletionPort) MyCreateIoCompletionPort; // @pyswig |DefineDosDevice|Lets an application define, redefine, or delete MS-DOS device names. |