update_engine: call res_init and retry one extra time on unresolved host
libcurl error
Based on https://curl.haxx.se/docs/todo.html#updated_DNS_server_while_running:
"If /etc/resolv.conf gets updated while a program using libcurl is running, it
may cause name resolves to fail unless res_init() is called. We should
consider calling res_init() + retry once unconditionally on all name resolve
failures to mitigate against this."
This CL added following behavior:
On libcurl returns CURLE_COULDNT_RESOLVE_HOST error code:
1. we increase the max retry count by 1 for the first time it happens in the
lifetime of an LibcurlHttpFetcher object.
2. we call res_init unconditionally.
We also add UMA metrics to measure whether calling res_init helps
mitigate the unresolved host problem. WIP CL: https://chromium-review.googlesource.com/c/chromium/src/+/1698722
BUG=chromium:982813
TEST=FEATURES="test" emerge-kefka update_engine, tested on a device
Change-Id: Ia894eae93b3a0adbac1a831e657b75cba835dfa0
diff --git a/metrics_constants.h b/metrics_constants.h
index b3833a3..161d585 100644
--- a/metrics_constants.h
+++ b/metrics_constants.h
@@ -60,6 +60,11 @@
// above block and before the kInputMalformed field. This
// is to ensure that error codes are not reordered.
+ // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST and
+ // calling res_init() can recover.
+ kUnresolvedHostRecovered = 97,
+ // This error is reported when libcurl returns CURLE_COULDNT_RESOLVE_HOST.
+ kUnresolvedHost = 98,
// This error is reported when libcurl has an internal error that
// update_engine can't recover from.
kInternalError = 99,