Message1937
Logged In: YES
user_id=7549
>It is hanging up in ConsoleCloseProc() in 'tclWinConsole.c'
>at about line 527:
>WaitForSingleObject(consolePtr->writeThread, INFINITE);
Jeff, this might need the same attention the pipe reader
thread got for that [exec] memory leak bug. I think
ConsoleWriterThread() should use WaitForMultipleObjects
instead of WaitForSingleObject with a second event handle
used to single a fall-out like the pipe reader thread does. It
appears that ConsoleCloseProc() has no way to signal the
writer thread to close at all.
This doesn't address the blocking WriteFile() in
ConsoleWriterThread(), though. Is it blocking there, too?
Sorry for the large post. I'm given the option to attach a file.
Index: tclWinConsole.c
=============================================
======================
RCS file: /cvsroot/tcl/tcl/win/tclWinConsole.c,v
retrieving revision 1.7
diff -c -r1.7 tclWinConsole.c
*** tclWinConsole.c 15 Jan 2002 17:55:30 -0000 1.7
--- tclWinConsole.c 16 Aug 2002 21:31:56 -0000
***************
*** 79,84 ****
--- 79,87 ----
HANDLE startWriter; /* Auto-reset
event used by the main thread to
* signal when
the writer thread should attempt
* to write to the
console. */
+ HANDLE stopWriter; /* Auto-reset
event used by the main thread to
+ * signal when
the writer thread should
+ * terminate. */
HANDLE startReader; /* Auto-reset
event used by the main thread to
* signal when
the reader thread should attempt
* to read from
the console. */
***************
*** 516,522 ****
*/
Tcl_MutexLock(&consoleMutex);
! TerminateThread(consolePtr->writeThread, 0);
/*
* Wait for the thread to terminate. This ensures
that we are
--- 519,525 ----
*/
Tcl_MutexLock(&consoleMutex);
! SetEvent(consolePtr->stopWriter);
/*
* Wait for the thread to terminate. This ensures
that we are
***************
*** 1134,1149 ****
{
ConsoleInfo *infoPtr = (ConsoleInfo *)arg;
HANDLE *handle = infoPtr->handle;
DWORD count, toWrite;
char *buf;
for (;;) {
/*
* Wait for the main thread to signal before
attempting to write.
*/
! WaitForSingleObject(infoPtr->startWriter,
INFINITE);
buf = infoPtr->writeBuf;
toWrite = infoPtr->toWrite;
--- 1137,1163 ----
{
ConsoleInfo *infoPtr = (ConsoleInfo *)arg;
+ HANDLE events[2];
HANDLE *handle = infoPtr->handle;
DWORD count, toWrite;
char *buf;
+ events[0] = infoPtr->stopWriter;
+ events[1] = infoPtr->startWriter;
+
for (;;) {
+ DWORD dwWait;
+
/*
* Wait for the main thread to signal before
attempting to write.
*/
! dwWait = WaitForMultipleObjects(events, 2,
FALSE, INFINITE);
!
! if (dwWait != (WAIT_OBJECT_0 + 1)) {
! /* either the stop event or some other error, so
exit */
! return 0;
! }
buf = infoPtr->writeBuf;
toWrite = infoPtr->toWrite;
***************
*** 1251,1256 ****
--- 1265,1271 ----
if (permissions & TCL_WRITABLE) {
infoPtr->writable = CreateEvent(NULL, TRUE,
TRUE, NULL);
infoPtr->startWriter = CreateEvent(NULL, FALSE,
FALSE, NULL);
+ infoPtr->stopWriter = CreateEvent(NULL, FALSE,
FALSE, NULL);
infoPtr->writeThread = CreateThread(NULL, 8000,
ConsoleWriterThread,
infoPtr, 0, &id);
}
|
|
Date |
User |
Action |
Args |
2007-08-23 13:51:19 | admin | link | issue216289 messages |
2007-08-23 13:51:19 | admin | create | |
|