Avoid race between run-ssh-session's KEXINIT and the startup of ssh-writer.
This commit is contained in:
parent
4cf624dd1e
commit
ae4005b002
|
@ -536,6 +536,19 @@
|
|||
(loop))
|
||||
(thread loop))
|
||||
|
||||
(define (wait-for-members room members)
|
||||
(define handle (join-room room (gensym 'wait-for-members) #:invisible? #t))
|
||||
(let loop ((remaining-members members))
|
||||
(if (null? remaining-members)
|
||||
#t
|
||||
(match (send handle listen)
|
||||
((arrived who) (loop (remove who remaining-members)))
|
||||
((departed who _) (if (member who members)
|
||||
(error 'wait-for-members "Waited-for member exited")
|
||||
(loop remaining-members)))
|
||||
(_ (loop remaining-members)))))
|
||||
(send handle depart))
|
||||
|
||||
(define (ssh-session role in out)
|
||||
(define io-room (make-room (gensym 'ssh-session-io-room)))
|
||||
(spy-on io-room)
|
||||
|
@ -558,6 +571,7 @@
|
|||
|
||||
(standard-thread (lambda () (ssh-reader in io-room)))
|
||||
(standard-thread (lambda () (ssh-writer out io-room)))
|
||||
(wait-for-members io-room '(read-thread write-thread))
|
||||
(standard-thread
|
||||
(lambda ()
|
||||
(run-ssh-session (connection (join-room io-room 'session)
|
||||
|
|
Loading…
Reference in New Issue