Skip to content

Commit

Permalink
add mutex.Unlock()
Browse files Browse the repository at this point in the history
  • Loading branch information
althen committed Dec 28, 2018
1 parent 3bb2622 commit 38010bc
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion client/simple_canal_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ func readHeaderLength() int {
//readNextPacket 通过长度去读取数据包
func readNextPacket() ([]byte,error) {
mutex.Lock()
defer func(){
mutex.Unlock()
}()
rdr := bufio.NewReader(conn)
data := make([]byte, 0, 4*1024)
n, err := io.ReadFull(rdr, data[:4])
Expand All @@ -437,7 +440,6 @@ func readNextPacket() ([]byte,error) {
return nil,err
}
data = data[:n]
mutex.Unlock()
return data,nil
}

Expand Down

0 comments on commit 38010bc

Please sign in to comment.