Skip to content

Commit

Permalink
Merge pull request #41 from libp2p/remove-send-lock
Browse files Browse the repository at this point in the history
remove the sendLock in the stream
  • Loading branch information
marten-seemann authored Feb 17, 2021
2 parents fc8d53b + f2c2ce6 commit 4e665e8
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ type Stream struct {
recvLock sync.Mutex
recvBuf segmentedBuffer

sendLock sync.Mutex

recvNotifyCh chan struct{}
sendNotifyCh chan struct{}

Expand Down Expand Up @@ -120,11 +118,8 @@ START:
}

// Write is used to write to the stream
func (s *Stream) Write(b []byte) (n int, err error) {
s.sendLock.Lock()
defer s.sendLock.Unlock()
total := 0

func (s *Stream) Write(b []byte) (int, error) {
var total int
for total < len(b) {
n, err := s.write(b[total:])
total += n
Expand Down

0 comments on commit 4e665e8

Please sign in to comment.