From 0c70f02008c0a9ba85e9f41ba5992a7bf9dfc82c Mon Sep 17 00:00:00 2001 From: Emmanuel Taurel Date: Wed, 2 May 2018 10:18:56 +0200 Subject: [PATCH 1/2] - Fix memory leak when pipe event is sent and there is no client process(es) subscribed to this event --- cppapi/server/pipe.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cppapi/server/pipe.cpp b/cppapi/server/pipe.cpp index 6db01d326..c01dd45af 100644 --- a/cppapi/server/pipe.cpp +++ b/cppapi/server/pipe.cpp @@ -788,7 +788,12 @@ void Pipe::fire_event(DeviceImpl *dev,DevicePipeBlob *p_data,struct timeval &t,b delta_subscription = now - event_subscription; if (delta_subscription >= EVENT_RESUBSCRIBE_PERIOD) + { + p_data->reset_insert_ctr(); + DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); + delete tmp_ptr; return; + } // // Get the event supplier, and simply return if not created @@ -801,6 +806,9 @@ void Pipe::fire_event(DeviceImpl *dev,DevicePipeBlob *p_data,struct timeval &t,b if (event_supplier_zmq == NULL) { + p_data->reset_insert_ctr(); + DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); + delete tmp_ptr; return; } From 912d05e2947d8d6d8dc522f615d15650d5343343 Mon Sep 17 00:00:00 2001 From: Reynald Bourtembourg Date: Thu, 3 May 2018 18:01:39 +0200 Subject: [PATCH 2/2] Indent like the surrounding code --- cppapi/server/pipe.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cppapi/server/pipe.cpp b/cppapi/server/pipe.cpp index c01dd45af..544f2c38c 100644 --- a/cppapi/server/pipe.cpp +++ b/cppapi/server/pipe.cpp @@ -788,12 +788,12 @@ void Pipe::fire_event(DeviceImpl *dev,DevicePipeBlob *p_data,struct timeval &t,b delta_subscription = now - event_subscription; if (delta_subscription >= EVENT_RESUBSCRIBE_PERIOD) - { - p_data->reset_insert_ctr(); - DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); - delete tmp_ptr; + { + p_data->reset_insert_ctr(); + DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); + delete tmp_ptr; return; - } + } // // Get the event supplier, and simply return if not created @@ -806,9 +806,9 @@ void Pipe::fire_event(DeviceImpl *dev,DevicePipeBlob *p_data,struct timeval &t,b if (event_supplier_zmq == NULL) { - p_data->reset_insert_ctr(); - DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); - delete tmp_ptr; + p_data->reset_insert_ctr(); + DevVarPipeDataEltArray *tmp_ptr = p_data->get_insert_data(); + delete tmp_ptr; return; }