mksquashfs: Add separate restore thread rather than setjmp/longjmp

When ^C is hit twice (or on error) Mksquashfs if it is appending to a
filesystem needs to exit restoring the filesystem to its original
state.

Originally when Mksquashfs was a single threaded application this
meant the single thread had to unwind back to a known state and
then restore.  This was achieved by the use of setjmp/longjmp.
When multi-threading was added to Mksquashfs this approach
was retained but with the addition of code to disable the sub-threads
before restoring took place.  This was an acceptable solution but
slightly inelegant because multi-threading meant unwinding of a single
thread was no longer necessary.

This commit removes the use of setjmp/longjmp and instead delegates
restoring to a separate thread which when ^C is hit twice or
unrecoverable error is encountered by a sub-thread (sending SIGUSR2),
kills the main thread and does the restoring itself.

Note, when the main thread receives an unrecoverable error, the new code
still executes the recovery on the main thread but now without any
unwinding.  In this situation unwinding was never necessary, but it
was easier with the original code to use share the code and unwind.
Now unwinding is not needed anywhere, it is easier to share the code
and not unwind.

Signed-off-by: Phillip Lougher <phillip@squashfs.org.uk>
3 files changed
tree: 8f0ffe056bdd8bc20932c2dcce86e2b278c14368
  1. kernel/
  2. kernel-2.4/
  3. squashfs-tools/
  4. README