Skip to content

Commit

Permalink
Merge pull request #104 from wilx/master
Browse files Browse the repository at this point in the history
Merge.
  • Loading branch information
wilx committed Aug 7, 2015
2 parents 965a74f + d33b1e0 commit 84d6088
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 14 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,43 @@ less than `0x900` and vice versa.
$ ../configure CPPFLAGS="-D__MSVCRT_VERSION__=0x700"


Windows and Visual Studio
-------------------------

[log4cplus] uses C++11 thread and synchronization facilities. The
synchronization facilities are implemented in Visual Studio C++ standard
library in a way that utilizes global variables. Therefore it is impossible
(due to "static initialization order fiasco") to use them outside
`main()`. This issue manifests as a deadlock on exit during destruction of
[log4cplus]' thread pool.

To overcome this limitation,

- always use `log4cplus::Initializer initializer;` as the first thing in
`main()`;

- never try to log from static/global objects constructors;

- never try to log from static/global object destructors.

Defining the `log4cplus::Initializer` instance as the first thing in `main()`
ensures that [log4cplus] is initialized. More importantly, it ensures that
[log4cplus] shuts down before the execution leaves the `main()` function.


Windows and rolling file Appenders
----------------------------------

On Windows, the standard C++ file streams open files in way that underlying
Win32 file `HANDLE` is not open with `FILE_SHARE_DELETE` flag. This flag,
beside shared delete, allows renaming files that have handles open to
them. This issue manifests as error code 13 when the file needs to be rolled
over and it is still open by another process.

This is also [bug #167](https://sourceforge.net/p/log4cplus/bugs/167/) on
SourceForge.


Windows and TLS
---------------

Expand Down
9 changes: 0 additions & 9 deletions docs/latex-header.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
%%

\usepackage{fix-cm}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{anyfontsize}
Expand Down Expand Up @@ -70,14 +69,6 @@
numbers=left, numberstyle=\scriptsize\noncopy,
prebreak={\raisebox{0ex}[0ex][0ex]{\ensuremath{\noncopy{\rhookswarrow}}}}}

\lstdefinelanguage{diff}{
morecomment=[f][\color{blue}]{@@}, % group identifier
morecomment=[f][\color{red}]-, % deleted lines
morecomment=[f][\color{green}]+, % added lines
morecomment=[f][\color{magenta}]{---}, % Diff header lines (must appear after +,-)
morecomment=[f][\color{magenta}]{+++},
}

%%
%% latex-header.tex end
%%
3 changes: 2 additions & 1 deletion docs/release.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ This describes log4cplus release procedure:
to date. Run `scripts/propagate-version.sh` followed by
`scripts/doautoreconf.sh`. _Do not forget to commit the changes._

#. Run `scripts/prepare_dist_from_bzr.sh` to prepare tarballs.
#. Run `scripts/prepare_dist_from_git.sh` to prepare tarballs. _Do not tag the
revision, yet._

#. [Upload tarballs][4] to SourceForge.

Expand Down
15 changes: 14 additions & 1 deletion scripts/build-pdf.pl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#! env perl

# This is a helper script for building log4cplus documentation PDF from several
# Markdown formatted files.

Expand Down Expand Up @@ -38,7 +40,8 @@
, '--latex-engine=lualatex',
, '--include-in-header=docs/latex-header.tex'
, '--include-before-body=docs/latex-body.tex'
, '-V', 'lang=english');
, '-V', 'lang=english',
, '-V', 'geometry:a4paper');

# pre-compute various source information strings

Expand Down Expand Up @@ -109,3 +112,13 @@
print Dumper(\@args), "\n";

system(@args);


# produce PDF using latexmk utility to run the LuaLaTeX

@args = (
'latexmk', '-gg', '-lualatex', 'README.md.tex');

print Dumper(\@args), "\n";

system(@args);
2 changes: 1 addition & 1 deletion scripts/propagate-version.pl
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ BEGIN
|| $line =~ s/\d+ ([._\-]) \d+ ([._\-]) \d+
/$major$1$minor$2$so_current_adjusted/gx;
print $line;
}
}
}
1 change: 1 addition & 0 deletions scripts/upload_to_wiki.pl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! env perl
use strict;
use IO::All;
use LWP::UserAgent;
Expand Down
4 changes: 4 additions & 0 deletions src/global-init.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ Initializer::Initializer ()
}


// Forward declaration. Defined in this file.
void shutdownThreadPool();

Initializer::~Initializer ()
{
bool destroy = false;
Expand All @@ -109,6 +112,7 @@ Initializer::~Initializer ()
if (InitializerImpl::instance->count == 0)
{
destroy = true;
shutdownThreadPool();
Logger::shutdown ();
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/hierarchy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,11 @@ Hierarchy::getLoggerFactory()

// from global-init.cxx
void waitUntilEmptyThreadPoolQueue ();
void shutdownThreadPool ();

void
Hierarchy::shutdown()
{
waitUntilEmptyThreadPoolQueue ();
shutdownThreadPool ();

LoggerList loggers = getCurrentLoggers();

Expand Down

0 comments on commit 84d6088

Please sign in to comment.