Jart node deadlock fixup part 2

This commit is contained in:
AJ Martinez 2023-03-21 02:39:25 -07:00 committed by James R
parent a8c129321a
commit 2afc43383e
3 changed files with 14 additions and 9 deletions

View file

@ -3484,9 +3484,7 @@ void D_ClientServerInit(void)
COM_AddCommand("drop", Command_Drop); COM_AddCommand("drop", Command_Drop);
COM_AddCommand("droprate", Command_Droprate); COM_AddCommand("droprate", Command_Droprate);
#endif #endif
#ifdef _DEBUG
COM_AddCommand("numnodes", Command_Numnodes); COM_AddCommand("numnodes", Command_Numnodes);
#endif
RegisterNetXCmd(XD_KICK, Got_KickCmd); RegisterNetXCmd(XD_KICK, Got_KickCmd);
RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer); RegisterNetXCmd(XD_ADDPLAYER, Got_AddPlayer);
@ -3512,6 +3510,7 @@ static void ResetNode(INT32 node)
nodeingame[node] = false; nodeingame[node] = false;
nodewaiting[node] = 0; nodewaiting[node] = 0;
nodeneedsauth[node] = false; nodeneedsauth[node] = false;
CONS_Printf("2: node %d -> %d\n", node, nodeneedsauth[node]);
nettics[node] = gametic; nettics[node] = gametic;
supposedtics[node] = gametic; supposedtics[node] = gametic;
@ -3680,6 +3679,7 @@ static inline void SV_AddNode(INT32 node)
nodeingame[node] = true; nodeingame[node] = true;
nodeneedsauth[node] = false; nodeneedsauth[node] = false;
CONS_Printf("3: node %d -> %d\n", node, nodeneedsauth[node]);
} }
// Xcmd XD_ADDPLAYER // Xcmd XD_ADDPLAYER
@ -4673,7 +4673,10 @@ static void HandlePacketFromAwayNode(SINT8 node)
case PT_NODETIMEOUT: case PT_NODETIMEOUT:
case PT_CLIENTQUIT: case PT_CLIENTQUIT:
if (server) if (server)
{
Net_CloseConnection(node); Net_CloseConnection(node);
nodeneedsauth[node] = false;
}
break; break;
case PT_CLIENTCMD: case PT_CLIENTCMD:
@ -4689,15 +4692,19 @@ static void HandlePacketFromAwayNode(SINT8 node)
{ {
PT_ClientKey(node); PT_ClientKey(node);
nodeneedsauth[node] = true; CONS_Printf("4: node %d -> %d\n", node, nodeneedsauth[node]);
freezetimeout[node] = I_GetTime() + jointimeout; if (nodeneedsauth[node] == false)
{
freezetimeout[node] = I_GetTime() + jointimeout;
nodeneedsauth[node] = true;
}
} }
break; break;
case PT_SERVERCHALLENGE: case PT_SERVERCHALLENGE:
if (cl_mode != CL_WAITCHALLENGE) if (cl_mode != CL_WAITCHALLENGE)
break; break;
memcpy(awaitingChallenge, netbuffer->u.serverchallenge.secret, sizeof(awaitingChallenge)); memcpy(awaitingChallenge, netbuffer->u.serverchallenge.secret, sizeof(awaitingChallenge));
cl_mode = CL_ASKJOIN; //cl_mode = CL_ASKJOIN;
break; break;
default: default:
DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype)); DEBFILE(va("unknown packet received (%d) from unknown host\n",netbuffer->packettype));
@ -5099,6 +5106,8 @@ static void HandlePacketFromPlayer(SINT8 node)
} }
Net_CloseConnection(node); Net_CloseConnection(node);
nodeingame[node] = false; nodeingame[node] = false;
nodeneedsauth[node] = false;
CONS_Printf("1: node %d -> %d\n", node, nodeneedsauth[node]);
break; break;
case PT_CANRECEIVEGAMESTATE: case PT_CANRECEIVEGAMESTATE:
PT_CanReceiveGamestate(node); PT_CanReceiveGamestate(node);

View file

@ -134,9 +134,7 @@ typedef enum
void Command_Drop(void); void Command_Drop(void);
void Command_Droprate(void); void Command_Droprate(void);
#endif #endif
#ifdef _DEBUG
void Command_Numnodes(void); void Command_Numnodes(void);
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma pack(1) #pragma pack(1)

View file

@ -489,7 +489,6 @@ static SINT8 getfreenode(void)
return -1; return -1;
} }
#ifdef _DEBUG
void Command_Numnodes(void) void Command_Numnodes(void)
{ {
INT32 connected = 0; INT32 connected = 0;
@ -527,7 +526,6 @@ void Command_Numnodes(void)
"Ingame: %d\n", "Ingame: %d\n",
connected, ingame); connected, ingame);
} }
#endif
static boolean hole_punch(ssize_t c) static boolean hole_punch(ssize_t c)
{ {