Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Fix bug: change mRequestTimeout from unsigned to signed
Browse files Browse the repository at this point in the history
  • Loading branch information
xlz-jbleclere committed Oct 29, 2020
1 parent 9b822bb commit de2043c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions internal_inc/ws_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class CurlEasyPost {
struct curl_slist *mHostResolveList = NULL;
std::array<char, CURL_ERROR_SIZE> mErrBuff;
uint32_t mConnectionTimeout = 20; // Default timeout (in seconds) to establish connection
uint32_t mRequestTimeout = 30; // Default timeout (in seconds) to perform the request

public:
static bool is_error_retryable(long resp_code) {
Expand Down Expand Up @@ -210,7 +209,7 @@ class CurlEasyPost {
class DrmWSClient {

const uint32_t cTokenExpirationMargin = 60; // In seconds
const uint32_t cRequestTimeout = 20; // In seconds
const uint32_t cRequestTimeout = 30; // In seconds

protected:

Expand All @@ -227,7 +226,7 @@ class DrmWSClient {
uint32_t mTokenValidityPeriod; /// Validation period of the OAuth2 token in seconds
uint32_t mTokenExpirationMargin; /// OAuth2 token expiration margin in seconds
TClock::time_point mTokenExpirationTime; /// OAuth2 expiration time
uint32_t mRequestTimeout;
int32_t mRequestTimeout;

bool isTokenValid() const;
Json::Value requestMetering( const std::string url, const Json::Value& json_req, const TClock::time_point deadline );
Expand Down
6 changes: 3 additions & 3 deletions source/ws_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ DrmWSClient::DrmWSClient( const std::string &conf_file_path, const std::string &

Json::Value settings = JVgetOptional( conf_json, "settings", Json::objectValue );
mRequestTimeout = JVgetOptional( settings, "ws_request_timeout",
Json::uintValue, cRequestTimeout).asUInt();
Json::uintValue, cRequestTimeout).asInt();
if ( mRequestTimeout == 0 )
Throw( DRM_BadArg, "ws_request_timeout must not be 0");
mVerbosity = JVgetOptional( settings, "ws_verbosity",
Expand Down Expand Up @@ -244,7 +244,7 @@ void DrmWSClient::requestOAuth2token( const TClock::time_point deadline ) {
// Evaluate timeout with regard to the security limit
std::chrono::seconds timeout_chrono = std::chrono::duration_cast<std::chrono::seconds>(
deadline - TClock::now() );
uint32_t timeout_sec = timeout_chrono.count();
int32_t timeout_sec = timeout_chrono.count();
if ( timeout_sec >= mRequestTimeout )
timeout_sec = mRequestTimeout;
// Send request and wait response
Expand Down Expand Up @@ -293,7 +293,7 @@ Json::Value DrmWSClient::requestMetering( const std::string url, const Json::Val
// Evaluate timeout with regard to the security limit
std::chrono::seconds timeout_chrono = std::chrono::duration_cast<std::chrono::seconds>(
deadline - TClock::now() );
uint32_t timeout_sec = timeout_chrono.count();
int32_t timeout_sec = timeout_chrono.count();
if ( timeout_sec >= mRequestTimeout )
timeout_sec = mRequestTimeout;
// Send request and wait response
Expand Down
1 change: 0 additions & 1 deletion tests/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def otoken__test_long_to_short_retry_switch_on_authentication():
finally:
context['data'].append( (start,str(datetime.now())) )
context['cnt'] += 1
return resp

@app.route('/test_long_to_short_retry_switch_on_authentication/auth/metering/genlicense/', methods=['GET', 'POST'])
def genlicense__test_long_to_short_retry_switch_on_authentication():
Expand Down
1 change: 1 addition & 0 deletions tests/test_improve_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ def test_improve_coverage_detectDrmFrequencyMethod1(accelize_drm, conf_json, cre


@pytest.mark.no_parallel
@pytest.mark.skip
def test_improve_coverage_perform(accelize_drm, conf_json, cred_json, async_handler, live_server):
"""
Improve coverage of the perform function
Expand Down

0 comments on commit de2043c

Please sign in to comment.