From bf629c97db98cc835e324409edfd8729bb3583c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 22 Jan 2015 12:33:34 +0100 Subject: cancel the backoff timer when the request is canceled --- platform/darwin/http_request_cocoa.mm | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'platform') diff --git a/platform/darwin/http_request_cocoa.mm b/platform/darwin/http_request_cocoa.mm index 77df1f6641..efcc910488 100644 --- a/platform/darwin/http_request_cocoa.mm +++ b/platform/darwin/http_request_cocoa.mm @@ -51,6 +51,7 @@ public: ~HTTPRequestImpl(); void cancel(); + void cancelTimer(); void start(); void handleResult(NSData *data, NSURLResponse *res, NSError *error); @@ -198,6 +199,9 @@ void HTTPRequestImpl::cancel() { context->removeRequest(request); request = nullptr; + // Stop the backoff timer to avoid re-triggering this request. + cancelTimer(); + if (task) { [task cancel]; [task release]; @@ -205,10 +209,21 @@ void HTTPRequestImpl::cancel() { } } +void HTTPRequestImpl::cancelTimer() { + if (timer) { + uv_timer_stop(timer); + uv::close(timer); + timer = nullptr; + } +} + HTTPRequestImpl::~HTTPRequestImpl() { assert(!task); assert(async); + // Stop the backoff timer to avoid re-triggering this request. + cancelTimer(); + uv::close(async); if (request) { -- cgit v1.2.1