View Full Version : EAGAIN - Error #11
shiva
04-16-2003, 04:52 PM
Hi,
In my socket program, in the sock read function I get too many EAGAIN error, whenever the fd is ready for read. Is there any way to reduce behaviour. This sock read function is running on a thread.
I use Solaris 8 with gnu gcc lib.
Is thread priority shall do for this problem.
Thanx in advance
Shiva
RobSeace
04-16-2003, 08:25 PM
You have the socket FD in non-blocking I/O mode, I'm guessing... So,
EAGAIN/EWOULDBLOCK is a normal, expected condition that you have
to deal with... You've instructed the reads not to block, so they don't...
It just means nothing is available to read immediately... What you wish
to do in that case depends on your program... But, typically, someone
might go into select() and wait for it to become readable again, or maybe
go off and do something else for a while and come back later to check
on it again... *shrug* Depends on your design...
shiva
04-22-2003, 08:04 AM
Yes, I've set the socket option has NON-BLOCKING, my request is, can I reduce the number of EAGAIN errors, that displays when run my pid on the truss -p <pid>. Here I can see lot of traces of EAGAIN.
Can this be reduced...
Shiva
mlampkin
04-24-2003, 06:32 AM
If you have a large number of threads running (actually woudlnt take that many) there is another possibility for the EAGAINs you are seeing (since they may just be mapped EINTRs)... the system may be slicing over to other pending threads during calls to the read operation (since it is an interruptable call and a normal break point)...
Two possible solutions are to either create a thread who's sole purpose in life is to read / write the sockets... and boost that threads priority above others on the system so it will not normally be preempted... the other is (an it may not work 100% but should reduce) to call sigaction with SA_RESTART...
Argh. Tired and going brain dead... can't remember all the specifics... but take a look at those two and see if you can dig deeper... it may (but may not) help some...
Michael
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.