From 8d3bfe4891ce3727833bb9f82c0e0a6205cc7897 Mon Sep 17 00:00:00 2001 From: maxz Date: Mon, 11 Nov 2024 11:32:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AE=A1=E8=AE=A1=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=AF=8F=E6=AC=A1=E5=90=AF=E5=8A=A8=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gausskernel/process/postmaster/pgaudit.cpp | 10 +++++++++- src/gausskernel/security/gs_policy/curl_utils.cpp | 5 +++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/process/postmaster/pgaudit.cpp b/src/gausskernel/process/postmaster/pgaudit.cpp index b78089c6d..e8938cd49 100755 --- a/src/gausskernel/process/postmaster/pgaudit.cpp +++ b/src/gausskernel/process/postmaster/pgaudit.cpp @@ -595,6 +595,14 @@ static void sig_thread_config_handler(int ¤tAuditRotationAge, int ¤t } } +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(); } diff --git a/src/gausskernel/security/gs_policy/curl_utils.cpp b/src/gausskernel/security/gs_policy/curl_utils.cpp index 5720f85e8..ddac5ef69 100644 --- a/src/gausskernel/security/gs_policy/curl_utils.cpp +++ b/src/gausskernel/security/gs_policy/curl_utils.cpp @@ -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);