### Please describe the problem.

git annex remotedaemon fails to reconnect after receiving several LOSTNET messages and RESUME.

Initially I've encountered the issue by noticing that git annex assistant stops updating local working copy after suspend/resume of laptop. Later I've found out that the same issue happens when disconnecting from network via NetworkManager and connecting back.

After some experiments with git annex remotedaemon I've found out that it incorrectly handles several LOSTNET messages in a row. After RESUME remotedaemon starts new SSH process and sends DISCONNECTED right away. Also it doesn't try to reconnect with backoff as it does with bad connection.

I've checked sources and with some logging found that it sends DISCONNECTED because of some kind of queueing of LOSTNET and switching to stopped mode right after RESUME. Unfortunately I don't know haskell to fix it myself.

### What steps will reproduce the problem?

[[!format sh """
% git annex remotedaemon --debug
[2014-12-19 11:07:13 NOVT] read: git ["config","--null","--list"]
[2014-12-19 11:07:13 NOVT] read: ssh ["-O","stop","-S","git@annex","-o","ControlMaster=auto","-o","ControlPersist=yes","localhost"]
[2014-12-19 11:07:13 NOVT] chat: ssh ["-S",".git/annex/ssh/git@annex","-o","ControlMaster=auto","-o","ControlPersist=yes","-T","git@annex","git-annex-shell 'notifychanges' '/~/annex' --uuid 858bc960-d379-4694-a6b8-98eba5fbeb82"]
CONNECTED ssh://git@annex/~/annex
[2014-12-19 11:07:13 NOVT] chat: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","cat-file","--batch"]
LOSTNET   
[2014-12-19 11:07:21 NOVT] read: ssh ["-O","stop","-S","git@annex","-o","ControlMaster=auto","-o","ControlPersist=yes","localhost"]
DISCONNECTED ssh://git@annex/~/annex
LOSTNET
RESUME
[2014-12-19 11:07:27 NOVT] chat: ssh ["-S",".git/annex/ssh/git@annex","-o","ControlMaster=auto","-o","ControlPersist=yes","-T","git@annex","git-annex-shell 'notifychanges' '/~/annex' --uuid 858bc960-d379-4694-a6b8-98eba5fbeb82"]
DISCONNECTED ssh://git@annex/~/annex
"""]]

### What version of git-annex are you using? On what operating system?

git-annex 5.20141203 on Gentoo Linux

### Please provide any additional information below.

Here is the original assistant log:

[[!format sh """

[2014-12-19 11:14:47 NOVT] NetWatcher: detected network disconnection
[2014-12-19 11:14:47 NOVT] RemoteControl: LOSTNET
[2014-12-19 11:14:47 NOVT] RemoteControl: DISCONNECTED ssh://git@annex/~/annex
[2014-12-19 11:14:47 NOVT] RemoteControl: fromList []
[2014-12-19 11:14:49 NOVT] NetWatcher: detected network disconnection
[2014-12-19 11:14:49 NOVT] RemoteControl: LOSTNET
[2014-12-19 11:14:52 NOVT] NetWatcher: detected network disconnection
[2014-12-19 11:14:52 NOVT] RemoteControl: LOSTNET
[2014-12-19 11:14:52 NOVT] NetWatcher: detected network disconnection
[2014-12-19 11:14:52 NOVT] RemoteControl: LOSTNET
[2014-12-19 11:14:53 NOVT] NetWatcher: detected network connection
[2014-12-19 11:14:53 NOVT] NetWatcher: Syncing with origin 
[2014-12-19 11:14:53 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","symbolic-ref","HEAD"]
[2014-12-19 11:14:53 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","refs/heads/master"]
[2014-12-19 11:14:53 NOVT] call: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","fetch","origin"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","git-annex"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","--hash","refs/heads/git-annex"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","log","refs/heads/git-annex..b85cddc187d388ab12d18fddbdef266565e81e43","-n1","--pretty=%H"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","log","refs/heads/git-annex..12f83429b96850f81ff8edfc0a8651bfa65a066b","-n1","--pretty=%H"]
[2014-12-19 11:14:54 NOVT] call: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","--verify","-q","refs/remotes/origin/master"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","log","refs/heads/master..refs/remotes/origin/master","-n1","--pretty=%H"]
[2014-12-19 11:14:54 NOVT] call: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","--verify","-q","refs/remotes/origin/synced/master"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","log","refs/heads/synced/master..refs/remotes/origin/synced/master","-n1","--pretty=%H"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","symbolic-ref","HEAD"]
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","show-ref","refs/heads/master"]
[2014-12-19 11:14:54 NOVT] NetWatcher: pushing to [Remote { name ="origin" }]
[2014-12-19 11:14:54 NOVT] call: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","push","origin","+git-annex:synced/git-annex","master:synced/master"]
Everything up-to-date
[2014-12-19 11:14:54 NOVT] read: git ["--git-dir=/home/user/annex/.git","--work-tree=/home/user/annex","push","origin","master"]
[2014-12-19 11:14:54 NOVT] RemoteControl: RESUME
[2014-12-19 11:14:54 NOVT] RemoteControl: DISCONNECTED ssh://git@annex/~/annex
[2014-12-19 11:14:54 NOVT] RemoteControl: fromList []


"""]]

[[!tag confirmed]]

> [[fixed|done]] --[[Joey]]
