OK... just when everything was looking good,
testing revealed that all was not well. I still need to test for longer but
early indications are, that the code changes in this one routine are the
cause.
(HTML alert)
This piece of code:
---
if
(!::WaitCommEvent(rsThreadData.hPortHandle,
&dwEvent,
&rsNotifyOverlapData)
)
{
dwError =
::GetLastError();
if (dwError ==
ERROR_IO_PENDING)
{
bDone = FALSE
;
// Wait for completion of
WaitCommEvent().
while (!rsThreadData.bTerminate
&& !bDone)
{
bDone =
::GetOverlappedResult(rsThreadData.hPortHandle,
&rsNotifyOverlapData,
&dwDummy,
FALSE);
dwError =
::GetLastError();
if (!bDone && dwError !=
ERROR_IO_INCOMPLETE)
bDone = TRUE ; // Real
error.
}
}
}
// V1.6 Beta 01: Manually reset
it now.
::ResetEvent(rsNotifyOverlapData.hEvent);
---
works just fine - it's been running for two hours non-stop now, no
problems. But change it to this:
---
if
(!::WaitCommEvent(rsThreadData.hPortHandle,
&dwEvent,
&rsNotifyOverlapData)
)
{
dwError =
::GetLastError();
if (dwError ==
ERROR_IO_PENDING)
{
// V1.6 Beta 01: Use a wait here, not
repeated calls!
bDone = FALSE
;
// Wait for completion of
WaitCommEvent().
::WaitForSingleObject(rsNotifyOverlapData.hEvent,
1000);
bDone =
::GetOverlappedResult(rsThreadData.hPortHandle,
&rsNotifyOverlapData,
&dwDummy,
FALSE);
}
}
// V1.6 Beta 01: Manually reset
it now.
::ResetEvent(rsNotifyOverlapData.hEvent);
---
causes the module / app to crash after an hour maximum (bear in mind
comms calls are coming at around 3 per second, so some 10,000 calls per
hour).
I've coloured the code that was removed /
added in grey, to try and make the simplicity of the change
clearer.
Does anyone have any ideas of what I might
have done wrong? It seems such a simple, innocent change that I can't believe it
causes this, but it does - repeatably. I've run it about four times now and it
crashes every time before getting anywhere near two
hours.
<POUT>
--
Jason
Teagle
[EMAIL PROTECTED]
_______________________________________________ msvc mailing list [email protected] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
