Skip to content

fix: Fixing races and resouce leaks#168

Closed
tantra35 wants to merge 0 commit intodevgianlu:masterfrom
tantra35:fix-01-portion-of-sync-bugs
Closed

fix: Fixing races and resouce leaks#168
tantra35 wants to merge 0 commit intodevgianlu:masterfrom
tantra35:fix-01-portion-of-sync-bugs

Conversation

@tantra35
Copy link
Contributor

  1. We must provide some cancelable context, so when main applplayer loop ends, any depend network operations must be canceled

  2. When chanel is closed it return empty variables (in case none pointer it returns emptry structs, wil nil chanel and if we do ch recive o send "some data" to nil chanel we hang forever)

  3. chanel for stop must be simple closed, in such case when we do <- closedCh we will signal in any case wneh chanel closed

  4. Dealer must be closed at the end on player loop

Comment on lines 65 to 66
for name, values := range header {
req.Header[name] = values
Copy link
Owner

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reason is simple, condition here is not needed, due range over nil map is acceptable, and means just skip loop

func (p *AppPlayer) Run(ctx context.Context, apiRecv <-chan ApiRequest) {
err := p.sess.Dealer().Connect(ctx)
func (p *AppPlayer) Run(_ctx context.Context, apiRecv <-chan ApiRequest) {
runCtx, cancelFn := context.WithCancel(_ctx)
Copy link
Owner

Choose a reason for hiding this comment

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

Use ctx, cancel as per standard practice

Copy link
Contributor Author

@tantra35 tantra35 Aug 27, 2025

Choose a reason for hiding this comment

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

I fixed this

@tantra35 tantra35 force-pushed the fix-01-portion-of-sync-bugs branch 2 times, most recently from c482dfc to 1a95e0b Compare August 27, 2025 14:13
@tantra35 tantra35 closed this Aug 27, 2025
@tantra35 tantra35 force-pushed the fix-01-portion-of-sync-bugs branch from 1a95e0b to 57ffceb Compare August 27, 2025 14:29
@tantra35 tantra35 deleted the fix-01-portion-of-sync-bugs branch August 27, 2025 14:30
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.

2 participants