Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix message pool bug #356

Merged
merged 7 commits into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions protocol/motanProtocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func DecodeWithTime(buf *bufio.Reader, rs *[]byte, maxContentLength int) (msg *M
msg.Header.VersionStatus = readSlice[3]
version := msg.Header.GetVersion()
if version != Version2 { // TODO 不再验证
err = ErrVersion
vlog.Errorf("unsupported protocol version number: %d", version)
return nil, start, ErrVersion
}
Expand All @@ -391,6 +392,7 @@ func DecodeWithTime(buf *bufio.Reader, rs *[]byte, maxContentLength int) (msg *M
}
metasize := int(binary.BigEndian.Uint32(readSlice[:4]))
if metasize > maxContentLength {
err = ErrOverSize
vlog.Errorf("meta over size. meta size:%d, max size:%d", metasize, maxContentLength)
return nil, start, ErrOverSize
}
Expand Down Expand Up @@ -418,6 +420,7 @@ func DecodeWithTime(buf *bufio.Reader, rs *[]byte, maxContentLength int) (msg *M
}
}
if k != "" {
err = ErrMetadata
vlog.Errorf("decode message fail, metadata not paired. header:%v, meta:%s", msg.Header, readSlice)
return nil, start, ErrMetadata
}
Expand All @@ -430,6 +433,7 @@ func DecodeWithTime(buf *bufio.Reader, rs *[]byte, maxContentLength int) (msg *M
}
bodysize := int(binary.BigEndian.Uint32(readSlice[:4]))
if bodysize > maxContentLength {
err = ErrOverSize
vlog.Errorf("body over size. body size:%d, max size:%d", bodysize, maxContentLength)
return nil, start, ErrOverSize
}
Expand Down