From 6d51452c555dbc2e086f1ceff7a1859f1d9bf9eb Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 16 Feb 2012 10:08:51 +0900 Subject: Bug fixed in context termination Signed-off-by: Martin Sustrik --- src/ctx.cpp | 11 +++++++++-- tests/Makefile.am | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ctx.cpp b/src/ctx.cpp index c80a3c3..a8df950 100644 --- a/src/ctx.cpp +++ b/src/ctx.cpp @@ -42,6 +42,11 @@ xs::ctx_t::ctx_t (uint32_t io_threads_) : tag (0xbadcafe0), starting (true), terminating (false), + reaper (NULL), + slot_count (0), + slots (NULL), + monitor (NULL), + log_socket (NULL), max_sockets (512), io_thread_count (io_threads_), reentrant (false) @@ -68,12 +73,14 @@ xs::ctx_t::~ctx_t () delete io_threads [i]; // Deallocate the reaper thread object. - delete reaper; + if (reaper) + delete reaper; // Deallocate the array of mailboxes. No special work is // needed as mailboxes themselves were deallocated with their // corresponding io_thread/socket objects. - free (slots); + if (slots) + free (slots); // Remove the tag, so that the object is considered dead. tag = 0xdeadbeef; diff --git a/tests/Makefile.am b/tests/Makefile.am index 78bac57..520b2cf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -19,7 +19,8 @@ noinst_PROGRAMS = pair_inproc \ reqrep_ipc \ timeo \ max_sockets \ - reentrant + reentrant \ + emptyctx pair_inproc_SOURCES = pair_inproc.cpp testutil.hpp pair_tcp_SOURCES = pair_tcp.cpp testutil.hpp @@ -38,5 +39,6 @@ reqrep_ipc_SOURCES = reqrep_ipc.cpp testutil.hpp timeo_SOURCES = timeo.cpp max_sockets_SOURCES = max_sockets.cpp reentrant_SOURCES = reentrant.cpp testutil.hpp +emptyctx_SOURCES = emptyctx.cpp TESTS = $(noinst_PROGRAMS) -- cgit v1.2.3