Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15093/win32/src
Modified Files:
win32trace.cpp
Log Message:
Double the buffer, and check if it is nearly full before writing, rather
than after. The latter change alone fixes clients that spew huge amounts,
and the buffer doubling is for extra measure! (128k of memory-mapped space
is reasonable these days)
Index: win32trace.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32trace.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** win32trace.cpp 31 Aug 2003 23:05:53 -0000 1.10
--- win32trace.cpp 13 May 2004 14:14:53 -0000 1.11
***************
*** 40,44 ****
! const size_t BUFFER_SIZE = 0x10000; // Includes size integer.
const char *MAP_OBJECT_NAME = "PythonTraceOutputMapping";
const char *MUTEX_OBJECT_NAME = "PythonTraceOutputMutex";
--- 40,44 ----
! const size_t BUFFER_SIZE = 0x20000; // Includes size integer.
const char *MAP_OBJECT_NAME = "PythonTraceOutputMapping";
const char *MUTEX_OBJECT_NAME = "PythonTraceOutputMutex";
***************
*** 301,305 ****
while (len) {
unsigned len_this = min(len, BUFFER_SIZE/2);
! if (GetMyMutex()) {
size_t *pLen = (size_t *)pMapBaseWrite;
char *buffer = (char *)(((size_t *)pMapBaseWrite)+1);
--- 301,317 ----
while (len) {
unsigned len_this = min(len, BUFFER_SIZE/2);
! BOOL ok = GetMyMutex();
! if (ok) {
! size_t *pLen = (size_t *)pMapBaseWrite;
! size_t sizeLeft = (BUFFER_SIZE-sizeof(size_t)) - *pLen;
! // If less than double we need left, wait for it to empty, or .1 sec.
! if (sizeLeft < len_this * 2) {
! ReleaseMyMutex();
! SetEvent(hEvent);
! WaitForSingleObject(hEventEmpty, 100);
! ok = GetMyMutex();
! }
! }
! if (ok) {
size_t *pLen = (size_t *)pMapBaseWrite;
char *buffer = (char *)(((size_t *)pMapBaseWrite)+1);
***************
*** 314,323 ****
data_this += len_this;
len -= len_this;
- if (len) {
- // If we had to split up the data, we can have little sleep
- // to let a reader grab the data (but if a reader empties us
- // before the timeout, then we wake up)
- WaitForSingleObject(hEventEmpty, 10);
- }
}
}
--- 326,329 ----
|