372046933 commented on issue #1907:
URL: https://github.com/apache/brpc/issues/1907#issuecomment-3344784745

   > 我有一段内存想要自己管理或者上层系统管理,例如
   > 
   > static void NoOpDeleter(void *) {}
   > 
   > class EchoServiceImpl : public EchoService {
   > public:
   >   EchoServiceImpl() {};
   >   virtual ~EchoServiceImpl() {};
   >   virtual void Echo(google::protobuf::RpcController* cntl_base,
   >                     const EchoRequest* request,
   >                     EchoResponse* response,
   >                     google::protobuf::Closure* done) {
   >     std::vector<int> a;
   >     {
   >       brpc::ClosureGuard done_guard(done);
   >       brpc::Controller* cntl =
   >                 static_cast<brpc::Controller*>(cntl_base);
   >       a.resize(dim);
   >       //... a do some calc
   >       butil::IOBuf &buf = cntl.response_attachment();
   >       buf.append_user_data(a.data(), a.size() * sizeof(int), NoOpDeleter);
   >     }
   >   }
   > }
   > 我的理解是done->Run()过程中,done->Run()是阻塞的,数据`a`会发送结束再出括号再析构a,但是我实际操作发现结果是不正确的。
   > 
   > 所以我想问一下如果采用NoOpDeleter这样方式手动管理内存的生命周期,这块内存的生命周期需要存活多久才能保证发送的数据安全。
   > 
   > 另外,如果我的数据通过[bthread 
local](https://github.com/apache/incubator-brpc/blob/master/docs/en/server.md#bthread-local)创建,采用NoOpDeleter这种方式管理安全吗?
   
   我在client端做了类似的逻辑,发现也是有问题的


-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to