Fix some browsers getting stuck in recursion loop and terminating the game when http request fails

This commit is contained in:
UnknownShadow200 2020-03-13 20:29:23 +11:00
parent 511da3e542
commit 9e2bcba94d

View File

@ -370,6 +370,13 @@ static void Http_FinishedAsync(emscripten_fetch_t* fetch) {
req->statusCode = fetch->status; req->statusCode = fetch->status;
req->contentLength = fetch->totalBytes; req->contentLength = fetch->totalBytes;
/* Remove error handler to avoid potential infinite recurison */
/* Sometimes calling emscripten_fetch_close calls fetch->__attributes.onerror */
/* But attr.onerror is actually Http_FinishedAsync, so this will end up doing */
/* Http_FinishedAsync --> emscripten_fetch_close --> Http_FinishedAsync .. */
/* .. and eventually the browser kills it from too much recursion */
fetch->__attributes.onerror = NULL;
/* data needs to persist beyond closing of fetch data */ /* data needs to persist beyond closing of fetch data */
fetch->data = NULL; fetch->data = NULL;
emscripten_fetch_close(fetch); emscripten_fetch_close(fetch);