Skip to content

Commit

Permalink
Better data emptyness checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykiselev committed Dec 13, 2024
1 parent f832683 commit c2ad101
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/networking/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (s *Session) waitForSend(data []byte) error {
}

dataCopy := func() {
if data == nil {
return // A nil data is ignored.
if len(data) == 0 {
return // An empty data is ignored.
}

// In the event of session shutdown or connection write timeout, we need to prevent `send` from reading
Expand Down Expand Up @@ -213,7 +213,7 @@ func (s *Session) sendLoop() error {
s.logger.Debug("Sending data to connection",
"data", base64.StdEncoding.EncodeToString(packet.data))
packet.mu.Lock()
if packet.data != nil {
if len(packet.data) != 0 {
// Copy the data into the buffer to avoid holding a mutex lock during the writing.
_, err := dataBuf.Write(packet.data)
if err != nil {
Expand Down

0 comments on commit c2ad101

Please sign in to comment.