wanyuqin commented on code in PR #1175:
URL: 
https://github.com/apache/rocketmq-client-go/pull/1175#discussion_r1803150313


##########
producer/producer.go:
##########
@@ -403,7 +403,7 @@ func (p *defaultProducer) sendAsync(ctx context.Context, 
msg *primitive.Message,
 
        ctx, cancel := context.WithTimeout(ctx, p.options.SendMsgTimeout)
        err := p.client.InvokeAsync(ctx, addr, p.buildSendRequest(mq, msg), 
func(command *remote.RemotingCommand, err error) {
-               cancel()

Review Comment:
   1. add defer to execute cancel because the ctx in the callback method added 
when using the SendAsync method is always passed by the ctx above. If you 
cancel at the beginning, the ctx in the callback will become invalid and cannot 
be used.
   2.in the trace.go file, there is also a direct cancel. In fact, there is no 
problem, because ctx will not be passed on forever.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to