Repository navigation
refactor(keychain): open secret service sessions under the caller's context - #697
Merged
Merged
Conversation
joe0BAB
marked this pull request as ready for review
October 15, 2026 13:33
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Benehiko
reviewed
Oct 15, 2026
…ontext OpenSession ran the D-Bus OpenSession call in a goroutine and raced it against time.After in a select. godbus already does this work: CallWithContext finalizes the pending call with ctx.Err() when the context is done and drops a late reply, so the goroutine, both channels and the select were redundant. They also leaked: the channels were unbuffered, so once the timeout branch returned the goroutine blocked forever on its send. OpenSession now takes a ctx, derives context.WithTimeout from it with the existing session-open timeout (10 s default, so a caller without a deadline still cannot hang on an unresponsive daemon) and issues a single CallWithContext. openSessionRaw and sessionOpenResponse are inlined away and the named results dropped. The timeout error changes from "timed out after 10s" to the wrapped context.DeadlineExceeded. Every Linux store operation passes its ctx through, consistent with CreateItem, DeleteItem and Unlock. An operation given an already-cancelled context therefore fails immediately instead of succeeding whenever no prompt was needed. The filter_credentials test cleanup relied on the old behavior: it deleted with t.Context(), which is already cancelled inside t.Cleanup. It now uses context.Background() like every other cleanup in the file. Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
joe0BAB
force-pushed
the
refactor/opensession-ctx
branch
from
October 15, 2026 14:00
abcce0c to
51a3cc4
Compare
Benehiko
approved these changes
Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenSession ran the D-Bus OpenSession call in a goroutine and raced it against time.After in a select. godbus already does this work: CallWithContext finalizes the pending call with ctx.Err() when the context is done and drops a late reply, so the goroutine, both channels and the select were redundant. They also leaked: the channels were unbuffered, so once the timeout branch returned the goroutine blocked forever on its send.
OpenSession now takes a ctx, derives context.WithTimeout from it with the existing session-open timeout (10 s default, so a caller without a deadline still cannot hang on an unresponsive daemon) and issues a single CallWithContext. openSessionRaw and sessionOpenResponse are inlined away and the named results dropped. The timeout error changes from "timed out after 10s" to the wrapped context.DeadlineExceeded.
Every Linux store operation passes its ctx through, consistent with CreateItem, DeleteItem and Unlock. An operation given an already-cancelled context therefore fails immediately instead of succeeding whenever no prompt was needed. The filter_credentials test cleanup relied on the old behavior: it deleted with t.Context(), which is already cancelled inside t.Cleanup. It now uses context.Background() like every other cleanup in the file.