Skip to content

Open Source alternative to Algolia + Pinecone and an Easier-to-Use alternative to ElasticSearch ⚡ 🔍 ✨ Fast, typo tolerant, in-memory fuzzy Search Engine for building delightful search experiences

Use only connection timeout, and not request timeout for curl.

kishorenc72e4c0510c61
diff --git a/TODO.md b/TODO.md
index d4553c67..b9d4b2d2 100644
--- a/TODO.md
+++ b/TODO.md
@@ -3,9 +3,8 @@
a) ~~Fix memory ratio (decreasing with indexing)~~
b) ~~Speed up wildcard searches further~~
c) ~~Allow int64 in default sorting field~~
-d) Use connection timeout for CURL rather than request timeout
-e) Update role to set max memory ration at 0.80
-f) Async import
+d) ~~Use connection timeout for CURL rather than request timeout~~
+e) Async import
**Search index**
diff --git a/src/http_client.cpp b/src/http_client.cpp
index 156c7965..9f8d3a4c 100644
--- a/src/http_client.cpp
+++ b/src/http_client.cpp
@@ -15,7 +15,6 @@ long HttpClient::post_response(const std::string &url, const std::string &body,
}
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
- curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout_ms);
return perform_curl(curl, res_headers);
}
@@ -28,7 +27,6 @@ long HttpClient::put_response(const std::string &url, const std::string &body, s
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, body.c_str());
- curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout_ms);
return perform_curl(curl, res_headers);
}
@@ -39,7 +37,6 @@ long HttpClient::delete_response(const std::string &url, std::string &response,
return 500;
}
- curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout_ms);
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
return perform_curl(curl, res_headers);
}
@@ -51,7 +48,6 @@ long HttpClient::get_response(const std::string &url, std::string &response,
return 500;
}
- curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, timeout_ms);
return perform_curl(curl, res_headers);
}
@@ -123,7 +119,7 @@ CURL *HttpClient::init_curl(const std::string& url, std::string& response) {
}
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
- curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 300);
+ curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT_MS, 4000);
// to allow self-signed certs
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
diff --git a/src/index.cpp b/src/index.cpp
index 2fcc048d..a22e3def 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -1014,6 +1014,7 @@ uint32_t* Index::collate_leaf_ids(const std::vector<const art_leaf *> &leaves, s
uint32_t num_ids = leaf->values->ids.getLength();
uint32_t* leaf_ids = leaf->values->ids.uncompress();
std::copy(leaf_ids, leaf_ids + num_ids, std::back_inserter(ids));
+ delete [] leaf_ids;
}
uint32_t* result_ids = new uint32_t[ids.size()];