Martin Mares [Tue, 6 Jul 2004 10:36:47 +0000 (10:36 +0000)]
can_overwrite_buffer fixes for bucket.c: added f->buffer resetting and
also don't forget to set can_overwrite_buffer on slurp fastbufs (this
involves a little dirty trick, see the comment).
Robert Spalek [Sun, 4 Jul 2004 11:30:53 +0000 (11:30 +0000)]
- use buck2obj_parse() instead of obj_read_bucket() to separate the header
and the body
- use the new interface for writing the attributes to the buckets
Robert Spalek [Sun, 4 Jul 2004 11:29:17 +0000 (11:29 +0000)]
- obj_parse_dump() generalized to store apart the header and the body, and
renamed to buck2obj_parse()
- added new obj_parse_dump() with the same interface as before; it is a
wrapper of buck2obj_parse()
Robert Spalek [Mon, 28 Jun 2004 11:44:00 +0000 (11:44 +0000)]
deleted obj_attr_to_bucket*(). sorry, I like them, however I have already
converted all sources to my version of these functions. if we reintroduce
them, let us put them to obj2buck.[ch]
Robert Spalek [Mon, 28 Jun 2004 09:45:49 +0000 (09:45 +0000)]
- added buck2obj_flush() that flushed the memory pool (some caller only
remember struct buck2obj_buf * and since it is not exported, they could not
flush it by themselves)
- obj_read_bucket() returns the length of the header if requested
- adapted to growing buffers (gbuf.h)
- updated interface of bconfig()
- lizard_decompress_safe() automatically realloc's the buffer, hence the
wrapper is not needed
Robert Spalek [Mon, 28 Jun 2004 09:34:27 +0000 (09:34 +0000)]
- encapsulation: hide struct lizard_buffer in the source code
===> interface changed, now it returns the pointer in one extra parameter
- lizard_alloc() allocates no memory, hence no size parameter needed
- lizard_realloc() made static and it is automatically called by the
decompression routine
Martin Mares [Sun, 27 Jun 2004 14:10:47 +0000 (14:10 +0000)]
obj_read_bucket() now gets the bucket length as a parameter, because
in many cases, the fastbuf continues after the end of the bucket.
If a V30 bucket ends with a NUL byte, eat that byte as well.
Also introduced obj_attr_to_bucket{,_num}() -- these functions take
a single attribute and encode it using the specified bucket type
for inclusion at the beginning of the bucket header. These functions
probably belong to obj2buck instead, but currently there is no such
file, so I'm leaving the moving to you.
Robert Spalek [Fri, 25 Jun 2004 18:45:56 +0000 (18:45 +0000)]
- buck2obj_alloc() initially allocates no buffers
- buck2obj_realloc() only stretches the main buffer (and not the lizard)
+ it is not exported anymore
- if lizard_decompress_safe() returns EFBIG, its buffer is shrinked
hence buck2obj.c allocates no memory if not needed. the internal buffer is
allocated when the first non-compact bucket is encountered and lizard's
buffer is allocated when the first compressed bucket is encountered.
Robert Spalek [Fri, 25 Jun 2004 15:35:57 +0000 (15:35 +0000)]
MJ's objections:
- test can_overwrite outside the loop in decode_attributes()
- mp_alloc() -> mp_alloc_fast_noalign()
- MAX() is a macro, be careful
- do not call bflush(body), but comment it in the header file
Robert Spalek [Fri, 25 Jun 2004 11:53:39 +0000 (11:53 +0000)]
added the configuration item BCONFIG_CAN_OVERWRITE, which specifies whether the
caller is allowed to perform the following 0-copy write operation:
1. call bdirect_read_prepare()
2. modify the data directly in the buffer returned (e.g. put \0's there)
3. call bflush() before any seek operation to let the fastbuf know
Robert Spalek [Fri, 25 Jun 2004 11:28:40 +0000 (11:28 +0000)]
modifications done at home, not yet incorporated MJ's objections:
- added buck2obj_{alloc,free}()
- extract_odes() renamed to buck2obj_convert() and simplified its interface.
it flushes the memory pool and calls obj_new() as used e.g. in scanner.c
- attribute lengths are stored incremented s.t. 0-lengths are allowed
- the length of the compressed part is stored as U32 instead of UTF8 to allow
0-copy compression
- temporary usage of object.c's oa_allocate removed and we call
obj_add_attr_ref() instead of obj_add_attr()
- renamed constants BUCKET_TYPE_*
- defined internal macro RET_ERR()
Robert Spalek [Thu, 24 Jun 2004 12:29:44 +0000 (12:29 +0000)]
sighandler.c:
- used sigaction() instead of signal()
- no need to re-register the signal handler now :-)
- renamed my_sighandler_t to sh_sighandler_t and changed the interface
Robert Spalek [Thu, 24 Jun 2004 11:57:48 +0000 (11:57 +0000)]
- lizard_alloc() turns on the wrapper for SIGSEGV and lizard_free() restores
its original value
- lizard_decompress_safe() registers quickly the SIGSEGV handler using the
wrapper. it saves 2 sys-calls.
- allocate 3 more bytes for unaligned memory access
Robert Spalek [Wed, 23 Jun 2004 16:48:25 +0000 (16:48 +0000)]
MJ's idea:
- only lock the memory by mprotect() once
- decompress into the middle of the buffer s.t. the barrier is at the distance
as it used before
(needs adding one pointer to the structure)
Robert Spalek [Wed, 23 Jun 2004 14:41:42 +0000 (14:41 +0000)]
incorporated MJ's suggestions:
- flush_copy_command() exploits fast unaligned memory access and memcpy()
lizard_compress():
- the test in_start==copy_start replaced by flag bof, in_start deleted
- if (copy_len > 0) replaced by if (copy_len)
- pos_bit |= 1<<4
- deleted testing cropping at BOF, it is obsolete now
lizard_decompress():
- at label perform_copy_command, we set expect_copy_command=2
- exploit fast unaligned memory access
Robert Spalek [Tue, 15 Jun 2004 09:21:39 +0000 (09:21 +0000)]
crash tests changed:
- since the memory protection is removed after decompress_safe(), it makes
no sense to check the read/write protection on the corresponding page
===> removed
- now, if the returned value is < 0, print errno
- try allocating a too small buffer
OR setting too low expected length
Robert Spalek [Tue, 15 Jun 2004 09:16:13 +0000 (09:16 +0000)]
- low-level safe version of lizard_decompress() put into an extra source file
- use M_PRIVATE instead of M_SHARED
- use PROT_NONE instead of PROT_READ and only set/clear it for one page
before/after the operation instead of doing it for all the array
- errno is set instead of returning different negative values
- use longjmp in the signal handler instead of die() and return -1
- use macro ALIGN()