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

HttpTransThread::AddRequestToCatchList,请求id和请求的内存堆,好像都有问题 #106

Open
Janeny2013 opened this issue Jan 4, 2023 · 2 comments

Comments

@Janeny2013
Copy link

HttpRequestID HttpTransThread::AddRequestToCatchList(const HttpRequestSharedPtr &request)
{
nbase::NAutoLock autolock(&message_loop_flag_lock_);
request_current_sn_ -= 1;
if (request_current_sn_ == INVALID_HTTPREQUESTID)
request_current_sn_ = kREQUEST_ID_BASE;
request_list_.insert(std::make_pair(request_current_sn_, std::make_pair(request.get(), request)));
request->attach_release(ToWeakCallback(std::bind(&HttpTransThread::OnRequestRelease, this, request.get())));
return request_current_sn_;
}

@Janeny2013
Copy link
Author

request_list_.insert(std::make_pair(request_current_sn_, std::make_pair(request.get(), request)));
map本身不管理内存,pair的second是监控生命期。这个不是问题了,在回话管理中管理生命期
但request_current_sn_还是没理解,这个id哪里变更

@nmgwddj
Copy link
Collaborator

nmgwddj commented Jul 26, 2024

HttpRequestID HttpTransThread::AddRequestToCatchList(const HttpRequestSharedPtr &request)
{
    nbase::NAutoLock autolock(&message_loop_flag_lock_);
+   request_current_sn_ -= 1;
    if (request_current_sn_ == INVALID_HTTPREQUESTID)
    request_current_sn_ = kREQUEST_ID_BASE;
    request_list_.insert(std::make_pair(request_current_sn_, std::make_pair(request.get(), request)));
    request->attach_release(ToWeakCallback(std::bind(&HttpTransThread::OnRequestRelease, this, request.get())));
    return request_current_sn_;
}

高亮处的 -= 就是变更。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants