Merge pull request #12847 from Jamiras/cheevos_http_neg1
(cheevos) automatically retry 'http error code -1'
This commit is contained in:
commit
9bd6051581
|
@ -108,7 +108,7 @@ static int append_no_spaces(char* buffer, char* stop, const char* text)
|
|||
}
|
||||
|
||||
*ptr = '\0';
|
||||
return (ptr - buffer);
|
||||
return (int)(ptr - buffer);
|
||||
}
|
||||
|
||||
void rcheevos_get_user_agent(rcheevos_locals_t *locals,
|
||||
|
@ -298,16 +298,8 @@ static void rcheevos_async_retry_request_after_delay(rcheevos_async_io_request*
|
|||
task_queue_push(task);
|
||||
}
|
||||
|
||||
static void rcheevos_async_http_task_callback(
|
||||
retro_task_t* task, void* task_data, void* user_data, const char* error)
|
||||
static void rcheevos_async_request_failed(rcheevos_async_io_request* request, const char* error)
|
||||
{
|
||||
rcheevos_async_io_request *request = (rcheevos_async_io_request*)user_data;
|
||||
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||
char buffer[224];
|
||||
|
||||
if (error)
|
||||
{
|
||||
/* there was a communication error */
|
||||
if (request->type == CHEEVOS_ASYNC_RICHPRESENCE && request->attempt_count > 0)
|
||||
{
|
||||
/* only retry the ping once (in case of network hiccup), otherwise let
|
||||
|
@ -320,6 +312,19 @@ static void rcheevos_async_http_task_callback(
|
|||
/* automatically retry the request */
|
||||
rcheevos_async_retry_request_after_delay(request, error);
|
||||
}
|
||||
}
|
||||
|
||||
static void rcheevos_async_http_task_callback(
|
||||
retro_task_t* task, void* task_data, void* user_data, const char* error)
|
||||
{
|
||||
rcheevos_async_io_request *request = (rcheevos_async_io_request*)user_data;
|
||||
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
|
||||
char buffer[224];
|
||||
|
||||
if (error)
|
||||
{
|
||||
/* there was a communication error */
|
||||
rcheevos_async_request_failed(request, error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -330,6 +335,15 @@ static void rcheevos_async_http_task_callback(
|
|||
}
|
||||
else if (!data->data || !data->len)
|
||||
{
|
||||
if (data->status <= 0)
|
||||
{
|
||||
/* something occurred which prevented the response from being processed.
|
||||
* assume the server request hasn't happened and try again. */
|
||||
snprintf(buffer, sizeof(buffer), "task status code %d", data->status);
|
||||
rcheevos_async_request_failed(request, buffer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data->status != 200)
|
||||
{
|
||||
/* Server returned an error via status code. */
|
||||
|
|
Loading…
Reference in New Issue