Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » thread bug....and fix
thread bug....and fix [message #52160] Tue, 30 July 2019 14:53 Go to previous message
aftershock is currently offline  aftershock
Messages: 141
Registered: May 2008
Experienced Member
Hi,
Bug report.
It seems that
handle can be 0 at unexpected places,
So I added additional checks for that to fix.
See added lines.
Wait function got stuck at WaitForSingleObject when handle was 0.
int Thread::Wait()
{
	if(!IsOpen())
		return -1;
	int out;
#ifdef PLATFORM_WIN32
	dword exit;
	if(!GetExitCodeThread(handle, &exit))
		return -1;
	if(exit != STILL_ACTIVE)
		out = (int)exit;
	else
	{
		if (!IsOpen())  // ADDED THIS LINE
		   return Null;	
		if(WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0)
			return Null;
		if (!IsOpen()) // ADDED THIS LINE
		   return Null;	
		out = GetExitCodeThread(handle, &exit) ? int(exit) : int(Null);
	}
	Detach();
#endif
#ifdef PLATFORM_POSIX
	void *thread_return;
	if(pthread_join(handle, &thread_return))
		out = Null;
	else
		out = (int)(intptr_t)thread_return;
	handle = 0;
#endif
	return out;
}

[Updated on: Wed, 31 July 2019 12:55]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Unable to run exe file in windows
Next Topic: ESC macro problem
Goto Forum:
  


Current Time: Tue Apr 07 11:22:04 CEST 2020

Total time taken to generate the page: 0.01020 seconds