Skip to content

Commit 2941db5

Browse files
author
Igor
committed
add stop chan to escape writing deadlock of s.sessionEvent
1 parent b038361 commit 2941db5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

session.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/quickfixgo/quickfix/internal"
1212
)
1313

14-
//The Session is the primary FIX abstraction for message communication
14+
// The Session is the primary FIX abstraction for message communication
1515
type session struct {
1616
store MessageStore
1717

@@ -50,8 +50,8 @@ func (s *session) logError(err error) {
5050
s.log.OnEvent(err.Error())
5151
}
5252

53-
//TargetDefaultApplicationVersionID returns the default application version ID for messages received by this version.
54-
//Applicable for For FIX.T.1 sessions.
53+
// TargetDefaultApplicationVersionID returns the default application version ID for messages received by this version.
54+
// Applicable for For FIX.T.1 sessions.
5555
func (s *session) TargetDefaultApplicationVersionID() string {
5656
return s.targetDefaultApplVerID
5757
}
@@ -204,7 +204,7 @@ func (s *session) resend(msg *Message) bool {
204204
return s.application.ToApp(msg, s.sessionID) == nil
205205
}
206206

207-
//queueForSend will validate, persist, and queue the message for send
207+
// queueForSend will validate, persist, and queue the message for send
208208
func (s *session) queueForSend(msg *Message) error {
209209
s.sendMutex.Lock()
210210
defer s.sendMutex.Unlock()
@@ -224,7 +224,7 @@ func (s *session) queueForSend(msg *Message) error {
224224
return nil
225225
}
226226

227-
//send will validate, persist, queue the message. If the session is logged on, send all messages in the queue
227+
// send will validate, persist, queue the message. If the session is logged on, send all messages in the queue
228228
func (s *session) send(msg *Message) error {
229229
return s.sendInReplyTo(msg, nil)
230230
}
@@ -247,7 +247,7 @@ func (s *session) sendInReplyTo(msg *Message, inReplyTo *Message) error {
247247
return nil
248248
}
249249

250-
//dropAndReset will drop the send queue and reset the message store
250+
// dropAndReset will drop the send queue and reset the message store
251251
func (s *session) dropAndReset() error {
252252
s.sendMutex.Lock()
253253
defer s.sendMutex.Unlock()
@@ -256,7 +256,7 @@ func (s *session) dropAndReset() error {
256256
return s.store.Reset()
257257
}
258258

259-
//dropAndSend will validate and persist the message, then drops the send queue and sends the message.
259+
// dropAndSend will validate and persist the message, then drops the send queue and sends the message.
260260
func (s *session) dropAndSend(msg *Message) error {
261261
return s.dropAndSendInReplyTo(msg, nil)
262262
}
@@ -757,6 +757,7 @@ func (s *session) run() {
757757
ticker := time.NewTicker(time.Second)
758758

759759
defer func() {
760+
close(stopChan)
760761
s.stateTimer.Stop()
761762
s.peerTimer.Stop()
762763
ticker.Stop()

0 commit comments

Comments
 (0)