summaryrefslogtreecommitdiff
path: root/src/Propellor/Spin.hs
diff options
context:
space:
mode:
authorJoey Hess2017-06-18 18:57:41 -0400
committerJoey Hess2017-06-18 18:57:41 -0400
commit217f787df9d6474c9a57fd29b6b2fa29bef64a8a (patch)
tree08478eff44b6a4f54c8b9682a4c045c516723e0c /src/Propellor/Spin.hs
parente32ff4337a1a7ebb9c6235cba55a8747e0429ec5 (diff)
my pipe trick didn't work; fallback to NoBuffering
Not sure what the problem was, but it hung. Also though, I noticed that stdin was still open when git fetch was run, so if git fetch itself decided to read from stdin, it would mess up the protocol forwarding. While git fetch should never read from stdin, that was reason enough to fall back to plan B.
Diffstat (limited to 'src/Propellor/Spin.hs')
-rw-r--r--src/Propellor/Spin.hs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/Propellor/Spin.hs b/src/Propellor/Spin.hs
index cc5fa0e8..cd964e16 100644
--- a/src/Propellor/Spin.hs
+++ b/src/Propellor/Spin.hs
@@ -178,11 +178,11 @@ getSshTarget target hst
update :: Maybe HostName -> IO ()
update forhost = do
whenM hasGitRepo $
- req NeedRepoUrl repoUrlMarker setRepoUrl
+ reqMarked NeedRepoUrl repoUrlMarker setRepoUrl
makePrivDataDir
createDirectoryIfMissing True (takeDirectory privfile)
- req NeedPrivData privDataMarker $
+ reqMarked NeedPrivData privDataMarker $
writeFileProtected privfile
whenM hasGitRepo $
@@ -350,19 +350,13 @@ spinCommitMessage = "propellor spin"
-- Request that it run git upload-pack, and connect that up to a git fetch
-- to receive the data.
gitPullFromUpdateServer :: IO ()
-gitPullFromUpdateServer = req NeedGitPush gitPushMarker $ \_ -> do
- -- IO involving stdin can cause data to be buffered in the Handle
- -- (even when it's set NoBuffering), but we need to pass a FD to
- -- git fetch containing all of stdin after the gitPushMarker,
- -- including any that has been buffered.
- --
- -- To do so, create a pipe, and forward stdin, including any
- -- buffered part, through it.
- (pread, pwrite) <- System.Posix.IO.createPipe
- hwrite <- fdToHandle pwrite
- _ <- async $ stdin *>* hwrite
- let hin = pread
+gitPullFromUpdateServer = reqMarked NeedGitPush gitPushMarker $ \_ -> do
+ -- Note that this relies on data not being buffered in the stdin
+ -- Handle, since such buffered data would not be available in the
+ -- FD passed to git fetch.
+ hin <- dup stdInput
hout <- dup stdOutput
+ hClose stdin
hClose stdout
-- Not using git pull because git 2.5.0 badly
-- broke its option parser.