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.
Martin Mares [Wed, 28 Jul 2010 22:30:10 +0000 (00:30 +0200)]
Main: Split off block I/O
Block-based I/O is no longer hard-wired in the mainloop itself,
it became a separate module built on the top of main_file. While the
timer embedded in main_block_io is somewhat illogical, I have decided
to keep it to make porting of old code easier.
I plan to add another I/O layer in the future, which will handle
more complex buffering capable of reading lines and other variable-size
data structures.
Martin Mares [Wed, 28 Jul 2010 21:56:29 +0000 (23:56 +0200)]
Main: Implemented safe delivery of signals
The current implementation passes the signals through a pipe,
I plan to add signalfd() later.
SIGCHLD handling became the first user of the new signal mechanism.
However, situations in which multiple threads spawn processes using
separate main loops are not supported (we must have a single SIGCHLD
handler for the whole process).
Martin Mares [Mon, 19 Jul 2010 15:27:12 +0000 (17:27 +0200)]
UCW::CGI: Support multiple argument tables
(1) parse_args() can be called multiple times with different
argument tables, so that different parts of a single script
can fetch their own arguments without cluttering the main
argument table. The only catch is that uploaded files must
be defined in the main argument table (i.e., the first one used).
(2) self_ref() and self_form() accepts optional argument tables
which are merged to the main one.
Daniel Fiala [Mon, 2 Aug 2010 17:54:13 +0000 (19:54 +0200)]
Minor fixes to strtonum.
* Removed nested function from strtonum-gen.h .
* Error messages are not saved in separate static variables.
* Octal numbers can be detected by prefix '0[0-7]...' (this feature is enabled by STN_OCT0).
* One-command blocks are not enclosed by { ... } .
* STN_ZCHAR renamed to STN_WHOLE.
Martin Mares [Thu, 22 Jul 2010 13:32:49 +0000 (15:32 +0200)]
Use thread-local storage of GCC 4.x
ucw/threads.c can now work in three different modes:
o non-threaded
o threaded with context in pthread per-thread storage
o threaded with context stored as __thread
I had to make a backward-incompatible change: ucwlib_context->thread_id
is no longer accessible directly (because I do not know of any way how
to initialize it in the __thread mode) and a wrapper function should
be used.
Pavel Charvat [Wed, 16 Jun 2010 18:10:25 +0000 (20:10 +0200)]
mainloop: Improved deletion and insertion of hooks.
It is now guaranted that:
* You can safely remove hook anytime, even from other hook.
* Newly inserted hook will be called at least once before next sleep.
Daniel Fiala [Fri, 14 May 2010 15:11:23 +0000 (17:11 +0200)]
strtonum: Fixed minor errors.
* Removed declarations of undefined conversion functions.
* Added inline conversion functions for signed integers.
* Moved branche for checking whether number is terminated by 0 character.