Skip to content

Commit 9449794

Browse files
authored
Merge pull request #709 from hlibman-connamara/race_condition
Fix race condition when acceptor.Stop() called immediately after acceptor.Start()
2 parents 4eeefdb + 9c6a733 commit 9449794

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

session.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,6 @@ func (s *session) onAdmin(msg interface{}) {
863863
}
864864

865865
func (s *session) run() {
866-
s.stopOnce = sync.Once{}
867866
s.Start(s)
868867
var stopChan = make(chan struct{})
869868
s.stateTimer = internal.NewEventTimer(func() {

session_factory.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"net"
2020
"strconv"
2121
"strings"
22+
"sync"
2223
"time"
2324

2425
"github.com/pkg/errors"
@@ -84,7 +85,10 @@ func (f sessionFactory) createSession(
8485
func (f sessionFactory) newSession(
8586
sessionID SessionID, storeFactory MessageStoreFactory, settings *SessionSettings, logFactory LogFactory,
8687
application Application) (s *session, err error) {
87-
s = &session{sessionID: sessionID}
88+
s = &session{
89+
sessionID: sessionID,
90+
stopOnce: sync.Once{},
91+
}
8892

8993
var validatorSettings = defaultValidatorSettings
9094
if settings.HasSetting(config.ValidateFieldsOutOfOrder) {

0 commit comments

Comments
 (0)