wudianer commented on issue #2896:
URL: https://github.com/apache/brpc/issues/2896#issuecomment-2667611118

   > 可以给一个能复现的demo吗
   
   感谢回复 具体场景是客户端http请求下载文件 我们服务接收请求后 调用存储端的sdk读文件并做处理 
   ```
       ctx->AsyncCallWithAttachment([req, callback = std::move(callback), ctx = 
std::move(ctx)]() mutable
                                    {  
            ### // brpc回调:
             auto lambda = [ctx](char *data, size_t length) -> size_t
               {
                    if (ctx == nullptr || length == 0) {
                   // 缓冲区错误
                   return 0; 
               }
               if(!ctx->readed){
                   ctx->readed = true;
                   if (ctx->ret_val!=0){
                       LOG_ERROR << "AsyncCall failed";
                       return 0; 
                   }
               }
                   size_t bytesToWrite = std::min(length, ctx->object_size);
                   if (ctx->offset + bytesToWrite > ctx->object_size)
                   {
                       bytesToWrite = ctx->object_size - ctx->offset;
                   }
           ### //看gdb是当访问contention这里出core 
                   ctx->buf.cutn(data, bytesToWrite);  
                   ctx->offset += bytesToWrite;
                   return bytesToWrite;
               };
               auto resp = HttpResponse::newStreamResponse(lambda, "", 
CT_APPLICATION_OCTET_STREAM, "", req);
               resp->addHeader("Content-Length", 
std::to_string(ctx->object_size));
               callback(resp); }); 
   ```
   然后配置一个dummy_server.port  访问flags ,status ,vars这些没问题 但是访问contention这些就出问题,当然 
进程不承接流量 不会有问题
   
   
![Image](https://github.com/user-attachments/assets/0df75e90-a58d-4db4-8c30-6833da53c0cd)


-- 
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: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to