mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化包头
This commit is contained in:
@@ -89,7 +89,7 @@ func (p *MsgParser) Read(conn *TCPConn) ([]byte, error) {
|
||||
msgLen = binary.BigEndian.Uint32(bufMsgLen)
|
||||
}
|
||||
}
|
||||
msgLen -= 2
|
||||
|
||||
|
||||
// check len
|
||||
if msgLen > p.maxMsgLen {
|
||||
@@ -97,7 +97,8 @@ func (p *MsgParser) Read(conn *TCPConn) ([]byte, error) {
|
||||
} else if msgLen < p.minMsgLen {
|
||||
return nil, errors.New("message too short")
|
||||
}
|
||||
|
||||
|
||||
msgLen -= 2
|
||||
// data
|
||||
msgData := make([]byte, msgLen)
|
||||
if _, err := io.ReadFull(conn, msgData); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user