summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schuster <git@rationality.eu>2018-02-20 18:47:45 +0100
committerSimon Schuster <git@rationality.eu>2018-02-20 20:02:38 +0100
commit52859ce848ec9581782526a27d6455772636ad60 (patch)
tree2a60c823bceb9a4df24977455078c14087a68743
parente26fae5dd907c6efee3a47adcd6eea2f362ae7e7 (diff)
TTRSS-API: Use the reload-threads curl handle
When reloading, ttrss_api now reuses the same handle over multiple feed-reloads, which speeds up bulk updates (reload-all).
-rw-r--r--include/ttrss_api.h4
-rw-r--r--src/rss_parser.cpp2
-rw-r--r--src/ttrss_api.cpp11
3 files changed, 9 insertions, 8 deletions
diff --git a/include/ttrss_api.h b/include/ttrss_api.h
index bdce7045..7c73e079 100644
--- a/include/ttrss_api.h
+++ b/include/ttrss_api.h
@@ -16,7 +16,7 @@ class ttrss_api : public remote_api {
bool authenticate() override;
virtual nlohmann::json run_op(
const std::string& op, const std::map<std::string,
- std::string>& args, bool try_login = true);
+ std::string>& args, bool try_login = true, CURL *cached_handle = nullptr);
std::vector<tagged_feedurl> get_subscribed_urls() override;
void add_custom_headers(curl_slist** custom_headers) override;
bool mark_all_read(const std::string& feedurl) override;
@@ -24,7 +24,7 @@ class ttrss_api : public remote_api {
bool update_article_flags(
const std::string& oldflags, const std::string& newflags,
const std::string& guid) override;
- rsspp::feed fetch_feed(const std::string& id);
+ rsspp::feed fetch_feed(const std::string& id, CURL* cached_handle);
bool update_article(const std::string& guid, int mode, int field);
private:
void fetch_feeds_per_category(
diff --git a/src/rss_parser.cpp b/src/rss_parser.cpp
index d84fbe0b..3322d262 100644
--- a/src/rss_parser.cpp
+++ b/src/rss_parser.cpp
@@ -471,7 +471,7 @@ bool rss_parser::is_html_type(const std::string& type) {
void rss_parser::fetch_ttrss(const std::string& feed_id) {
ttrss_api * tapi = dynamic_cast<ttrss_api *>(api);
if (tapi) {
- f = tapi->fetch_feed(feed_id);
+ f = tapi->fetch_feed(feed_id, easyhandle ? easyhandle->ptr() : nullptr);
is_valid = true;
}
LOG(level::DEBUG, "rss_parser::fetch_ttrss: f.items.size = %u", f.items.size());
diff --git a/src/ttrss_api.cpp b/src/ttrss_api.cpp
index 9e8701a1..64f4701f 100644
--- a/src/ttrss_api.cpp
+++ b/src/ttrss_api.cpp
@@ -97,7 +97,8 @@ unsigned int ttrss_api::query_api_level()
json ttrss_api::run_op(const std::string& op,
const std::map<std::string, std::string >& args,
- bool try_login)
+ bool try_login, /* = true */
+ CURL *cached_handle /* = nullptr */)
{
std::string url = strprintf::fmt("%s/api/", cfg->get_configvalue("ttrss-url"));
@@ -120,7 +121,7 @@ json ttrss_api::run_op(const std::string& op,
req_data = requestparam.dump();
}
- std::string result = utils::retrieve_url(url, cfg, auth_info, &req_data);
+ std::string result = utils::retrieve_url(url, cfg, auth_info, &req_data, cached_handle);
LOG(level::DEBUG, "ttrss_api::run_op(%s,...): post=%s reply = %s", op, req_data, result);
@@ -143,7 +144,7 @@ json ttrss_api::run_op(const std::string& op,
if (status != 0) {
if (reply["error"] == "NOT_LOGGED_IN" && try_login) {
if (authenticate())
- return run_op(op, args, false);
+ return run_op(op, args, false, cached_handle);
else
return json(nullptr);
} else {
@@ -305,7 +306,7 @@ bool ttrss_api::update_article_flags(
return success;
}
-rsspp::feed ttrss_api::fetch_feed(const std::string& id) {
+rsspp::feed ttrss_api::fetch_feed(const std::string& id, CURL* cached_handle) {
rsspp::feed f;
f.rss_version = rsspp::TTRSS_JSON;
@@ -314,7 +315,7 @@ rsspp::feed ttrss_api::fetch_feed(const std::string& id) {
args["feed_id"] = id;
args["show_content"] = "1";
args["include_attachments"] = "1";
- json content = run_op("getHeadlines", args);
+ json content = run_op("getHeadlines", args, true, cached_handle);
if (content.is_null())
return f;