Skip to content

Commit d31b0bf

Browse files
committed
auth: use buffered err channels, in case context is canceled (keybase#2947)
Without this, a particular user can get deadlocked, because the user loop is stuck trying to send back the error for a canceled request.
1 parent b6a91d2 commit d31b0bf

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎go/auth/credential_authority.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ func (u *user) checkKey(kid keybase1.KID) error {
475475
func (v *CredentialAuthority) CheckUserKey(ctx context.Context, uid keybase1.UID,
476476
username *libkb.NormalizedUsername, kid *keybase1.KID) (err error) {
477477
v.log.Debug("CheckUserKey uid %s, kid %s", uid, kid)
478-
retCh := make(chan error)
478+
retCh := make(chan error, 1) // buffered in case the ctx is canceled
479479
v.checkCh <- checkArg{uid: uid, username: username, kid: kid, retCh: retCh}
480480
select {
481481
case <-ctx.Done():
@@ -502,7 +502,7 @@ func (v *CredentialAuthority) CheckUsers(ctx context.Context, users []keybase1.U
502502
// It returns true if the sets are equal.
503503
func (v *CredentialAuthority) CompareUserKeys(ctx context.Context, uid keybase1.UID, sibkeys, subkeys []keybase1.KID) (
504504
err error) {
505-
retCh := make(chan error)
505+
retCh := make(chan error, 1) // buffered in case the ctx is canceled
506506
v.checkCh <- checkArg{uid: uid, sibkeys: sibkeys, subkeys: subkeys, retCh: retCh}
507507
select {
508508
case <-ctx.Done():

0 commit comments

Comments
 (0)