diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:53:39 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:53:39 +0000 |
| commit | 11edbfca22fe6e8280caeb77832f4dfbb68ed274 (patch) | |
| tree | a3e238dbe004c4ea0f061135a0c1d4430e50c28e /llvm/lib/Debuginfod/Debuginfod.cpp | |
| parent | e3b557809604d036af6e00c60f012c2025b59a5e (diff) | |
Diffstat (limited to 'llvm/lib/Debuginfod/Debuginfod.cpp')
| -rw-r--r-- | llvm/lib/Debuginfod/Debuginfod.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/lib/Debuginfod/Debuginfod.cpp b/llvm/lib/Debuginfod/Debuginfod.cpp index 026f118bbf5b..2b0710b536ba 100644 --- a/llvm/lib/Debuginfod/Debuginfod.cpp +++ b/llvm/lib/Debuginfod/Debuginfod.cpp @@ -55,7 +55,11 @@ static std::string buildIDToString(BuildIDRef ID) { return llvm::toHex(ID, /*LowerCase=*/true); } -Expected<SmallVector<StringRef>> getDefaultDebuginfodUrls() { +bool canUseDebuginfod() { + return HTTPClient::isAvailable() && !getDefaultDebuginfodUrls().empty(); +} + +SmallVector<StringRef> getDefaultDebuginfodUrls() { const char *DebuginfodUrlsEnv = std::getenv("DEBUGINFOD_URLS"); if (DebuginfodUrlsEnv == nullptr) return SmallVector<StringRef>(); @@ -126,13 +130,8 @@ Expected<std::string> getCachedOrDownloadArtifact(StringRef UniqueKey, return CacheDirOrErr.takeError(); CacheDir = *CacheDirOrErr; - Expected<SmallVector<StringRef>> DebuginfodUrlsOrErr = - getDefaultDebuginfodUrls(); - if (!DebuginfodUrlsOrErr) - return DebuginfodUrlsOrErr.takeError(); - SmallVector<StringRef> &DebuginfodUrls = *DebuginfodUrlsOrErr; return getCachedOrDownloadArtifact(UniqueKey, UrlPath, CacheDir, - DebuginfodUrls, + getDefaultDebuginfodUrls(), getDefaultDebuginfodTimeout()); } @@ -159,7 +158,8 @@ public: Error StreamedHTTPResponseHandler::handleBodyChunk(StringRef BodyChunk) { if (!FileStream) { - if (Client.responseCode() != 200) + unsigned Code = Client.responseCode(); + if (Code && Code != 200) return Error::success(); Expected<std::unique_ptr<CachedFileStream>> FileStreamOrError = CreateStream(); @@ -259,7 +259,8 @@ Expected<std::string> getCachedOrDownloadArtifact( if (Err) return std::move(Err); - if (Client.responseCode() != 200) + unsigned Code = Client.responseCode(); + if (Code && Code != 200) continue; // Return the path to the artifact on disk. |
