On Tue, 06 Sep 2016 11:53:11 GMT, Alexey Kulentsov wrote:

It's not about sharing connection, because when I replace waitForConnectionClose() for explicit waiting loop then problem disappears. Now this method looks like:

void setExitByHTTPClose(HTTPServerResponse response)
{
	runTask((){
			while(response.connected())
				sleep(5.seconds);
			if(stillRunning)
				writer.send(WriterCommand.JustExit);
	});
}


You said

It was a bad idea because when this function running, you can't write to response bodyWriter.

But how you can write to bodyWriter when running waitForConnectionClose() without creating parallel task and sharing connection between them?
However, I believe that waitForConnectionClose() should not take ownership.

Could you post your previous problematic code, please.