Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ML::filter_ostream: added debugging output for the handling of deferred ... #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions utils/filter_streams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <boost/lexical_cast.hpp>
#include "jml/arch/exception.h"
#include "jml/arch/format.h"
#include "jml/arch/threads.h"
#include "string_functions.h"
#include <errno.h>
#include <sstream>
Expand Down Expand Up @@ -119,8 +120,9 @@ filter_ostream::
try {
close();
}
catch (...) {
cerr << "~filter_ostream: ignored exception\n";
catch (const std::exception & exc) {
cerr << ("~filter_ostream: ignored exception: "
+ string(exc.what()) + "\n");
}
}

Expand Down Expand Up @@ -472,16 +474,23 @@ void
filter_ostream::
close()
{
bool wasClosed(true); // closed when "close" is called
if (stream) {
boost::iostreams::flush(*stream);
boost::iostreams::close(*stream);
wasClosed = false;
}
exceptions(ios::goodbit);
rdbuf(0);
stream.reset();
sink.reset();
options.clear();
if (hasDeferredFailure()) {
if (wasClosed) {
cerr << (to_string(getpid()) + "/" + to_string(gettid())
+ ": filter_ostream: a deferred failure has been reported"
" for a closed stream\n");
}
clearDeferredFailure();
exceptions(ios::badbit | ios::failbit);
setstate(ios::badbit);
Expand Down Expand Up @@ -533,8 +542,9 @@ filter_istream::
try {
close();
}
catch (...) {
cerr << "~filter_istream: ignored exception\n";
catch (const std::exception & exc) {
cerr << ("~filter_istream: ignored exception: "
+ string(exc.what()) + "\n");
}
}

Expand Down