Martin Mares [Sun, 17 Apr 2011 17:06:54 +0000 (19:06 +0200)]
Trans: New semantics of exceptions
Changed exception propagation rules according to the new semantics
documented in ucw/doc/trans.txt, which is based on transaction folding.
We avoid the (partially implemented) exception pool altogether, all
exceptions are just allocated from the pool of the current transaction,
and clever re-throwing rules make the pools last as long as they should.
Also, the current exception is kept track of in the current transaction
instead of the thread context.
Martin Mares [Sun, 17 Apr 2011 16:26:37 +0000 (18:26 +0200)]
Trans: First bits of documentation
I have tried to document the complete logic of transactions,
including memory management details. It is however still far from
a complete documentation and the AsciiDoc formatting is also somewhat
obscure at the moment.
Martin Mares [Sun, 17 Apr 2011 15:21:53 +0000 (17:21 +0200)]
Resources: Implemented subpools
I also had to extend the pool/resource dumping functions, so that
they can print complex structures. All functions pass the amount
of indent to apply and the resource->dump callback is expected
to include a `\n' after its output.
Martin Mares [Mon, 1 Sep 2008 23:22:55 +0000 (01:22 +0200)]
More work on resource pools.
I really do not like that the respools use two different types of memory
allocation, but I really want them to be as efficient as possible inside
transactions and we do not have a good thread-local allocator yet.
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).