mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-11-23 19:59:16 +01:00
Handle an OOM error when downloading
This commit is contained in:
parent
370d28f1fd
commit
63e9d31b74
@ -1658,10 +1658,10 @@ int CMenu::_gametdbDownloaderAsync()
|
|||||||
m_thrdMessageAdded = true;
|
m_thrdMessageAdded = true;
|
||||||
struct download file = {};
|
struct download file = {};
|
||||||
downloadfile(fmt(GAMETDB_URL, langCode.c_str()), &file);
|
downloadfile(fmt(GAMETDB_URL, langCode.c_str()), &file);
|
||||||
if(file.size <= 0)
|
if(errno == ENOMEM)
|
||||||
{
|
return -1;
|
||||||
|
else if(file.size <= 0)
|
||||||
return -3;
|
return -3;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
update_pThread(1); // It's downloaded
|
update_pThread(1); // It's downloaded
|
||||||
|
@ -165,6 +165,14 @@ bool read_chunked(HTTP_INFO *httpinfo, struct download *buffer, size_t start_pos
|
|||||||
#endif
|
#endif
|
||||||
capacity *= 2;
|
capacity *= 2;
|
||||||
buffer->data = MEM2_realloc(buffer->data, capacity);
|
buffer->data = MEM2_realloc(buffer->data, capacity);
|
||||||
|
if (!buffer->data) // A custom theme is using too much memory
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_NETWORK
|
||||||
|
gprintf("Out of memory!\n");
|
||||||
|
#endif
|
||||||
|
errno = ENOMEM;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((ret = https_read(httpinfo, &buffer->data[start_pos], capacity - start_pos, false)) < 1)
|
if ((ret = https_read(httpinfo, &buffer->data[start_pos], capacity - start_pos, false)) < 1)
|
||||||
return false;
|
return false;
|
||||||
@ -200,6 +208,14 @@ bool read_all(HTTP_INFO *httpinfo, struct download *buffer, size_t start_pos)
|
|||||||
#endif
|
#endif
|
||||||
capacity *= 2;
|
capacity *= 2;
|
||||||
buffer->data = MEM2_realloc(buffer->data, capacity);
|
buffer->data = MEM2_realloc(buffer->data, capacity);
|
||||||
|
if (!buffer->data) // A custom theme is using too much memory
|
||||||
|
{
|
||||||
|
#ifdef DEBUG_NETWORK
|
||||||
|
gprintf("Out of memory!\n");
|
||||||
|
#endif
|
||||||
|
errno = ENOMEM;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((ret = https_read(httpinfo, &buffer->data[start_pos], capacity - start_pos, false)) == 0)
|
if ((ret = https_read(httpinfo, &buffer->data[start_pos], capacity - start_pos, false)) == 0)
|
||||||
break;
|
break;
|
||||||
@ -347,7 +363,7 @@ void downloadfile(const char *url, struct download *buffer)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
if (path == NULL)
|
if (!path)
|
||||||
return;
|
return;
|
||||||
// Get the host
|
// Get the host
|
||||||
int domainlength = path - url - 7 - httpinfo.use_https;
|
int domainlength = path - url - 7 - httpinfo.use_https;
|
||||||
@ -434,7 +450,7 @@ void downloadfile(const char *url, struct download *buffer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Attempt to resume the session
|
// Attempt to resume the session
|
||||||
if (session != NULL && wolfSSL_set_session(httpinfo.ssl, session) != SSL_SUCCESS)
|
if (session && wolfSSL_set_session(httpinfo.ssl, session) != SSL_SUCCESS)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NETWORK
|
#ifdef DEBUG_NETWORK
|
||||||
gprintf("Failed to set session (session timed out?)\n");
|
gprintf("Failed to set session (session timed out?)\n");
|
||||||
@ -458,7 +474,7 @@ void downloadfile(const char *url, struct download *buffer)
|
|||||||
usleep(10000);
|
usleep(10000);
|
||||||
}
|
}
|
||||||
// Check if we resumed successfully
|
// Check if we resumed successfully
|
||||||
if (session != NULL && !wolfSSL_session_reused(httpinfo.ssl))
|
if (session && !wolfSSL_session_reused(httpinfo.ssl))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_NETWORK
|
#ifdef DEBUG_NETWORK
|
||||||
gprintf("Failed to resume session\n");
|
gprintf("Failed to resume session\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user