Skip to content

Conversation

@hw-claudio
Copy link

c.shutdownLock protects access to c.shutdown,
but before this commit this is only used when calling Close(), thus only protecting against parallel user calls to Close(),

but it was not used when checking whether the channel is shutdown in the exported function IsClosed(), potentially returning an incorrect value.

It was also not used in send() and listen().

To address this, turn the c.shutdownLock Mutex into a RWMutex, and make use of it in all these cases, enabling use of the same RPCClient from multiple parallel goroutines.

Fixes: #782

c.shutdownLock protects access to c.shutdown,
but before this commit this is only used when calling Close(),
thus only protecting against parallel user calls to Close(),

but it was not used when checking whether the channel is shutdown
in the exported function IsClosed(), potentially returning an
incorrect value.

It was also not used in send() and listen().

To address this, turn the c.shutdownLock Mutex into a RWMutex,
and make use of it in all these cases, enabling use of the same
RPCClient from multiple parallel goroutines.

Fixes: hashicorp#782

Signed-off-by: Claudio Fontana <cfontana@suse.de>
@hw-claudio hw-claudio requested review from a team as code owners December 8, 2025 15:02
@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Claudio Fontana seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

1 similar comment
@hashicorp-cla-app
Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes


Claudio Fontana seems not to be a GitHub user.
You need a GitHub account to be able to sign the CLA.
If you have already a GitHub account, please add the email address used for this commit to your account.

Have you signed the CLA already but the status is still pending? Recheck it.

@hw-claudio
Copy link
Author

signed the agreement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rpc_client.go: suspect locking (shutdownLock)

1 participant