summaryrefslogtreecommitdiff
path: root/Types
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2017-05-11 17:33:18 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2017-05-11 17:36:03 -0400
commita087841ae775a14197c1550488f54b5761f4700b (patch)
tree93b0c8f09107395bd58f9dc7210b8ee0817cf20d /Types
parentb09ac870e1dd2bc924c2ab4cd1d2280024a8a80a (diff)
Ssh password prompting improved when using -J
When ssh connection caching is enabled (and when GIT_ANNEX_USE_GIT_SSH is not set), only one ssh password prompt will be made per host, and only one ssh password prompt will be made at a time. This also fixes a race in prepSocket's stale ssh connection stopping when run with -J. It was possible for one thread to start a cached ssh connection, and another thread to immediately stop it, resulting in excess connections being made. This commit was supported by the NSF-funded DataLad project.
Diffstat (limited to 'Types')
-rw-r--r--Types/Messages.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/Types/Messages.hs b/Types/Messages.hs
index 751a513d6..551531349 100644
--- a/Types/Messages.hs
+++ b/Types/Messages.hs
@@ -1,6 +1,6 @@
{- git-annex Messages data types
-
- - Copyright 2012 Joey Hess <id@joeyh.name>
+ - Copyright 2012-2017 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
@@ -9,9 +9,9 @@
module Types.Messages where
-import Data.Default
import qualified Data.Aeson as Aeson
+import Control.Concurrent
#ifdef WITH_CONCURRENTOUTPUT
import System.Console.Regions (ConsoleRegion)
#endif
@@ -32,11 +32,13 @@ data MessageState = MessageState
, consoleRegionErrFlag :: Bool
#endif
, jsonBuffer :: Maybe Aeson.Object
+ , promptLock :: MVar () -- left full when not prompting
}
-instance Default MessageState
- where
- def = MessageState
+newMessageState :: IO MessageState
+newMessageState = do
+ promptlock <- newMVar ()
+ return $ MessageState
{ outputType = NormalOutput
, concurrentOutputEnabled = False
, sideActionBlock = NoBlock
@@ -46,4 +48,5 @@ instance Default MessageState
, consoleRegionErrFlag = False
#endif
, jsonBuffer = Nothing
+ , promptLock = promptlock
}