Merge lp:~marcustomlinson/net-cpp/fix_ppc_timeout-rtm into lp:net-cpp/rtm-14.09

Proposed by Marcus Tomlinson
Status: Merged
Merged at revision: 41
Proposed branch: lp:~marcustomlinson/net-cpp/fix_ppc_timeout-rtm
Merge into: lp:net-cpp/rtm-14.09
Diff against target: 16 lines (+5/-1)
1 file modified
src/core/net/http/impl/curl/request.h (+5/-1)
To merge this branch: bzr merge lp:~marcustomlinson/net-cpp/fix_ppc_timeout-rtm
Reviewer Review Type Date Requested Status
Thomas Voß Pending
Review via email: mp+247409@code.launchpad.net

Commit message

Explicitly cast milliseconds::count() to long

Description of the change

Explicitly cast milliseconds::count() to long.

On PPC, this method returns an 8-byte long long, of which libCurl is hardcoded to read only the first 4 bytes. Furthermore, PPC being Big Endian means that the first 4 bytes will be 0 for any number lower than 2147483648.

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Top approving as this is literally the same change that has been approved here: https://code.launchpad.net/~marcustomlinson/net-cpp/fix_ppc_timeout/+merge/247100

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

> Top approving as this is literally the same change that has been approved
> here: https://code.launchpad.net/~marcustomlinson/net-
> cpp/fix_ppc_timeout/+merge/247100

Oh oops, apparently I don't have permissions to do that. nm

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/net/http/impl/curl/request.h'
2--- src/core/net/http/impl/curl/request.h 2014-05-14 10:07:20 +0000
3+++ src/core/net/http/impl/curl/request.h 2015-01-23 11:36:49 +0000
4@@ -88,7 +88,11 @@
5 if (atomic_state.load() != core::net::http::Request::State::ready)
6 throw core::net::http::Request::Errors::AlreadyActive{CORE_FROM_HERE()};
7
8- easy.set_option(::curl::Option::timeout_ms, timeout.count());
9+ // timeout.count() is a long long, but curl uses varargs and wants a long.
10+ // If timeout.count() overflows a long, we wait forever instead of roughly 24.8 days.
11+ auto count = timeout.count();
12+ long adjusted_timeout = count <= std::numeric_limits<long>::max() ? count : 0;
13+ easy.set_option(::curl::Option::timeout_ms, adjusted_timeout);
14 }
15
16 Response execute(const Request::ProgressHandler& ph)

Subscribers

People subscribed via source and target branches

to all changes: