Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor: use member func instead of macro RPC_CHECK_STATUS #598

Merged
merged 8 commits into from
Aug 26, 2020

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Aug 20, 2020

In previous implementation, we use RPC_CHECK_STATUS to check the status of meta server. But In cpp, macro has no type check, so we can't prevent it from calling with rpc_holder. But it will cause the response to be sent repeatedly if we do this.
So in this pull request, I reimplement it using member function(function has type check).
I name this function as check_status_with_msg, but not check_status, because it may produce template function instantiated with ambiguity if we use check_status.

neverchanje
neverchanje previously approved these changes Aug 21, 2020
acelyc111
acelyc111 previously approved these changes Aug 22, 2020
Comment on lines 204 to 206
template <typename TRespType>
bool check_status_with_msg(message_ex *req, TRespType response_struct);

Copy link
Contributor

@neverchanje neverchanje Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
template <typename TRespType>
bool check_status_with_msg(message_ex *req, TRespType response_struct);
template <typename T, typename TRespType=std::remove_reference<T>::type>
bool check_status_with_msg(message_ex *req, /*out*/ TRespType& response_struct);

response_struct is declared as a value type. While the compiler likely treated it as a reference type, it's still very dangerous.

@neverchanje neverchanje merged commit c51db3e into XiaoMi:master Aug 26, 2020
levy5307 added a commit to levy5307/rdsn that referenced this pull request Dec 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants