summaryrefslogtreecommitdiff
path: root/lib/circular_buffer.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-06-19 20:27:25 -0700
committerJosh Blum2013-06-19 20:27:25 -0700
commit0a30efc54bd115f717f55cf4be0ea5cf20def198 (patch)
treed3ee79e64eb6eba1c51183ace25ede589a3b580b /lib/circular_buffer.cpp
parent8fe3bdb1a67f7f17b8499fb822851102ca050217 (diff)
downloadsandhi-0a30efc54bd115f717f55cf4be0ea5cf20def198.tar.gz
sandhi-0a30efc54bd115f717f55cf4be0ea5cf20def198.tar.bz2
sandhi-0a30efc54bd115f717f55cf4be0ea5cf20def198.zip
gras: add retries for make_circular_buffer ipc exceptions
This commit addresses #104
Diffstat (limited to 'lib/circular_buffer.cpp')
-rw-r--r--lib/circular_buffer.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/circular_buffer.cpp b/lib/circular_buffer.cpp
index 948e3db..0dda400 100644
--- a/lib/circular_buffer.cpp
+++ b/lib/circular_buffer.cpp
@@ -180,7 +180,27 @@ static void circular_buffer_delete(SBuffer &buff, CircularBuffer *circ_buff)
SBuffer make_circular_buffer(const size_t num_bytes)
{
- CircularBuffer *circ_buff = new CircularBuffer(num_bytes);
+ CircularBuffer *circ_buff = NULL;
+ size_t trial_count = 0;
+ while (circ_buff == NULL)
+ {
+ trial_count++;
+ try
+ {
+ circ_buff = new CircularBuffer(num_bytes);
+ }
+ catch(const boost::interprocess::interprocess_exception &ex)
+ {
+ std::cerr << boost::format(
+ "GRAS: make_circular_buffer threw ipc exception on attempt %u\n%s"
+ ) % trial_count % ex.what() << std::endl;
+ if (trial_count== 3) throw ex;
+ }
+ catch(...)
+ {
+ throw;
+ }
+ }
SBufferDeleter deleter = boost::bind(&circular_buffer_delete, _1, circ_buff);
SBufferConfig config;
config.memory = circ_buff->buff_addr;