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++ MT-multithreading and servers » Skylark logs failure in accept()
Skylark logs failure in accept() [message #37160] Sat, 01 September 2012 15:03 Go to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi,

I'm running a Skylark based server app and I get a lot of this error in the log:
Quote:

Accept failed: accept: Resource temporarily unavailable
It appears on average once every 10 requests or so. When I run the same server single-threaded in debug mode it doesn't happen. I don't know the socket stuff good enough to point my finger at the culprit, but it seems as if sometimes one thread tries to handle a request that is already being handled by some other thread. As far as I can say it doesn't affect the behavior of the app, so it is not really a bug - but if it didn't happen the app might have slightly better performance Smile

Honza
Re: Skylark logs failure in accept() [message #37161 is a reply to message #37160] Sun, 02 September 2012 08:59 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Interesting.

I think it is caused by something wrong in our emulation of "blocking" accept.

bool TcpSocket::Accept(TcpSocket& ls)
{
	Close();
	Init();
	Reset();
	ASSERT(ls.IsOpen());
	if(timeout) { // <<< Timeout should be Null
		int h = ls.GetTimeout();
		bool b = ls.Timeout(timeout).Wait(WAIT_READ, GetEndTime()); // <<< This should do the waiting until some request is available
		ls.Timeout(h);
		if(!b)
			return false;
	}
	socket = accept(ls.GetSOCKET(), NULL, NULL);
	if(socket == INVALID_SOCKET) {
		SetSockError("accept");
		return false;
	}
	mode = ACCEPT;
	return SetupSocket();
}


Basically, error reported is EAGAIN, which is sort of "non-error", it only means that operation should be performed again later. But it should not happen anyway...

On the other way, if there is a "legal" way how it can get EAGAIN there, easy fix would be to return false for EAGAIN and timeout not Null and to loop back if timeout is Null (to be blocking).

Mirek
Re: Skylark logs failure in accept() [message #37162 is a reply to message #37161] Sun, 02 September 2012 10:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Now, thinking about it, I guess it can rather be associated with prefork... Do you have prefork > 1 ?

Mirek
Re: Skylark logs failure in accept() [message #37165 is a reply to message #37162] Sun, 02 September 2012 12:08 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Sun, 02 September 2012 10:10

Now, thinking about it, I guess it can rather be associated with prefork... Do you have prefork > 1 ?

Mirek

Oops, I forgot to mention that. I run the server with prefork=2 and threads at default (machine has 1 CPU -> 4 threads).

I will publish the sources in couple of days, I just need to fix couple last errors I found when I run it in production settings, so then it will be available for testing.

Honza
Re: Skylark logs failure in accept() [message #37171 is a reply to message #37165] Mon, 03 September 2012 11:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I believe that if my prefork hypothesis was correct, it should be now fixed.

Mirek
Re: Skylark logs failure in accept() [message #37172 is a reply to message #37171] Mon, 03 September 2012 12:24 Go to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

mirek wrote on Mon, 03 September 2012 11:07

I believe that if my prefork hypothesis was correct, it should be now fixed.

Mirek

Recompiled and deployed, so far it seems to work well Smile

Thanks,
Honza
Previous Topic: [Solved]Can't show favicon.ico in Skylark if root path is not Null
Next Topic: TcpSocket in Array
Goto Forum:
  


Current Time: Sat Apr 20 11:11:17 CEST 2024

Total time taken to generate the page: 0.06340 seconds