Skip to content
Permalink
Browse files
16KB use Rlock
  • Loading branch information
Lvnszn committed Nov 17, 2021
1 parent da1e5d5 commit a3f9370868af70d809f90104040e27d08891d358
Showing 1 changed file with 2 additions and 2 deletions.
@@ -423,15 +423,15 @@ func (s *session) WriteBytes(pkg []byte) (int, error) {
}

leftPackageSize, totalSize, writeSize := len(pkg), len(pkg), 0
if leftPackageSize >= maxPacketLen {
if leftPackageSize > maxPacketLen {
s.packetLock.Lock()
defer s.packetLock.Unlock()
} else {
s.packetLock.RLock()
defer s.packetLock.RUnlock()
}

for leftPackageSize >= maxPacketLen {
for leftPackageSize > maxPacketLen {
_, err := s.Connection.send(pkg[writeSize:(writeSize + maxPacketLen)])
if err != nil {
return writeSize, perrors.Wrapf(err, "s.Connection.Write(pkg len:%d)", len(pkg))

0 comments on commit a3f9370

Please sign in to comment.