mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-13 15:36:51 +01:00
Update: set Max EventQue size to avoid Buffer over flow
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -15,8 +15,8 @@
|
||||
**************************************************************************************/
|
||||
|
||||
#include "MQTTSNGateway.h"
|
||||
#include "MQTTSNGWProcess.h"
|
||||
#include "SensorNetwork.h"
|
||||
#include "MQTTSNGWProcess.h"
|
||||
|
||||
using namespace MQTTSNGW;
|
||||
|
||||
@@ -31,6 +31,7 @@ Gateway::Gateway()
|
||||
theProcess = this;
|
||||
_params.loginId = 0;
|
||||
_params.password = 0;
|
||||
_packetEventQue.setMaxSize(DEFAULT_INFLIGHTMESSAGE * DEFAULT_MAX_CLIENTS);
|
||||
}
|
||||
|
||||
Gateway::~Gateway()
|
||||
@@ -197,7 +198,7 @@ GatewayParams* Gateway::getGWParams(void)
|
||||
=====================================*/
|
||||
EventQue::EventQue()
|
||||
{
|
||||
|
||||
_maxSize = 0;
|
||||
}
|
||||
|
||||
EventQue::~EventQue()
|
||||
@@ -205,6 +206,11 @@ EventQue::~EventQue()
|
||||
|
||||
}
|
||||
|
||||
void EventQue::setMaxSize(uint16_t maxSize)
|
||||
{
|
||||
_maxSize = maxSize;
|
||||
}
|
||||
|
||||
Event* EventQue::wait(void)
|
||||
{
|
||||
Event* ev;
|
||||
@@ -249,14 +255,15 @@ Event* EventQue::timedwait(uint16_t millsec)
|
||||
|
||||
int EventQue::post(Event* ev)
|
||||
{
|
||||
if ( ev )
|
||||
if ( ev && ( _maxSize == 0 || size() < _maxSize ) )
|
||||
{
|
||||
_mutex.lock();
|
||||
_que.post(ev);
|
||||
_sem.post();
|
||||
_mutex.unlock();
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int EventQue::size()
|
||||
|
||||
Reference in New Issue
Block a user