Skip to content

Commit 6604b09

Browse files
committed
(#17515) [boost]: patch for boost::log
* patch to resolve boostorg/log#209
1 parent 74a5031 commit 6604b09

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

recipes/boost/all/conandata.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ patches:
6565
- patch_file: "patches/1.81.0-locale-fail-on-missing-backend.patch"
6666
patch_description: "Fails the build when there is no iconv backend"
6767
patch_type: "conan"
68+
- patch_file: "patches/1.81.0-log-file-rotate-deadlock.patch"
69+
patch_description: "Boost deadlocks when a log message exceeds log rotate size"
70+
patch_type: "official"
71+
patch_source: "https://github.com/boostorg/log/issues/209"
6872
"1.80.0":
6973
- patch_file: "patches/1.80.0-locale-fail-on-missing-backend.patch"
7074
patch_description: "Fails the build when there is no iconv backend"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
diff --git a/libs/log/src/text_file_backend.cpp b/src/text_file_backend.cpp
2+
index 8b8920e..0df9a37 100644
3+
--- a/libs/log/src/text_file_backend.cpp
4+
+++ b/libs/log/src/text_file_backend.cpp
5+
@@ -1422,6 +1422,7 @@ BOOST_LOG_API void text_file_backend::consume(record_view const& rec, string_typ
6+
rotate_file();
7+
}
8+
9+
+ const unsigned int last_file_counter = m_pImpl->m_FileCounter - 1u;
10+
while (!m_pImpl->m_File.is_open())
11+
{
12+
filesystem::path new_file_name;
13+
@@ -1464,6 +1465,7 @@ BOOST_LOG_API void text_file_backend::consume(record_view const& rec, string_typ
14+
else
15+
{
16+
prev_file_name.swap(new_file_name);
17+
+ use_prev_file_name = false;
18+
}
19+
20+
filesystem::create_directories(new_file_name.parent_path());
21+
@@ -1479,9 +1481,11 @@ BOOST_LOG_API void text_file_backend::consume(record_view const& rec, string_typ
22+
m_pImpl->m_FileName.swap(new_file_name);
23+
m_pImpl->m_IsFirstFile = false;
24+
25+
- // Check the file size before invoking the open handler, as it may write more data to the file
26+
+ // Check the file size before invoking the open handler, as it may write more data to the file.
27+
+ // Only do this check if we haven't exhausted the file counter to avoid looping indefinitely.
28+
m_pImpl->m_CharactersWritten = static_cast< std::streamoff >(m_pImpl->m_File.tellp());
29+
- if (m_pImpl->m_CharactersWritten + formatted_message.size() >= m_pImpl->m_FileRotationSize)
30+
+ if (m_pImpl->m_CharactersWritten > 0 && m_pImpl->m_CharactersWritten + formatted_message.size() >= m_pImpl->m_FileRotationSize &&
31+
+ m_pImpl->m_FileCounter != last_file_counter)
32+
{
33+
// Avoid running the close handler, as we haven't run the open handler yet
34+
struct close_handler_backup_guard
35+

0 commit comments

Comments
 (0)