Skip to content

Commit 9de41ce

Browse files
committed
refactor: lock when to call GetLastError since it might be in communication
1 parent 2f623f0 commit 9de41ce

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

conn.go

+2
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ func (l *Conn) nextMessageID() int64 {
327327
// GetLastError returns the last recorded error from goroutines like processMessages and reader.
328328
// Only the last recorded error will be returned.
329329
func (l *Conn) GetLastError() error {
330+
l.messageMutex.Lock()
331+
defer l.messageMutex.Unlock()
330332
return l.err
331333
}
332334

v3/conn.go

+2
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ func (l *Conn) nextMessageID() int64 {
327327
// GetLastError returns the last recorded error from goroutines like processMessages and reader.
328328
// // Only the last recorded error will be returned.
329329
func (l *Conn) GetLastError() error {
330+
l.messageMutex.Lock()
331+
defer l.messageMutex.Unlock()
330332
return l.err
331333
}
332334

0 commit comments

Comments
 (0)