diff --git a/CHANGELOG.md b/CHANGELOG.md index 002b7c2..7e96a67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,6 @@ - `get_index_prefix()` crashed on forensic reports with `TypeError` due to `report()` instead of `report[]` dict access. - Missing `exit(1)` after IMAP user/password validation failure allowed execution to continue with `None` credentials. -- IMAP `watch()` leaked a connection on every IDLE cycle by not closing the old `IMAPClient` before replacing it. ## 9.2.1 diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index c1df138..c813012 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -814,6 +814,12 @@ class _ElasticsearchHandle: """Sentinel so Elasticsearch participates in _close_output_clients.""" def close(self): + try: + conn = elastic.connections.get_connection() + if not isinstance(conn, str): + conn.close() + except Exception: + pass try: elastic.connections.remove_connection("default") except Exception: @@ -824,6 +830,12 @@ class _OpenSearchHandle: """Sentinel so OpenSearch participates in _close_output_clients.""" def close(self): + try: + conn = opensearch.connections.get_connection() + if not isinstance(conn, str): + conn.close() + except Exception: + pass try: opensearch.connections.remove_connection("default") except Exception: diff --git a/parsedmarc/gelf.py b/parsedmarc/gelf.py index 4a6477b..e07fa7d 100644 --- a/parsedmarc/gelf.py +++ b/parsedmarc/gelf.py @@ -37,7 +37,7 @@ class GelfClient(object): """ self.host = host self.port = port - self.logger = logging.getLogger("parsedmarc_syslog") + self.logger = logging.getLogger("parsedmarc_gelf") self.logger.setLevel(logging.INFO) self.logger.addFilter(ContextFilter()) self.gelf_mode = { diff --git a/parsedmarc/mail/imap.py b/parsedmarc/mail/imap.py index 1fd4430..b084bd9 100644 --- a/parsedmarc/mail/imap.py +++ b/parsedmarc/mail/imap.py @@ -90,12 +90,7 @@ class IMAPConnection(MailboxConnection): # IDLE callback sends IMAPClient object, # send back the imap connection object instead def idle_callback_wrapper(client: IMAPClient): - old_client = self._client self._client = client - try: - old_client.logout() - except Exception: - pass check_callback(self) while True: