Skip to content
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