From: =?UTF-8?q?=C3=89rico=20Nogueira?= <erico.erc@gmail.com>
Date: Sun, 31 Oct 2021 01:39:25 -0300
Subject: [PATCH] fetches/curl: add warning when setting curl option fails
Helps in debugging the causes for such failures.
Re-organizing brackets was necessary here so the NSLOG call could fit
cleanly, and none of the code relied on SETOPT being its own block.
---
content/fetchers/curl.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/content/fetchers/curl.c b/content/fetchers/curl.c
index d36f44c09..acc5e7eef 100644
--- a/content/fetchers/curl.c
+++ b/content/fetchers/curl.c
@@ -878,9 +878,10 @@ static CURLcode fetch_curl_set_options(struct curl_fetch_info *f)
const char *auth;
#undef SETOPT
-#define SETOPT(option, value) { \
+#define SETOPT(option, value) \
code = curl_easy_setopt(f->curl_handle, option, value); \
- if (code != CURLE_OK) \
+ if (code != CURLE_OK) { \
+ NSLOG(netsurf, WARNING, "Setting cURL option " #option " failed."); \
return code; \
}
--
2.33.1
Hi!
I was recently exploring building a slightly smaller libcurl, and had
disabled cookie support in it. This made it so netsurf just looped
eternally while trying to fetch a page, because fetch_curl_set_options()
would always return an error (due to SETOPT(CURLOPT_COOKIE,...)
failing), leading to fetch_curl_initiate_fetch() always invalidating the
curl handle. In what situation can this error happen that it shouldn't
be considered a fatal one? I think netsurf requiring cookie support at
all is reasonable, but the behavior was a bit too broken, I think.
For the debugging, I have attached the change that helped me and I think
could be merged into netsurf.
Thanks,
Érico
No comments:
Post a Comment