improve daemon mode - #90
Merged
Merged
Conversation
Ensure fifo is created before forking: avoids possible race condition when accessing the fifo immediately after starting fbink.
|
Contributor
Author
|
Example, on kindle, with this patch to --- a/platform/kindle/koreader.sh
+++ b/platform/kindle/koreader.sh
@@ -138,6 +138,11 @@ ko_update_check() {
export FBINK_NAMED_PIPE="/tmp/koreader.fbink"
rm -f "${FBINK_NAMED_PIPE}"
FBINK_PID="$(/var/tmp/fbink --daemon 1 %KOREADER% -q -y -6 -P 0)"
+ # Open a handle to the fifo ourselves too: this prevent tar checkpointing
+ # calls from hanging when writing to the fifo if fbink crashed (even with
+ # no one reading from the fifo, its buffer should still be big enough to
+ # never be full either).
+ exec 3<>"${FBINK_NAMED_PIPE}"
# NOTE: To avoid blowing up when an executable get truncated during use, we copy our binaries to the system's
# tmpfs, and run them from there (c.f., #4602)... This is most likely a side-effect of the weird fuse overlay
# being used for /mnt/us (vs. the real vfat on /mnt/base-us), which we cannot use because it's been mounted
@@ -167,6 +172,9 @@ ko_update_check() {
eips_print_bottom_centered "KOReader may fail to function properly" 1
fi
rm -f /tmp/package.index "${NEWUPDATE}" # always purge newupdate to prevent update loops
+ # Fifo cleanup: close our handle, and unlink the path too (in case fbink crashed).
+ exec 3>&-
+ rm -f "${FBINK_NAMED_PIPE}"
unset FBINK_NAMED_PIPE FBINK_PID
# Ensure everything is flushed to disk before we restart. This *will* stall for a while on slow storage!
syncWithout the patch, or a sleep after starting, fbink fails to daemonize successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Ensure fifo is created before forking: avoids possible race condition when accessing the fifo immediately after starting fbink.
This change is