remotedaemon: Fix problem that could prevent ssh connections being made after two LOSTNET messages were received in a row

Perhaps due to two different network interfaces being brought down.

Since there is no reliable way to drain a Chan, I switched to STM TChan.
This commit is contained in:
Joey Hess 2015-01-15 15:37:48 -04:00
parent ec90116851
commit 1ce8367417
6 changed files with 44 additions and 19 deletions

View file

@ -18,7 +18,7 @@ import qualified Git
import Git.Command
import Utility.ThreadScheduler
import Control.Concurrent.Chan
import Control.Concurrent.STM
import Control.Concurrent.Async
transport :: Transport
@ -58,7 +58,7 @@ transport' r url transporthandle ichan ochan = do
return $ either (either id id) id status
send msg = writeChan ochan msg
send msg = atomically $ writeTChan ochan msg
fetch = do
send (SYNCING url)
@ -80,7 +80,7 @@ transport' r url transporthandle ichan ochan = do
Nothing -> return Stopping
handlecontrol = do
msg <- readChan ichan
msg <- atomically $ readTChan ichan
case msg of
STOP -> return Stopping
LOSTNET -> return Stopping