(runloop_data.c) Refactor HTTP runloop code
This commit is contained in:
parent
d9c568f6e8
commit
1ed0fd0495
|
@ -27,6 +27,16 @@ typedef int (*transfer_cb_t )(void *data, size_t len);
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
#include <net/net_http.h>
|
#include <net/net_http.h>
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
HTTP_STATUS_POLL = 0,
|
||||||
|
HTTP_STATUS_CONNECTION_TRANSFER,
|
||||||
|
HTTP_STATUS_CONNECTION_TRANSFER_PARSE,
|
||||||
|
HTTP_STATUS_TRANSFER,
|
||||||
|
HTTP_STATUS_TRANSFER_PARSE,
|
||||||
|
HTTP_STATUS_TRANSFER_PARSE_FREE,
|
||||||
|
} http_status_enum;
|
||||||
|
|
||||||
typedef struct http_handle
|
typedef struct http_handle
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
|
@ -38,6 +48,7 @@ typedef struct http_handle
|
||||||
msg_queue_t *msg_queue;
|
msg_queue_t *msg_queue;
|
||||||
struct http_t *handle;
|
struct http_t *handle;
|
||||||
transfer_cb_t cb;
|
transfer_cb_t cb;
|
||||||
|
unsigned status;
|
||||||
} http_handle_t;
|
} http_handle_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -742,9 +753,6 @@ static void rarch_main_data_nbio_iterate(bool is_thread, nbio_handle_t *nbio)
|
||||||
nbio->status = NBIO_STATUS_TRANSFER;
|
nbio->status = NBIO_STATUS_TRANSFER;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rarch_main_data_nbio_image_iterate(is_thread, nbio, &nbio->image);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
|
@ -753,19 +761,30 @@ static void rarch_main_data_http_iterate(bool is_thread, http_handle_t *http)
|
||||||
if (!http)
|
if (!http)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (http->connection.handle)
|
switch (http->status)
|
||||||
{
|
{
|
||||||
if (!rarch_main_data_http_con_iterate_transfer(http))
|
case HTTP_STATUS_CONNECTION_TRANSFER_PARSE:
|
||||||
rarch_main_data_http_conn_iterate_transfer_parse(http);
|
rarch_main_data_http_conn_iterate_transfer_parse(http);
|
||||||
}
|
http->status = HTTP_STATUS_TRANSFER;
|
||||||
|
break;
|
||||||
if (http->handle)
|
case HTTP_STATUS_CONNECTION_TRANSFER:
|
||||||
{
|
if (!rarch_main_data_http_con_iterate_transfer(http))
|
||||||
if (!rarch_main_data_http_iterate_transfer(http))
|
http->status = HTTP_STATUS_CONNECTION_TRANSFER_PARSE;
|
||||||
|
break;
|
||||||
|
case HTTP_STATUS_TRANSFER_PARSE:
|
||||||
rarch_main_data_http_iterate_transfer_parse(http);
|
rarch_main_data_http_iterate_transfer_parse(http);
|
||||||
|
http->status = HTTP_STATUS_POLL;
|
||||||
|
break;
|
||||||
|
case HTTP_STATUS_TRANSFER:
|
||||||
|
if (!rarch_main_data_http_iterate_transfer(http))
|
||||||
|
http->status = HTTP_STATUS_TRANSFER_PARSE;
|
||||||
|
break;
|
||||||
|
case HTTP_STATUS_POLL:
|
||||||
|
default:
|
||||||
|
if (rarch_main_data_http_iterate_poll(http) == 0)
|
||||||
|
http->status = HTTP_STATUS_CONNECTION_TRANSFER;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
rarch_main_data_http_iterate_poll(http);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -874,11 +893,13 @@ void rarch_main_data_free(void)
|
||||||
|
|
||||||
static void data_runloop_iterate(bool is_thread, data_runloop_t *runloop)
|
static void data_runloop_iterate(bool is_thread, data_runloop_t *runloop)
|
||||||
{
|
{
|
||||||
runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
nbio_handle_t *nbio = runloop ? &runloop->nbio : NULL;
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
rarch_main_data_overlay_iterate(is_thread, runloop);
|
rarch_main_data_overlay_iterate(is_thread, runloop);
|
||||||
#endif
|
#endif
|
||||||
rarch_main_data_nbio_iterate(is_thread, &runloop->nbio);
|
rarch_main_data_nbio_iterate(is_thread, nbio);
|
||||||
|
rarch_main_data_nbio_image_iterate(is_thread, nbio, &nbio->image);
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
rarch_main_data_http_iterate(is_thread, &runloop->http);
|
rarch_main_data_http_iterate(is_thread, &runloop->http);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue