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

rpcn: wait for signal before connect #10995

Merged
merged 1 commit into from Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 11 additions & 11 deletions rpcs3/Emu/NP/rpcn_client.cpp
Expand Up @@ -168,18 +168,16 @@ namespace rpcn
// By default is the object is alive we should be connected
if (!connected)
{
bool result_connect;
if (want_conn)
{
std::lock_guard lock(mutex_connected);
result_connect = connect(g_cfg_rpcn.get_host());
{
std::lock_guard lock(mutex_connected);
connect(g_cfg_rpcn.get_host());
}
sem_connected.release();
}
sem_connected.release();

if (!result_connect)
{
break;
}
continue;
break;
}

if (!authentified)
Expand All @@ -195,7 +193,6 @@ namespace rpcn

if (!result_login)
{
rpcn_log.notice("MT: login attempt failed");
break;
}
continue;
Expand Down Expand Up @@ -435,6 +432,7 @@ namespace rpcn
if (res == 0)
{
// Remote closed connection
rpcn_log.error("recv failed: connection reset by server");
return recvn_result::recvn_noconn;
}

Expand Down Expand Up @@ -543,7 +541,6 @@ namespace rpcn

connected = false;
authentified = false;
want_auth = false;
server_info_received = false;
}

Expand Down Expand Up @@ -1624,6 +1621,9 @@ namespace rpcn
{
return state;
}

want_conn = true;
sem_rpcn.release();
}

sem_connected.acquire();
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/NP/rpcn_client.h
Expand Up @@ -215,6 +215,7 @@ namespace rpcn

atomic_t<bool> connected = false;
atomic_t<bool> authentified = false;
atomic_t<bool> want_conn = false;
atomic_t<bool> want_auth = false;
std::binary_semaphore sem_connected, sem_authentified;
std::mutex mutex_connected, mutex_authentified;
Expand Down