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 for messages coming from the message pool always ends up as non-confirmable #366

Merged
merged 4 commits into from
Sep 8, 2022
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
7 changes: 7 additions & 0 deletions net/blockwise/blockwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ func newWriteRequestResponse(remoteAddr net.Addr, request Message, acquireMessag
req.SetToken(request.Token())
req.ResetOptionsTo(request.Options())
req.SetBody(request.Body())
setTypeFrom(req, request)
return &writeMessageResponse{
request: req,
releaseMessage: releaseMessage,
Expand Down Expand Up @@ -432,6 +433,7 @@ func (b *BlockWise) handleSendingMessage(w ResponseWriter, sendingMessage Messag
sendMessage.SetCode(sendingMessage.Code())
sendMessage.ResetOptionsTo(sendingMessage.Options())
sendMessage.SetToken(token)
setTypeFrom(sendMessage, sendingMessage)
payloadSize, err := sendingMessage.BodySize()
if err != nil {
return false, fmt.Errorf("cannot get size of payload: %w", err)
Expand Down Expand Up @@ -489,6 +491,9 @@ func (b *BlockWise) sendEntityIncomplete(w ResponseWriter, token message.Token)
sendMessage := b.acquireMessage(w.Message().Context())
sendMessage.SetCode(codes.RequestEntityIncomplete)
sendMessage.SetToken(token)
if msg, ok := sendMessage.(hasType); ok {
msg.SetType(udpMessage.NonConfirmable)
}
w.SetMessage(sendMessage)
}

Expand Down Expand Up @@ -633,6 +638,7 @@ func (b *BlockWise) startSendingMessage(w ResponseWriter, maxSZX SZX, maxMessage
sendingMessage.SetBody(w.Message().Body())
sendingMessage.SetCode(w.Message().Code())
sendingMessage.SetToken(w.Message().Token())
setTypeFrom(sendingMessage, w.Message())

_, err = b.handleSendingMessage(w, sendingMessage, maxSZX, maxMessageSize, sendingMessage.Token(), block)
if err != nil {
Expand Down Expand Up @@ -825,6 +831,7 @@ func (b *BlockWise) processReceivedMessage(w ResponseWriter, r Message, maxSzx S
cachedReceivedMessage.SetSequence(r.Sequence())
cachedReceivedMessage.SetBody(memfile.New(make([]byte, 0, 1024)))
cachedReceivedMessage.SetCode(r.Code())
setTypeFrom(cachedReceivedMessage, r)
msgGuard = newRequestGuard(cachedReceivedMessage)
errA := msgGuard.Acquire(cachedReceivedMessage.Context(), 1)
if errA != nil {
Expand Down