diff options
-rw-r--r-- | lib/session.ml | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/session.ml b/lib/session.ml index 7e1052f..aa90e64 100644 --- a/lib/session.ml +++ b/lib/session.ml @@ -31,10 +31,7 @@ type t = { https://datatracker.ietf.org/doc/html/rfc6120#section-4.3 }}, and gets the Portal in a "ready" state. *) let create (config : config) : t Lwt.t = - let needs_restart = function - | Feature.Mechanisms _ | STARTTLS -> true - | _ -> false - and features_next_state = function + let features_next_state = function | feature :: rest -> Feature (feature, rest) (* No features returned by stream start. Connection is completed. *) | [] -> Logged_in [] @@ -54,10 +51,10 @@ let create (config : config) : t Lwt.t = in let next_state = features_next_state features in update (Negotiating (portal, next_state)) | Negotiating (portal, Feature (feature, features)) -> - let+ () = negotiate feature portal config - in let next_state = if needs_restart (Feature.unwrap feature) - then Connected portal._socket - else Negotiating (portal, features_next_state features) + let+ negotiation = negotiate feature portal config + in let next_state = match negotiation with + | Some socket -> Connected socket + | None -> Negotiating (portal, features_next_state features) in update next_state | _ -> Lwt.return_unit in let+ () = S.map_s connection_map state >|= S.keep; |