diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2022-04-06 12:39:49 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2022-04-06 13:16:00 +0300 |
commit | 90621da7f6e1bfd6d91d60415eae04b2bca274c2 (patch) | |
tree | 94a29abbb0dd5d7a7a9646ac8390aff8c9c6f711 /src/liblzma/api/lzma | |
parent | liblzma: Threaded decoder: Always wait for output if LZMA_FINISH is used. (diff) | |
download | xz-90621da7f6e1bfd6d91d60415eae04b2bca274c2.tar.xz |
liblzma: Add a new flag LZMA_FAIL_FAST for threaded decoder.
In most cases if the input file is corrupt the application won't
care about the uncompressed content at all. With this new flag
the threaded decoder will return an error as soon as any thread
has detected an error; it won't wait to copy out the data before
the location of the error.
I don't plan to use this in xz to keep the behavior consistent
between single-threaded and multi-threaded modes.
Diffstat (limited to 'src/liblzma/api/lzma')
-rw-r--r-- | src/liblzma/api/lzma/container.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/liblzma/api/lzma/container.h b/src/liblzma/api/lzma/container.h index b2b912d5..564c6aaf 100644 --- a/src/liblzma/api/lzma/container.h +++ b/src/liblzma/api/lzma/container.h @@ -73,7 +73,7 @@ typedef struct { * * Decoder: Bitwise-or of zero or more of the decoder flags: * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED + * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED, LZMA_FAIL_FAST */ uint32_t flags; @@ -616,6 +616,29 @@ extern LZMA_API(lzma_ret) lzma_microlzma_encoder( /** + * This flag makes the threaded decoder report errors (like LZMA_DATA_ERROR) + * as soon as they are detected. This saves time when the application has no + * interest in a partially decompressed truncated or corrupt file. Note that + * due to timing randomness, if the same truncated or corrupt input is + * decompressed multiple times with this flag, a different amount of output + * may be produced by different runs, and even the error code might vary. + * + * Without this flag the threaded decoder will provide as much output as + * possible at first and then report the pending error. This default behavior + * matches the single-threaded decoder and provides repeatable behavior + * with truncated or corrupt input. There are a few special cases where the + * behavior can still differ like memory allocation failures (LZMA_MEM_ERROR). + * + * Single-threaded decoders currently ignore this flag. + * + * Support for this flag was added in liblzma 5.3.3alpha. Note that in older + * versions this flag isn't supported (LZMA_OPTIONS_ERROR) even by functions + * that ignore this flag in newer liblzma versions. + */ +#define LZMA_FAIL_FAST UINT32_C(0x20) + + +/** * \brief Initialize .xz Stream decoder * * \param strm Pointer to properly prepared lzma_stream |