From 3c8cd6289b203d632a6880e9a14365394bb0c2a0 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Sat, 28 Sep 2019 10:36:47 -0700 Subject: [PATCH] ixcobra / fix crash in CobraConnection::publishNext when the queue is empty + handle CobraConnection_PublishMode_Batch in CobraMetricsThreadedPublisher --- DOCKER_VERSION | 2 +- docs/CHANGELOG.md | 4 ++++ ixcobra/ixcobra/IXCobraConnection.cpp | 8 +++++++- ixcobra/ixcobra/IXCobraConnection.h | 3 +++ ixcobra/ixcobra/IXCobraMetricsThreadedPublisher.cpp | 5 ++++- ixwebsocket/IXWebSocketVersion.h | 2 +- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/DOCKER_VERSION b/DOCKER_VERSION index c84aaa07..798e3899 100644 --- a/DOCKER_VERSION +++ b/DOCKER_VERSION @@ -1 +1 @@ -6.2.9 +6.3.0 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 7b9a7a0f..7464493f 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## [6.3.0] - 2019-09-28 + +- ixcobra / fix crash in CobraConnection::publishNext when the queue is empty + handle CobraConnection_PublishMode_Batch in CobraMetricsThreadedPublisher + ## [6.2.9] - 2019-09-27 - mbedtls fixes / the unittest now pass on macOS, and hopefully will on Windows/AppVeyor as well. diff --git a/ixcobra/ixcobra/IXCobraConnection.cpp b/ixcobra/ixcobra/IXCobraConnection.cpp index 9382050a..42502ba9 100644 --- a/ixcobra/ixcobra/IXCobraConnection.cpp +++ b/ixcobra/ixcobra/IXCobraConnection.cpp @@ -233,6 +233,11 @@ namespace ix _publishMode = publishMode; } + CobraConnectionPublishMode CobraConnection::getPublishMode() + { + return _publishMode; + } + void CobraConnection::configure(const std::string& appkey, const std::string& endpoint, const std::string& rolename, @@ -487,10 +492,11 @@ namespace ix { std::lock_guard lock(_queueMutex); + if (_messageQueue.empty()) return true; + auto&& msg = _messageQueue.back(); if (!publishMessage(msg)) { - _messageQueue.push_back(msg); return false; } _messageQueue.pop_back(); diff --git a/ixcobra/ixcobra/IXCobraConnection.h b/ixcobra/ixcobra/IXCobraConnection.h index baa01038..4c8c1a48 100644 --- a/ixcobra/ixcobra/IXCobraConnection.h +++ b/ixcobra/ixcobra/IXCobraConnection.h @@ -114,6 +114,9 @@ namespace ix /// Set the publish mode void setPublishMode(CobraConnectionPublishMode publishMode); + /// Query the publish mode + CobraConnectionPublishMode getPublishMode(); + /// Lifecycle management. Free resources when backgrounding void suspend(); void resume(); diff --git a/ixcobra/ixcobra/IXCobraMetricsThreadedPublisher.cpp b/ixcobra/ixcobra/IXCobraMetricsThreadedPublisher.cpp index a208ab76..17e859c6 100644 --- a/ixcobra/ixcobra/IXCobraMetricsThreadedPublisher.cpp +++ b/ixcobra/ixcobra/IXCobraMetricsThreadedPublisher.cpp @@ -166,7 +166,10 @@ namespace ix case MessageKind::Message: { - _cobra_connection.publishNext(); + if (_cobra_connection.getPublishMode() == CobraConnection_PublishMode_Immediate) + { + _cobra_connection.publishNext(); + } }; break; } } diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 957af26a..14d9b839 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "6.2.9" +#define IX_WEBSOCKET_VERSION "6.3.0"