mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-06 06:51:26 +12:00
Terminate RPCN connection cleanly
This commit is contained in:
parent
a7da245656
commit
af8d308a69
2 changed files with 20 additions and 6 deletions
|
@ -145,6 +145,7 @@ namespace rpcn
|
||||||
|
|
||||||
rpcn_client::~rpcn_client()
|
rpcn_client::~rpcn_client()
|
||||||
{
|
{
|
||||||
|
terminate_connection();
|
||||||
std::lock_guard lock(inst_mutex);
|
std::lock_guard lock(inst_mutex);
|
||||||
terminate = true;
|
terminate = true;
|
||||||
sem_rpcn.release();
|
sem_rpcn.release();
|
||||||
|
@ -414,7 +415,7 @@ namespace rpcn
|
||||||
command == CommandType::AddBlock || command == CommandType::RemoveBlock ||
|
command == CommandType::AddBlock || command == CommandType::RemoveBlock ||
|
||||||
command == CommandType::SendMessage || command == CommandType::SendToken ||
|
command == CommandType::SendMessage || command == CommandType::SendToken ||
|
||||||
command == CommandType::SendResetToken || command == CommandType::ResetPassword ||
|
command == CommandType::SendResetToken || command == CommandType::ResetPassword ||
|
||||||
command == CommandType::GetNetworkTime || command == CommandType::SetPresence)
|
command == CommandType::GetNetworkTime || command == CommandType::SetPresence || command == CommandType::Terminate)
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mutex_replies_sync);
|
std::lock_guard lock(mutex_replies_sync);
|
||||||
replies_sync.insert(std::make_pair(packet_id, std::make_pair(command, std::move(data))));
|
replies_sync.insert(std::make_pair(packet_id, std::make_pair(command, std::move(data))));
|
||||||
|
@ -574,23 +575,20 @@ namespace rpcn
|
||||||
if (res == 0)
|
if (res == 0)
|
||||||
{
|
{
|
||||||
// Remote closed connection
|
// Remote closed connection
|
||||||
rpcn_log.error("recv failed: connection reset by server");
|
rpcn_log.notice("recv failed: connection reset by server");
|
||||||
return recvn_result::recvn_noconn;
|
return recvn_result::recvn_noconn;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcn_log.error("recvn failed with error: %d:%s(native: %d)", res, get_wolfssl_error(read_wssl, res), get_native_error());
|
rpcn_log.error("recvn failed with error: %d:%s(native: %d)", res, get_wolfssl_error(read_wssl, res), get_native_error());
|
||||||
return recvn_result::recvn_fatal;
|
return recvn_result::recvn_fatal;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = 0;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Reset timeout each time something is received
|
// Reset timeout each time something is received
|
||||||
num_timeouts = 0;
|
num_timeouts = 0;
|
||||||
|
n_recv += res;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_recv += res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return recvn_result::recvn_success;
|
return recvn_result::recvn_success;
|
||||||
|
@ -1017,6 +1015,21 @@ namespace rpcn
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool rpcn_client::terminate_connection()
|
||||||
|
{
|
||||||
|
u64 req_id = rpcn_request_counter.fetch_add(1);
|
||||||
|
|
||||||
|
std::vector<u8> packet_data;
|
||||||
|
std::vector<u8> data;
|
||||||
|
|
||||||
|
if (!forge_send_reply(CommandType::Terminate, req_id, data, packet_data))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
ErrorType rpcn_client::create_user(std::string_view npid, std::string_view password, std::string_view online_name, std::string_view avatar_url, std::string_view email)
|
ErrorType rpcn_client::create_user(std::string_view npid, std::string_view password, std::string_view online_name, std::string_view avatar_url, std::string_view email)
|
||||||
{
|
{
|
||||||
std::vector<u8> data;
|
std::vector<u8> data;
|
||||||
|
|
|
@ -407,6 +407,7 @@ namespace rpcn
|
||||||
static std::shared_ptr<rpcn_client> get_instance(bool check_config = false);
|
static std::shared_ptr<rpcn_client> get_instance(bool check_config = false);
|
||||||
rpcn_state wait_for_connection();
|
rpcn_state wait_for_connection();
|
||||||
rpcn_state wait_for_authentified();
|
rpcn_state wait_for_authentified();
|
||||||
|
bool terminate_connection();
|
||||||
|
|
||||||
void get_friends_and_register_cb(friend_data& friend_infos, friend_cb_func cb_func, void* cb_param);
|
void get_friends_and_register_cb(friend_data& friend_infos, friend_cb_func cb_func, void* cb_param);
|
||||||
void remove_friend_cb(friend_cb_func, void* cb_param);
|
void remove_friend_cb(friend_cb_func, void* cb_param);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue