mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2024-12-02 15:25:37 +08:00
fix a bug in Steam_HTTP::SendHTTPRequest()
where the ID of the triggered call-result from online requests was completely unrelated to the original request, resulting in timeout
This commit is contained in:
parent
afee4c4a72
commit
c65e0fc36a
@ -67,7 +67,7 @@ public ISteamHTTP
|
|||||||
std::vector<Steam_Http_Request> requests{};
|
std::vector<Steam_Http_Request> requests{};
|
||||||
|
|
||||||
Steam_Http_Request *get_request(HTTPRequestHandle hRequest);
|
Steam_Http_Request *get_request(HTTPRequestHandle hRequest);
|
||||||
void online_http_request(Steam_Http_Request *request, SteamAPICall_t *pCallHandle);
|
void online_http_request(Steam_Http_Request *request, SteamAPICall_t call_res_id);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Steam_HTTP(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks);
|
Steam_HTTP(class Settings *settings, class Networking *network, class SteamCallResults *callback_results, class SteamCallBacks *callbacks);
|
||||||
|
@ -189,12 +189,12 @@ static int curl_debug_trace(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t *pCallHandle)
|
void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t call_res_id)
|
||||||
{
|
{
|
||||||
PRINT_DEBUG("attempting to download from url: '%s', target filepath: '%s'",
|
PRINT_DEBUG("attempting to download from url: '%s', target filepath: '%s'",
|
||||||
request->url.c_str(), request->target_filepath.c_str());
|
request->url.c_str(), request->target_filepath.c_str());
|
||||||
|
|
||||||
const auto send_callresult = [&]() -> void {
|
const auto send_callresult = [=]() -> void {
|
||||||
struct HTTPRequestCompleted_t data{};
|
struct HTTPRequestCompleted_t data{};
|
||||||
data.m_hRequest = request->handle;
|
data.m_hRequest = request->handle;
|
||||||
data.m_ulContextValue = request->context_value;
|
data.m_ulContextValue = request->context_value;
|
||||||
@ -202,16 +202,13 @@ void Steam_HTTP::online_http_request(Steam_Http_Request *request, SteamAPICall_t
|
|||||||
if (request->response.empty() && !settings->force_steamhttp_success) {
|
if (request->response.empty() && !settings->force_steamhttp_success) {
|
||||||
data.m_bRequestSuccessful = false;
|
data.m_bRequestSuccessful = false;
|
||||||
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
data.m_bRequestSuccessful = true;
|
data.m_bRequestSuccessful = true;
|
||||||
data.m_eStatusCode = k_EHTTPStatusCode200OK;
|
data.m_eStatusCode = k_EHTTPStatusCode200OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto callres = callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.1);
|
callback_results->addCallResult(call_res_id, data.k_iCallback, &data, sizeof(data));
|
||||||
if (pCallHandle) *pCallHandle = callres;
|
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||||
|
|
||||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::size_t filename_part = request->target_filepath.find_last_of("\\/");
|
std::size_t filename_part = request->target_filepath.find_last_of("\\/");
|
||||||
@ -378,7 +375,10 @@ bool Steam_HTTP::SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pC
|
|||||||
|
|
||||||
if (request->response.empty() && request->target_filepath.size() &&
|
if (request->response.empty() && request->target_filepath.size() &&
|
||||||
!settings->disable_networking && settings->download_steamhttp_requests) {
|
!settings->disable_networking && settings->download_steamhttp_requests) {
|
||||||
std::thread(&Steam_HTTP::online_http_request, this, request, pCallHandle).detach();
|
auto call_res_id = callback_results->reserveCallResult();
|
||||||
|
if (pCallHandle) *pCallHandle = call_res_id;
|
||||||
|
|
||||||
|
std::thread(&Steam_HTTP::online_http_request, this, request, call_res_id).detach();
|
||||||
} else {
|
} else {
|
||||||
struct HTTPRequestCompleted_t data{};
|
struct HTTPRequestCompleted_t data{};
|
||||||
data.m_hRequest = request->handle;
|
data.m_hRequest = request->handle;
|
||||||
@ -387,7 +387,6 @@ bool Steam_HTTP::SendHTTPRequest( HTTPRequestHandle hRequest, SteamAPICall_t *pC
|
|||||||
if (request->response.empty() && !settings->force_steamhttp_success) {
|
if (request->response.empty() && !settings->force_steamhttp_success) {
|
||||||
data.m_bRequestSuccessful = false;
|
data.m_bRequestSuccessful = false;
|
||||||
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
data.m_eStatusCode = k_EHTTPStatusCode404NotFound;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
data.m_bRequestSuccessful = true;
|
data.m_bRequestSuccessful = true;
|
||||||
data.m_eStatusCode = k_EHTTPStatusCode200OK;
|
data.m_eStatusCode = k_EHTTPStatusCode200OK;
|
||||||
|
Loading…
Reference in New Issue
Block a user