Martin Mares [Tue, 22 Nov 2011 16:13:32 +0000 (17:13 +0100)]
UCW::CGI: Report all errors by proper HTTP status codes
All calls to die have been replaced by returning a proper HTTP status
code. (A sole exception is if we fail, because we were not run as a CGI
script at all.)
Also, the set of supported HTTP methods now includes HEAD.
Martin Mares [Fri, 19 Aug 2011 10:29:34 +0000 (12:29 +0200)]
Main: Clean up handling of poll flags
- We no longer include POLLERR and POLLHUP in the set of requested
events. The standard (SUSv2) says they will be delivered regardless
of the event mask chosen.
- POLLERR is an output event, so we call only the write handler.
- POLLHUP is documented as an output event, but it sometimes signals
events which we would like to process by the input handler. The
situations when POLLHUP is generated include:
* on reading end of a pipe when the writing end has been closed
-> we would like to call read handler and get EOF (write handler
does not exist)
* on writing end of a pipe when the reading end has been closed
-> we would like to call write handler (read handler does not
exist)
* on a R/W socket when the other end has been closed -> better
call read handler to get an EOF
* on a tty which has been hanged up -> probably the same as a R/W
socket
We have therefore decided to call the read handler, but fall back to
the write handler if the read handler does not exist.
- When a handler decided to remove itself (but keep the main_file),
we could have entered an infinite loop. This no longer happens.
Martin Mares [Thu, 9 Jun 2011 16:04:26 +0000 (18:04 +0200)]
Main recio: Allow rec_io_(start|stop)_read from the read_handler
This involves rescanning the read buffer on rec_io_start_read()
as there might be leftover data from previous invokations of the
read_handler.
However, we have to be careful to avoid arbitrarily deep recursion
of various handlers. We do that by deferring the actual start of
reading to a main_hook.
Martin Mares [Sat, 26 Feb 2011 11:11:16 +0000 (12:11 +0100)]
Main: Added main_teardown() and main_destroy()
There are now two possibilities how to get rid of a main loop
context. Either you call main_delete(), which is gentle and fails
whenever there are any active files/hooks/etc. Or you call main_destroy(),
which forcibly removes all such objects; it also closes all files.
main_teardown() just calls main_destroy() on the current context,
just as main_cleanup() calls main_delete().
Also, file_close_all() is no longer available -- the only known use
cases are after fork(), but closing files is no longer sufficient
there. All calls to file_close_all() should be therefore replaced
by main_teardown().
Martin Mares [Thu, 7 Oct 2010 14:58:43 +0000 (16:58 +0200)]
UCW::Configure::C: de-reference CPU_ARCH in COPT
Originally, when CONFIG_EXACT_CPU was enabled, COPT contained `-march=$(CPU_ARCH)',
which worked when it was used in a Makefile, but not when doing a test
compile in the configure script.
I changed it to dereference the variable immediately.
Martin Mares [Fri, 1 Oct 2010 18:57:25 +0000 (20:57 +0200)]
Added a clean way for building of static PIC libraries
Defining CONFIG_STATIC_PIC adds a dependency on *-pic.a
to every pkg-config file. In addition to that, the .pc
files now contain a "picsuffix" variable which can be
overridden by the user to enable the PIC mode.
Martin Mares [Fri, 30 Jul 2010 18:42:57 +0000 (20:42 +0200)]
Main: Optimize calls to epoll_ctl()
It often happens that a file callback is removed and then reinstated
again before the next main loop iteration (e.g., on a boundary between
two blocks if block_io is used). This caused lots of unnecessary
calls to epoll_ctl().
We now put all files on which file_chg() was called to a separate list
and just before we call epoll_wait(), we process this list and check
which files have changed their event mask since the last iteration.
Martin Mares [Fri, 30 Jul 2010 18:24:56 +0000 (20:24 +0200)]
Main: Unified support for poll and epoll
When the epoll mechanism is available in the system library, use it.
Rewritten processing of file events: when (e)poll completes, all pending
events are scanned and the corresponding files are relinked to another
list. Then this list is processed entry by entry and callbacks are
performed. When file_add() or file_del() is requested from the callback
function, the file is just relinked to the main file_list and the worst
thing which can happen is that an event will be postponed to the next
iteration of the main loop.
To achieve this, I had to decouple the order of entries in the poll_table
from the order of files in the file_list by introducing an auxiliary
array of pointers mapping poll_table entries to file structs.
All tricks with stopping the event scanning loop when poll_table_obsolete
becomes set are gone.