From fe005a6c44eecbeb708b331207532e7b8c7ff6b7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 15 Jan 2019 11:32:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cpp/httpclientpool.cc | 10 ++++++++++ cpp/httpclientpool.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/cpp/httpclientpool.cc b/cpp/httpclientpool.cc index f76a29b..2c2883c 100644 --- a/cpp/httpclientpool.cc +++ b/cpp/httpclientpool.cc @@ -135,12 +135,22 @@ namespace f8 switch (node->method) { case 1: { + long long begin_tick = a8::XGetTickCount(); ret = a8::http::Get(finally_url, response, &node->headers, 10); + long long end_tick = a8::XGetTickCount(); + if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_request_delay) { + f8::HttpClientPool::Instance()->max_request_delay = end_tick - begin_tick; + } break; } case 2: { + long long begin_tick = a8::XGetTickCount(); ret = a8::http::Post(finally_url.c_str(), node->content, response, &node->headers, 10); + long long end_tick = a8::XGetTickCount(); + if (end_tick - begin_tick > f8::HttpClientPool::Instance()->max_request_delay) { + f8::HttpClientPool::Instance()->max_request_delay = end_tick - begin_tick; + } break; } default: diff --git a/cpp/httpclientpool.h b/cpp/httpclientpool.h index ca47d3c..df6e766 100644 --- a/cpp/httpclientpool.h +++ b/cpp/httpclientpool.h @@ -13,6 +13,9 @@ namespace f8 HttpClientPool() {}; friend class a8::Singleton; + public: + volatile long long max_request_delay = 0; + public: void Init(int thread_num); void UnInit();