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 maxMessageSize not effective even if aligned with broker #381

Merged
merged 3 commits into from
Oct 20, 2020
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions pulsar/internal/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ import (
)

const (
// MaxFrameSize limit the maximum size that pulsar allows for messages to be sent.
MaxFrameSize = 5 * 1024 * 1024
// MaxMessageSize limit message size for transfer
MaxMessageSize = 5 * 1024 * 1024
// MessageFramePadding is for metadata and other frame headers
MessageFramePadding = 10 * 1024
// MaxMessageSize limit message size for transfer
MaxMessageSize = MaxFrameSize - MessageFramePadding
magicCrc32c uint16 = 0x0e01
// MaxFrameSize limit the maximum size that pulsar allows for messages to be sent.
MaxFrameSize = MaxMessageSize + MessageFramePadding
magicCrc32c uint16 = 0x0e01
)

// ErrCorruptedMessage is the error returned by ReadMessageData when it has detected corrupted data.
Expand Down
2 changes: 1 addition & 1 deletion pulsar/internal/connection_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (r *connectionReader) readSingleCommand() (cmd *pb.BaseCommand, headersAndP

// We have enough to read frame size
frameSize := r.buffer.ReadUint32()
if frameSize > MaxFrameSize {
if r.cnx.maxMessageSize != 0 && int32(frameSize) > (r.cnx.maxMessageSize+MessageFramePadding) {
r.cnx.log.Warnf("Received too big frame size. size=%d", frameSize)
r.cnx.TriggerClose()
return nil, nil, errors.New("Frame size too big")
Expand Down