Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventTimer.Stop panics if called more than once #581

Closed
agukrapo opened this issue Sep 10, 2023 · 1 comment · Fixed by #580
Closed

EventTimer.Stop panics if called more than once #581

agukrapo opened this issue Sep 10, 2023 · 1 comment · Fixed by #580

Comments

@agukrapo
Copy link
Contributor

We use quickfix extensively in our systems and we are getting this panic several times per week across our services

panic: close of closed channel
goroutine 39832 [running]:
github.com/quickfixgo/quickfix/internal.(*EventTimer).Stop(...)
	/go/pkg/mod/github.com/quickfixgo/[email protected]/internal/event_timer.go:48
github.com/quickfixgo/quickfix.(*session).run.func3()
	/go/pkg/mod/github.com/quickfixgo/[email protected]/session.go:795 +0x4c
github.com/quickfixgo/quickfix.(*session).run(0xc00060cc00)
	/go/pkg/mod/github.com/quickfixgo/[email protected]/session.go:823 +0x446
github.com/quickfixgo/quickfix.(*Initiator).handleConnection.func1()
	/go/pkg/mod/github.com/quickfixgo/[email protected]/initiator.go:142 +0x25
created by github.com/quickfixgo/quickfix.(*Initiator).handleConnection in goroutine 39831
	/go/pkg/mod/github.com/quickfixgo/[email protected]/initiator.go:141 +0xd3

A solution could be to make EventTimer.Stop idempotent:

func (t *EventTimer) Stop() {
	if t == nil {
		return
	}

	t.once.Do(func() {
		close(t.done)
	})

	t.wg.Wait()
}

This proposal is included in PR #580

@melkanas
Copy link

melkanas commented Oct 12, 2023

I had the same panic, managed to avoid this in my application by having a state of initiator and testing the state before initiator.Start() or initiator.Stop() to prevent calling them multiple times

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 a pull request may close this issue.

2 participants