Skip to content

Add TSMutex lock guard - #13188

Merged
bneradt merged 1 commit into
apache:masterfrom
bneradt:tsmutex-lock-guard
Jun 23, 2026
Merged

Add TSMutex lock guard#13188
bneradt merged 1 commit into
apache:masterfrom
bneradt:tsmutex-lock-guard

Conversation

@bneradt

@bneradt bneradt commented May 21, 2026

Copy link
Copy Markdown
Contributor

Plugin code that protects small critical sections with TSMutex has to pair
every early return with a matching unlock. That pattern is easy to get wrong
and makes the intended lock lifetime harder to see.

This adds a small TSMutexLockGuard helper to the plugin API and uses it in
plugin code where the mutex naturally stays locked until a return path.

Copilot AI review requested due to automatic review settings May 21, 2026 19:13
@bneradt bneradt added this to the 11.0.0 milestone May 21, 2026
@bneradt bneradt self-assigned this May 21, 2026
@bneradt bneradt added TS API Plugins Enhancement easy_review No new logic, easy to review. Feedback Needed Request people to provide feedback. labels May 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@zwoop
zwoop requested review from masaori335 and zwoop May 21, 2026 20:58
zwoop
zwoop previously approved these changes May 21, 2026
Comment thread include/ts/ts.h

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Comment thread include/ts/ts.h Outdated
Plugin code that protects small critical sections with TSMutex has to pair
every early return with a matching unlock. That pattern is easy to get wrong
and makes the intended lock lifetime harder to see.

This adds a small TSMutexLockGuard helper to the plugin API and uses it in
plugin code where the mutex naturally stays locked until a return path.
@bneradt
bneradt force-pushed the tsmutex-lock-guard branch from ca811de to 157193e Compare June 15, 2026 23:20

@masaori335 masaori335 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. No leak of lock anymore.

@bneradt
bneradt merged commit 094c755 into apache:master Jun 23, 2026
15 checks passed
@bneradt
bneradt deleted the tsmutex-lock-guard branch June 23, 2026 17:57
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jul 29, 2026
Plugin code that protects small critical sections with TSMutex has to pair
every early return with a matching unlock. That pattern is easy to get wrong
and makes the intended lock lifetime harder to see.

This adds a small TSMutexLockGuard helper to the plugin API and uses it in
plugin code where the mutex naturally stays locked until a return path.
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Jul 29, 2026
Plugin code that protects small critical sections with TSMutex has to pair
every early return with a matching unlock. That pattern is easy to get wrong
and makes the intended lock lifetime harder to see.

This adds a small TSMutexLockGuard helper to the plugin API and uses it in
plugin code where the mutex naturally stays locked until a return path.

(cherry picked from commit 094c755)
@cmcfarlen cmcfarlen moved this to Picked v10.2.0 in ATS v10.2.x Jul 29, 2026
@cmcfarlen cmcfarlen modified the milestones: 11.0.0, 10.2.0 Jul 29, 2026
@github-project-automation github-project-automation Bot moved this from Picked v10.2.0 to For v10.2.0 in ATS v10.2.x Jul 29, 2026
@cmcfarlen cmcfarlen moved this from For v10.2.0 to Picked v10.2.0 in ATS v10.2.x Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

easy_review No new logic, easy to review. Enhancement Feedback Needed Request people to provide feedback. Plugins TS API

Projects

Status: Picked v10.2.0

Development

Successfully merging this pull request may close these issues.

5 participants