summaryrefslogtreecommitdiff
path: root/test_http_server.cc
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2015-09-24 14:59:43 -0700
committerAlex Deymo <deymo@google.com>2015-09-24 19:41:54 -0700
commitf123ae2065ef19c172ae67a4c11cf23f1b787204 (patch)
treea3eea6fbc180b8be121efd0eea590335d0248818 /test_http_server.cc
parented80c802955cc68b573f4ff38b5163a7790a5fe4 (diff)
Remove leaked callback when CleanUp() from TimeoutCallback().
When CleanUp() is called indirectly from TimeoutCallback(), the TimeoutCallback() itself is canceled before the new recurrent call is scheduled. The CancelTask() call will trivially succeed because the callback already triggered. Before CL:281197, the g_source_destroy() call to remove the currently running callback would prevent it from being re-scheduled even if it returns TRUE from the callback. This patch re-schedules the callback before calling CurlPerformOnce() so CancelTask() would cancel the scheduled task. Bug: chromium:535649 Test: Added unittest. Verified it fails without the change. Change-Id: Ica742dab0eb8d9d5c5055c8afac9d775ad1e0012
Diffstat (limited to 'test_http_server.cc')
-rw-r--r--test_http_server.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/test_http_server.cc b/test_http_server.cc
index f4190c30..7326eb53 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -41,6 +41,7 @@
#include <vector>
#include <base/logging.h>
+#include <base/posix/eintr_wrapper.h>
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
@@ -450,6 +451,12 @@ ssize_t HandleErrorIfOffset(int fd, const HttpRequest& request,
}
}
+void HandleHang(int fd) {
+ LOG(INFO) << "Hanging until the other side of the connection is closed.";
+ char c;
+ while (HANDLE_EINTR(read(fd, &c, 1)) > 0) {}
+}
+
void HandleDefault(int fd, const HttpRequest& request) {
const off_t start_offset = request.start_offset;
const string data("unhandled path");
@@ -517,6 +524,8 @@ void HandleConnection(int fd) {
} else if (base::StartsWithASCII(url, "/error-if-offset/", true)) {
const UrlTerms terms(url, 3);
HandleErrorIfOffset(fd, request, terms.GetSizeT(1), terms.GetInt(2));
+ } else if (url == "/hang") {
+ HandleHang(fd);
} else {
HandleDefault(fd, request);
}