Skip to content

EventTimer.Stop panics if called more than once #581

Description

@agukrapo

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/quickfix@v0.7.1-0.20230509031336-098031ef5379/internal/event_timer.go:48
github.com/quickfixgo/quickfix.(*session).run.func3()
	/go/pkg/mod/github.com/quickfixgo/quickfix@v0.7.1-0.20230509031336-098031ef5379/session.go:795 +0x4c
github.com/quickfixgo/quickfix.(*session).run(0xc00060cc00)
	/go/pkg/mod/github.com/quickfixgo/quickfix@v0.7.1-0.20230509031336-098031ef5379/session.go:823 +0x446
github.com/quickfixgo/quickfix.(*Initiator).handleConnection.func1()
	/go/pkg/mod/github.com/quickfixgo/quickfix@v0.7.1-0.20230509031336-098031ef5379/initiator.go:142 +0x25
created by github.com/quickfixgo/quickfix.(*Initiator).handleConnection in goroutine 39831
	/go/pkg/mod/github.com/quickfixgo/quickfix@v0.7.1-0.20230509031336-098031ef5379/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

Activity

  1. melkanas commented on Oct 12, 2023

    @melkanas

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions