修复审计线程每次启动初始化内存

This commit is contained in:
maxz
2024-11-11 11:32:09 +08:00
committed by maxiaozhen
parent f59ce09eba
commit 8d3bfe4891
2 changed files with 12 additions and 3 deletions

View File

@ -595,6 +595,14 @@ static void sig_thread_config_handler(int &currentAuditRotationAge, int &current
}
}
static void pgaudit_exit_clean(int code, Datum arg)
{
if (t_thrd.audit.cur_thread_idx == 0) {
m_curlUtils.~CurlUtils();
}
}
/* audit sha code version: finished upgrade*/
static bool pgaudit_need_sha_code()
{
@ -728,6 +736,7 @@ NON_EXEC_STATIC void PgAuditorMain()
/* audit master thread */
if (t_thrd.audit.cur_thread_idx == 0) {
m_curlUtils.initialize(false, "", "", "");
on_proc_exit(pgaudit_exit_clean, 0);
elasic_search_connection_test();
audit_process_cxt_init();
} else {
@ -886,7 +895,6 @@ NON_EXEC_STATIC void PgAuditorMain()
}
if (t_thrd.audit.cur_thread_idx == 0) {
m_curlUtils.~CurlUtils();
audit_process_cxt_exit();
}

View File

@ -50,6 +50,7 @@ CurlUtils::CurlUtils() : m_withSSL(false),
CurlUtils::~CurlUtils()
{
curl_easy_cleanup(m_curlForPost);
m_curlForPost = NULL;
}
void CurlUtils::initialize(bool withSSL, const std::string certificate, const std::string user,
@ -91,7 +92,7 @@ bool CurlUtils::http_post_file_request(const std::string url, const std::string
(void)curl_easy_setopt(m_curlForPost, CURLOPT_CUSTOMREQUEST, "POST");
(void)curl_easy_setopt(m_curlForPost, CURLOPT_TCP_KEEPALIVE, 1L);
/* a simply connection test to server, just verify the connection without any data transfer */
/* a simple connection test to server, just verify the connection without any data transfer */
if (connection_testing) {
(void)curl_easy_setopt(m_curlForPost, CURLOPT_CONNECT_ONLY, 1L);
}
@ -111,7 +112,7 @@ bool CurlUtils::http_post_file_request(const std::string url, const std::string
curl_slist_free_all(slist1);
curl_easy_reset(m_curlForPost);
ereport(WARNING, (errmsg("Connection issue happended, post file error: %s\n", curl_easy_strerror(res))));
ereport(WARNING, (errmsg("Connection issue happened, post file error: %s\n", curl_easy_strerror(res))));
return false;
}
curl_slist_free_all(slist1);