about summary refs log tree commit diff
path: root/src/libutil/serialise.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2011-12-16T15·45+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2011-12-16T15·45+0000
commit78598d06f0240a15b74720d8f987daeb702318d7 (patch)
tree362d25677710ade8084a5ca417d88224f1c6faa0 /src/libutil/serialise.cc
parent5a1b9ed0aa3a0c240b667dbe504b61b2b68e4d16 (diff)
* Clean up exception handling.
Diffstat (limited to 'src/libutil/serialise.cc')
-rw-r--r--src/libutil/serialise.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libutil/serialise.cc b/src/libutil/serialise.cc
index a82262704ea3..76f2e721a535 100644
--- a/src/libutil/serialise.cc
+++ b/src/libutil/serialise.cc
@@ -41,8 +41,15 @@ void BufferedSink::operator () (const unsigned char * data, size_t len)
 void BufferedSink::flush()
 {
     if (bufPos == 0) return;
-    write(buffer, bufPos);
-    bufPos = 0;
+    size_t n = bufPos;
+    bufPos = 0; // don't trigger the assert() in ~BufferedSink()
+    write(buffer, n);
+}
+
+
+FdSink::~FdSink()
+{
+    try { flush(); } catch (...) { ignoreException(); }
 }