From 4ad0afc4283ba54a8c63fbf5d05e203c06ea7747 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 26 Jul 2012 15:33:40 +0000 Subject: Gracefully handle notification ring overflow. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4557 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/Context.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server/Context.cpp b/src/server/Context.cpp index 0736b451..86feaf67 100644 --- a/src/server/Context.cpp +++ b/src/server/Context.cpp @@ -51,8 +51,15 @@ Context::notify(LV2_URID key, const void* body) { const Notification n(port, time, key, size, type); - _event_sink.write(sizeof(n), &n); - _event_sink.write(size, body); + if (_event_sink.write_space() < sizeof(n) + size) { + Raul::warn("Notification ring overflow\n"); + } else { + if (_event_sink.write(sizeof(n), &n) != sizeof(n)) { + Raul::error("Error writing header to notification ring\n"); + } else if (_event_sink.write(size, body) != size) { + Raul::error("Error writing body to notification ring\n"); + } + } } void -- cgit v1.2.1