Skip to content

Commit 59a5a0b

Browse files
Merge pull request #188 from jesse-engineer/feat/optimize_dequeueMessage
feat: optimize ch close Judgement
2 parents cd14092 + 0406904 commit 59a5a0b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

server/session/state.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,7 @@ func (s *State) dequeueMessage(ctx context.Context) ([]byte, error) {
148148
case <-ctx.Done():
149149
return nil, ctx.Err()
150150
case msg, ok := <-s.sendChan:
151-
if msg == nil && !ok {
152-
// There are no new messages and the chan has been closed, indicating that the request may need to be terminated.
151+
if !ok {
153152
return nil, pkg.ErrSendEOF
154153
}
155154
return msg, nil

transport/transport_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ func (m *mockSessionManager) DequeueMessageForSend(ctx context.Context, sessionI
6363
case <-ctx.Done():
6464
return nil, ctx.Err()
6565
case msg, ok := <-ch:
66-
if msg == nil && !ok {
67-
// There are no new messages and the chan has been closed, indicating that the request may need to be terminated.
66+
if !ok {
6867
return nil, pkg.ErrSendEOF
6968
}
7069
return msg, nil

0 commit comments

Comments
 (0)