From e0e9b451caeee504c54b06e0b319daaf10f52c3e Mon Sep 17 00:00:00 2001 From: Eric Harding Date: Fri, 23 Mar 2018 13:14:37 -0400 Subject: [PATCH] spark-947 - Fix crash in read_trades at startup. --- src/lib/md/MDConsumer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/md/MDConsumer.cpp b/src/lib/md/MDConsumer.cpp index 5811fe00c..efe88f78c 100644 --- a/src/lib/md/MDConsumer.cpp +++ b/src/lib/md/MDConsumer.cpp @@ -87,7 +87,7 @@ public: _hot.reset(new utils::SharedListReader(hot_segment_name(symbol, type, exchange, _platform), shared)); } } - ~MDConsumerInst() { } + ~MDConsumerInst() { if (_queues) delete _queues; } template size_t walk_sec_list(CB cb, const string& symbol="", SecurityType type=SECURITYTYPE_UNSET) { @@ -273,7 +273,8 @@ private: bool init_queues() { if (_queues) return true; if (!_cold.is_initialized()) return false; - _queues.reset(new QueueStruct(_cold.header())); + // double assignment is OK. Leak instead of lock. + _queues = new QueueStruct(_cold.header()); return true; } @@ -286,7 +287,7 @@ private: unique_ptr> _hot; unique_ptr> _hot_depth; utils::SharedListReader _cold; - unique_ptr _queues; + QueueStruct* _queues; }; ///////////////////////////////////////////////////////////////////////////////////////////////////