What reasons are known a thread stops suddenly?

tcak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 4 12:25:27 PST 2016


I have implemented a standalone HTTP server. So everything is in 
single executable. Requests come, for responding a new thread is 
started, etc.

To listen new socket connections, and socket events, a single 
thread is used (Call this event listener thread).

Everything works perfectly. Firefox asks for page, all HTML, JS, 
CSS, Image requests come and responded properly.

Now, when I start the executable, instead of calling the page on 
Firefox by pressing F5 for refresh, if I press Ctrl+Shift+F5, 
Firefox asks for same requests as always do, but that event 
listener thread suddenly stops.

You might say that is a programming error of mine, but problem is 
as follows:

void threadFunc(){
	scope(exit){
		writeln("Leaving 2: ", stopRequested);
	}


	while( !stopRequested ){
/* THERE IS NO "RETURN" HERE AT ALL */
	}

	writeln("Leaving 1: ", stopRequested);
}



While loop is running, suddenly "Leaving 2: false" is seen. 
Checked with exception, but there is nothing. GDB doesn't show 
any error. There is no "Leaving 1: .." message at all.

Is there any known reason for a thread to suddenly stop like this?


More information about the Digitalmars-d-learn mailing list