about summary refs log tree commit diff
path: root/src/libutil/serialise.cc
diff options
context:
space:
mode:
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(); }
 }