Add a timeout to the TCP connect state. Prior to this, it was possible to block (indefinitely?) if there is a network glitch when trying to upload a score.

This commit is contained in:
Jeremy Rand 2021-07-03 16:42:41 -04:00
parent 165d489832
commit 2a43113f4b
3 changed files with 14 additions and 4 deletions

View File

@ -92,7 +92,7 @@ This project would not have been a success without help from the Apple // commun
* Ken Gagne and Juiced.GS for making tools like ORCA and GoldenGate available.
* Stephen Heumann for NetDisk which I used to transfer my latest build to my real GS for testing.
* Ewen Wannop (Speccie) for his great network tools, especially Versions which I am using to assist in pushing out fixes and new versions of BuGS. I had a problem with the Check File Finder extension but very quickly he found the problem. I very much appreciate his support getting that problem fixed.
* Stefan Wessels for his extensive testing leading up to v2.0 of BuGS. At the time of updating this document, he is trying very hard to beat my high score online and is very close to doing so (his scores are posted as SQW). Thanks so much for your help and enthusiasm and I am sure you will beat my score soon.
* Stefan Wessels for his extensive testing leading up to v2.0 of BuGS. He identified a problem which could lead to waves of scorpions appearing over and over again due to the behaviour of the random number generator and also found a problem with timeouts not working when trying to upload a score. At the time of updating this document, he is trying very hard to beat my high score online and is very close to doing so (his scores are posted as SQW). Thanks so much for your help and enthusiasm and I am sure you will beat my score soon.
## Contact:

View File

@ -32,6 +32,7 @@
#define GLOBAL_SCORE_REFRESH_TIME (15 * 60 * 60)
#define SHUTDOWN_NETWORK_TIMEOUT (2 * 60)
#define TCP_CONNECT_TIMEOUT (8 * 60)
#define READ_NETWORK_TIMEOUT (5 * 60)
#define NETWORK_RETRY_TIMEOUT (3 * 60 * 60)
@ -90,7 +91,8 @@ typedef struct tStatusResponse {
typedef enum tProtocolErrors {
HELLO_TIMEOUT_ERROR = 1,
TCP_CONNECT_TIMEOUT_ERROR = 1,
HELLO_TIMEOUT_ERROR,
HELLO_TOO_BIG_ERROR,
HELLO_UNEXPECTED_RESPONSE_ERROR,
HIGH_SCORE_TIMEOUT_ERROR,
@ -431,6 +433,7 @@ void pollNetwork(void)
break;
}
networkGlobals->gameNetworkState = GAME_NETWORK_WAITING_FOR_TCP;
networkGlobals->timeout = TCP_CONNECT_TIMEOUT;
break;
case GAME_NETWORK_WAITING_FOR_TCP:
@ -441,8 +444,15 @@ void pollNetwork(void)
break;
}
if ((networkGlobals->tcpStatus.srState == TCPSSYNSENT) ||
(networkGlobals->tcpStatus.srState == TCPSSYNRCVD))
(networkGlobals->tcpStatus.srState == TCPSSYNRCVD)) {
if (networkGlobals->timeout > 0) {
networkGlobals->timeout--;
} else {
networkGlobals->gameNetworkState = GAME_NETWORK_PROTOCOL_FAILED;
networkGlobals->errorCode = TCP_CONNECT_TIMEOUT_ERROR;
}
break;
}
if (networkGlobals->tcpStatus.srState != TCPSESTABLISHED) {
abortConnection();

View File

@ -63,7 +63,7 @@ resource rVersion (1) {
{
1, /* Major version number in BCD */
9, /* Minor version number in BCD */
3, /* Bug version number in BCD */
4, /* Bug version number in BCD */
beta, /* Development phase */
0 /* Release number */
},