Keep the account watches of a session made outside an engine open
A TeamSpeak session made through the plain Connector interface (the way the
conformance suite and any client of the seam that is no engine make one) got
a LocalCtx::standalone() whose only job is to hold the senders of the
myTeamSpeak watches. connect_link dropped that context when it returned, the
senders went with it, and the TeamSpeak link ends its connection with
"account source closed" when a watch has no sender: the session died by
itself a moment after it was handed out. The engine's own path was never
affected, its watches belong to the engine.
The context now moves into the driver task and lives as long as the session.
Found by running the link conformance suite against the development servers:
close_ends_the_session passed vacuously and the_backend_can_end_the_session
saw the session end with that text. The new test fails without this change
("the identity watch lost its sender").
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8d07502e1e
commit
659798e5f9
2 files changed
+23
-1
No files matched your search
@@ -1308,6 +1308,21 @@ async fn a_session_closes_as_the_table_says() {
|
||||
assert!(matches!(error, SessionError::Closed(_)), "{error:?}");
|
||||
}
|
||||
|
||||
/// A session made through the plain `Connector` interface, outside an engine
|
||||
/// (the conformance suite does, so does any client of the seam that is no
|
||||
/// engine), has no engine to hold the account watches the link listens to:
|
||||
/// the session keeps their senders for as long as it runs. The link ends its
|
||||
/// connection with "account source closed" when it has lost them.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_session_made_outside_an_engine_keeps_the_watches_of_its_link_open() {
|
||||
let (session, _pushes, inner) = open(everything()).await;
|
||||
// Let the driver start, and the connect that returned drop what it held.
|
||||
tokio::time::sleep(Duration::from_millis(50)).await;
|
||||
assert!(inner.ctx.myts_identity.has_changed().is_ok(), "the identity watch lost its sender");
|
||||
assert!(inner.ctx.myts_data.has_changed().is_ok(), "the data watch lost its sender");
|
||||
drop(session);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn a_connect_that_the_link_fails_is_an_error_with_its_reason() {
|
||||
let (conns, mut seen) = mpsc::unbounded_channel();
|
||||
|
||||
@@ -703,7 +703,14 @@ async fn connect_link(
|
||||
closed: closed_rx,
|
||||
own_slot,
|
||||
};
|
||||
tokio::spawn(driver.run(cmds_rx));
|
||||
tokio::spawn(async move {
|
||||
driver.run(cmds_rx).await;
|
||||
// The context keeps the senders of the account watches that a connection
|
||||
// made outside an engine has (`LocalCtx::standalone`): the link ends its
|
||||
// connection when a watch has no sender, so the context lives as long as
|
||||
// the session does.
|
||||
drop(ctx);
|
||||
});
|
||||
Ok(LocalConnected {
|
||||
connected: Connected {
|
||||
session: Arc::new(session),
|
||||
|
||||
Reference in new issue
Block a user