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

[Adhoc] Fix lobby issue on The Warriors #14117

Merged
merged 1 commit into from
Feb 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Core/HLE/sceNetAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ int DoBlockingPtpSend(int uid, AdhocSocketRequest& req, s64& result) {
// Return Success
result = 0;
}
else if (ret == SOCKET_ERROR && (sockerr == EAGAIN || sockerr == EWOULDBLOCK)) {
else if (ret == SOCKET_ERROR && (sockerr == EAGAIN || sockerr == EWOULDBLOCK || (ptpsocket.state == ADHOC_PTP_STATE_SYN_SENT && (sockerr == ENOTCONN || connectInProgress(sockerr))))) {
u64 now = (u64)(time_now_d() * 1000000.0);
if (req.timeout == 0 || now - req.startTime <= req.timeout) {
return -1;
Expand Down Expand Up @@ -624,7 +624,7 @@ int DoBlockingPtpRecv(int uid, AdhocSocketRequest& req, s64& result) {

result = 0;
}
else if (ret == SOCKET_ERROR && (sockerr == EAGAIN || sockerr == EWOULDBLOCK)) {
else if (ret == SOCKET_ERROR && (sockerr == EAGAIN || sockerr == EWOULDBLOCK || (ptpsocket.state == ADHOC_PTP_STATE_SYN_SENT && (sockerr == ENOTCONN || connectInProgress(sockerr))))) {
u64 now = (u64)(time_now_d() * 1000000.0);
if (req.timeout == 0 || now - req.startTime <= req.timeout) {
return -1;
Expand Down Expand Up @@ -3225,6 +3225,10 @@ static int sceNetAdhocPtpOpen(const char *srcmac, int sport, const char *dstmac,
// Initiate PtpConnect (ie. The Warrior seems to try to PtpSend right after PtpOpen without trying to PtpConnect first)
NetAdhocPtp_Connect(i + 1, rexmt_int, 1, false);

// Workaround to give some time to get connected before returning from PtpOpen over high latency
if (g_Config.bForcedFirstConnect && internal->attemptCount == 1)
hleDelayResult(i + 1, "delayed ptpopen", rexmt_int);

// Return PTP Socket Pointer
return hleLogDebug(SCENET, i + 1, "success");
}
Expand Down Expand Up @@ -3891,7 +3895,7 @@ static int sceNetAdhocPtpSend(int id, u32 dataAddr, u32 dataSizeAddr, int timeou
}

// Non-Critical Error
else if (sent == SOCKET_ERROR && (error == EAGAIN || error == EWOULDBLOCK)) {
else if (sent == SOCKET_ERROR && (error == EAGAIN || error == EWOULDBLOCK || (ptpsocket.state == ADHOC_PTP_STATE_SYN_SENT && (error == ENOTCONN || connectInProgress(error))))) {
// Non-Blocking
if (flag)
return hleLogSuccessVerboseI(SCENET, ERROR_NET_ADHOC_WOULD_BLOCK, "would block");
Expand Down Expand Up @@ -3976,7 +3980,7 @@ static int sceNetAdhocPtpRecv(int id, u32 dataAddr, u32 dataSizeAddr, int timeou
received = recv(ptpsocket.id, (char*)buf, *len, MSG_NOSIGNAL);
error = errno;

if (received == SOCKET_ERROR && (error == EAGAIN || error == EWOULDBLOCK)) {
if (received == SOCKET_ERROR && (error == EAGAIN || error == EWOULDBLOCK || (ptpsocket.state == ADHOC_PTP_STATE_SYN_SENT && (error == ENOTCONN || connectInProgress(error))))) {
if (flag == 0) {
// Simulate blocking behaviour with non-blocking socket
u64 threadSocketId = ((u64)__KernelGetCurThread()) << 32 | ptpsocket.id;
Expand Down