Update: EventQue deleminate null Event.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2016-10-19 17:20:22 +09:00
parent 143b2ef90b
commit e2cf453c6b
4 changed files with 22 additions and 24 deletions

View File

@@ -35,7 +35,8 @@ ClientAuthentication=NO
#RootCAfile=/path/to/your_Root_CA.crt
#RootCApath=/path/to/your_certs_directory/
#CertsDirectory=/path/to/your_client_certs_directory/
#CertKey=/path/to/your_cert.pem
#PrivateKey=/path/to/your_private-key.pem
GatewayID=1
GatewayName=PahoGateway-01
@@ -59,7 +60,7 @@ ApiMode=2
Client should know the BroadcastIP and PortNo to send a SEARCHGW message.
**GatewayId** is defined by GWSEARCH message.
**KeepAlive** is a duration of ADVERTISE message in seconds.
when **ClientAuthentication** is YES, see MQTTSNGWClient.cpp line53, clients file specified by ClientsList is required. This file defines connect allowed clients by ClientId, IPaddress and PortNo.
when **ClientAuthentication** is YES, see MQTTSNGWClient.cpp line53, clients file specified by ClientsList is required. This file defines connect allowed clients by ClientId and SensorNetwork Address. e.g. IP address and Port No.

View File

@@ -152,7 +152,7 @@ void ClientRecvTask::log(Client* client, MQTTSNPacket* packet, MQTTSNString* id)
if ( id )
{
memset((void*)cstr, 0, id->lenstring.len);
memset((void*)cstr, 0, id->lenstring.len + 1);
strncpy(cstr, id->lenstring.data, id->lenstring.len) ;
clientId = cstr;
}

View File

@@ -207,7 +207,7 @@ public:
int post(T* t)
{
if ( t && ( _maxSize == 0 || size() < _maxSize ))
if ( t && ( _maxSize == 0 || _cnt < _maxSize ))
{
QueElement<T>* elm = new QueElement<T>(t);
if ( _head )

View File

@@ -315,19 +315,13 @@ void EventQue::setMaxSize(uint16_t maxSize)
Event* EventQue::wait(void)
{
Event* ev;
while ( true )
{
_sem.wait();
_mutex.lock();
ev = _que.front();
_que.pop();
_mutex.unlock();
if ( ev )
{
return ev;
}
}
}
Event* EventQue::timedwait(uint16_t millsec)
{
@@ -355,6 +349,8 @@ Event* EventQue::timedwait(uint16_t millsec)
}
void EventQue::post(Event* ev)
{
if ( ev )
{
_mutex.lock();
if ( _que.post(ev) )
@@ -367,6 +363,7 @@ void EventQue::post(Event* ev)
}
_mutex.unlock();
}
}
int EventQue::size()
{