diehardii
October 7th, 2004, 08:22 AM
Hi everyone, I can't find a good reason for this and I was hoping someone here could enlighten me.
I have a (threaded) loop in my program. It pretty much just monitors a running process and if that process ends resets it. Under debug this runs just fine. When I go to release it hangs on the reset. Further testing showed that it isn't even getting to the reset instruction. So here's the weird part. If I add a Sleep(10) to the loop it works, or if I add another if..then statement it also works, however just the single if..then never gets called with the full optimization flag. I am genuinely very curious about this, considering I banged my head against the wall for awhile. What the heck???
~Steve
//Works
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("What the heck\n");
}
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
//Sleep(10);
}
return 0;
}
//Works
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
Sleep(10);
}
return 0;
}
//Doesn't work????
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
}
return 0;
}
I have a (threaded) loop in my program. It pretty much just monitors a running process and if that process ends resets it. Under debug this runs just fine. When I go to release it hangs on the reset. Further testing showed that it isn't even getting to the reset instruction. So here's the weird part. If I add a Sleep(10) to the loop it works, or if I add another if..then statement it also works, however just the single if..then never gets called with the full optimization flag. I am genuinely very curious about this, considering I banged my head against the wall for awhile. What the heck???
~Steve
//Works
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("What the heck\n");
}
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
//Sleep(10);
}
return 0;
}
//Works
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
Sleep(10);
}
return 0;
}
//Doesn't work????
DWORD WINAPI Monitor(void* arguments)
{
while(g_monitorkill == false)
{
if(g_reset == true)
{
printf("resetting\n");
Reset(Connection.IPaddress.c_str(),Connection.Port);
g_reset = false;
}
}
return 0;
}