Open kybu opened 10 years ago
I've added this now (see latest commit here https://github.com/ieuan25/HttpServer/commit/cbd0757c1a72dc7c973c4f492526b90dd273b7be).
Two questions.
I noticed first that I was terminating the process when select returned -1 (error condition). This was a problem because it does this when interrupted by signals and my SIG_CHLD signals were causing this to happen. Therefore no longer worrying about this error condition. I noticed though that this has never happened to me before with the accept function. Is this because accept is re-entrant meaning default behaviour is to re-start when interrupted by a signal?
Also, as you can see I'm not setting the file descriptors to non-blocking when doing the accept/read/write as I'm assuming that they will not block given the result of select. Is this sufficient or should I also set them to non-blocking even though I won't even execute them unless select says they won't block?
select()
and accept()
behave the same way in this situation. Also, your SIGCHLD
handler has SA_RESTART
set so they should not return -1 and set errno
to EINTR
. That can happen for any other signal though. Bear in mind that we haven't done any process / thread signal masking yet. Check the log file and see what errno
caused it, it should be logged. The exception contains its value.
As we spoke, have a look at select(). It should be mentioned in "14.4.1 select and pselect functions" in the "14. Advanced I/O" chapter.
Just re-implement
alarm()
in this task.