Update of /cvsroot/pywin32/pywin32/isapi/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18021/src
Modified Files:
PyExtensionObjects.cpp PyExtensionObjects.h
Log Message:
Change how we check for a valid ECB and remove some unused and unreliable code
Index: PyExtensionObjects.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PyExtensionObjects.h 4 Jan 2007 08:19:59 -0000 1.3
--- PyExtensionObjects.h 7 Mar 2007 01:54:13 -0000 1.4
***************
*** 65,76 ****
PyObject * m_logData; // log data string
- bool m_bAsyncDone; // sent the async done
-
public:
PyECB(CControlBlock * pcb = NULL);
~PyECB();
!
! bool FinishedResponse(void) { return m_bAsyncDone; }
! public:
// Python support
static void deallocFunc(PyObject *ob);
--- 65,80 ----
PyObject * m_logData; // log data string
public:
PyECB(CControlBlock * pcb = NULL);
~PyECB();
!
! BOOL Check() {
! if (!m_pcb || !m_pcb->GetECB()) {
! assert(!PyErr_Occurred());
! PyErr_SetString(PyExc_RuntimeError, "Invalid ECB (DoneWithSession has been called)");
! return FALSE;
! }
! return TRUE;
! }
// Python support
static void deallocFunc(PyObject *ob);
***************
*** 98,108 ****
static PyObject * IsSessionActive(PyObject *self, PyObject * args);
-
protected:
-
#pragma warning( disable : 4251 )
static struct memberlist PyECB_memberlist[];
#pragma warning( default : 4251 )
-
};
--- 102,109 ----
***************
*** 111,114 ****
PyObject * SetPyECBError(char *fnName, long err=0);
!
! #endif // __PyExtensionObjects_H__
\ No newline at end of file
--- 112,114 ----
PyObject * SetPyECBError(char *fnName, long err=0);
! #endif // __PyExtensionObjects_H__
Index: PyExtensionObjects.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/isapi/src/PyExtensionObjects.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** PyExtensionObjects.cpp 4 Jan 2007 08:19:59 -0000 1.6
--- PyExtensionObjects.cpp 7 Mar 2007 01:54:13 -0000 1.7
***************
*** 153,157 ****
{"DoneWithSession", PyECB::DoneWithSession, 1}, // @pymeth DoneWithSession|
{"close", PyECB::DoneWithSession, 1}, // @pymeth close|A synonym for DoneWithSession.
- {"IsSessionActive", PyECB::IsSessionActive,1}, // @pymeth IsSessionActive|Indicates if DoneWithSession has been called
{"Redirect", PyECB::Redirect,1}, // @pymeth Redirect|
{"IsKeepAlive", PyECB::IsKeepAlive,1}, // @pymeth IsKeepAlive|
--- 153,156 ----
***************
*** 199,205 ****
m_HttpStatusCode(0), // @prop int|HttpStatusCode|The status of the current transaction when the request is completed.
! m_logData(NULL), // @prop string|LogData|log data string
!
! m_bAsyncDone(false) // async done
{
ob_type = &PyECBType;
--- 198,202 ----
m_HttpStatusCode(0), // @prop int|HttpStatusCode|The status of the current transaction when the request is completed.
! m_logData(NULL) // @prop string|LogData|log data string
{
ob_type = &PyECBType;
***************
*** 393,442 ****
PyObject * PyECB::ReadClient(PyObject *self, PyObject *args)
{
-
PyECB * pecb = (PyECB *) self;
BOOL bRes = FALSE;
BYTE * pBuff = NULL;
! DWORD nSize = 0;
!
! if (pecb->m_pcb){
! nSize = pecb->m_totalBytes - pecb->m_available;
! }
! // @pyparm int|nbytes|0|
if (!PyArg_ParseTuple(args, "|l:ReadClient", &nSize))
return NULL;
!
! if (pecb->m_pcb){
! Py_BEGIN_ALLOW_THREADS
! if (nSize < 1)
! nSize = 1;
! DWORD orgSize = nSize;
! DWORD bytesGot= nSize;
! pBuff = new BYTE[nSize];
! bRes = pecb->m_pcb->ReadClient(pBuff, &bytesGot);
! if (bytesGot<orgSize){
! DWORD extraBytes = orgSize-bytesGot;
! DWORD offset=bytesGot;
! while (extraBytes > 0){
bytesGot=extraBytes;
! bRes = pecb->m_pcb->ReadClient(&pBuff[offset], &bytesGot);
! if (bytesGot <1)
! break;
!
! extraBytes -= bytesGot;
offset += bytesGot;
}
if (extraBytes>0)
nSize -= extraBytes;
! }
!
! Py_END_ALLOW_THREADS
! if (!bRes){
! delete [] pBuff;
! return SetPyECBError("ReadClient");
! }
}
--- 390,430 ----
PyObject * PyECB::ReadClient(PyObject *self, PyObject *args)
{
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
BOOL bRes = FALSE;
BYTE * pBuff = NULL;
! DWORD nSize = pecb->m_totalBytes - pecb->m_available;
! // @pyparm int|nbytes||Default is to read all available data.
if (!PyArg_ParseTuple(args, "|l:ReadClient", &nSize))
return NULL;
! Py_BEGIN_ALLOW_THREADS
! assert (nSize >= 0); // DWORD == unsigned == >= 0
! DWORD orgSize = nSize;
! DWORD bytesGot= nSize;
! pBuff = new BYTE[nSize];
! bRes = pecb->m_pcb->ReadClient(pBuff, &bytesGot);
! if (bytesGot<orgSize){
! DWORD extraBytes = orgSize-bytesGot;
! DWORD offset=bytesGot;
! while (extraBytes > 0){
bytesGot=extraBytes;
! bRes = pecb->m_pcb->ReadClient(&pBuff[offset], &bytesGot);
! if (bytesGot <1)
! break;
!
! extraBytes -= bytesGot;
offset += bytesGot;
}
if (extraBytes>0)
nSize -= extraBytes;
! }
! Py_END_ALLOW_THREADS
! if (!bRes){
! delete [] pBuff;
! return SetPyECBError("ReadClient");
}
***************
*** 450,454 ****
return pyRes;
-
}
--- 438,441 ----
***************
*** 463,466 ****
--- 450,454 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
// @pyparm string|reply||
***************
*** 489,492 ****
--- 477,481 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
// @pyparm string|url||The URL to redirect to
***************
*** 513,516 ****
--- 502,506 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
HANDLE handle;
BOOL bRes;
***************
*** 530,533 ****
--- 520,524 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
BOOL bRes, bIs;
Py_BEGIN_ALLOW_THREADS
***************
*** 620,623 ****
--- 611,615 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
BOOL bRes;
***************
*** 642,645 ****
--- 634,638 ----
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
if (!PyArg_ParseTuple(args, ":IsKeepAlive"))
***************
*** 659,662 ****
--- 652,656 ----
{
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
// todo - handle ERROR_INSUFFICIENT_BUFFER - but 4k will do for now.
char buffer[1024*4];
***************
*** 683,686 ****
--- 677,681 ----
DWORD status = HSE_STATUS_SUCCESS;
PyECB * pecb = (PyECB *) self;
+ if (!pecb || !pecb->Check()) return NULL;
// @pyparm int|status|HSE_STATUS_SUCCESS|An optional status.
***************
*** 689,718 ****
return NULL;
! if (pecb->m_pcb){
! Py_BEGIN_ALLOW_THREADS
! pecb->m_pcb->DoneWithSession(status);
! pecb->m_bAsyncDone = true;
! Py_END_ALLOW_THREADS
! }
Py_INCREF(Py_None);
return Py_None;
}
- // @pymethod bool|EXTENSION_CONTROL_BLOCK|IsSessionActive|Indicates if <om EXTENSION_CONTROL_BLOCK.DoneWithSession>
- // has been called.
- PyObject * PyECB::IsSessionActive(PyObject *self, PyObject * args)
- {
- PyECB * pecb = (PyECB *) self;
-
- if (!PyArg_ParseTuple(args, ":IsSessionActive"))
- return NULL;
-
- BOOL bActive = FALSE;
- if (pecb->m_pcb){
- bActive = (pecb->m_bAsyncDone) ? FALSE : TRUE;
- }
- return PyBool_FromLong(bActive);
- }
-
// Setup an exception
--- 684,696 ----
return NULL;
! Py_BEGIN_ALLOW_THREADS
! pecb->m_pcb->DoneWithSession(status);
! Py_END_ALLOW_THREADS
! pecb->m_pcb->Done();
! pecb->m_pcb = NULL;
Py_INCREF(Py_None);
return Py_None;
}
// Setup an exception
|