BugFix: 100% CPU

This commit is contained in:
tomoaki
2016-12-07 22:45:18 +09:00
parent 4ebd92fc14
commit 64f7bbac1b
4 changed files with 10 additions and 4 deletions

View File

@@ -16,6 +16,7 @@
#include "MQTTSNGWBrokerRecvTask.h"
#include "MQTTSNGWClient.h"
#include <unistd.h>
using namespace std;
using namespace MQTTSNGW;
@@ -90,7 +91,11 @@ void BrokerRecvTask::run(void)
client = client->getNextClient();
}
if (maxSock > 0)
if (maxSock == 0)
{
usleep(500 * 1000);
}
else
{
/* Check sockets is ready to read */
int activity = select(maxSock + 1, &rset, 0, 0, &timeout);

View File

@@ -25,7 +25,7 @@ namespace MQTTSNGW
/*=================================
* Starting prompt
==================================*/
#define GATEWAY_VERSION " * Version: 0.9.5"
#define GATEWAY_VERSION " * Version: 0.9.6"
#define PAHO_COPYRIGHT0 " * MQTT-SN Transparent Gateway"
#define PAHO_COPYRIGHT1 " * Part of Project Paho in Eclipse"

View File

@@ -503,7 +503,8 @@ int Network::recv(uint8_t* buf, uint16_t len)
}
_busy = true;
loop: do
loop:
do
{
readBlockedOnWrite = false;
readBlocked = false;

View File

@@ -400,7 +400,7 @@ SerialPort::SerialPort()
_tio.c_iflag = IGNBRK | IGNPAR;
_tio.c_cflag = CS8 | CLOCAL | CRTSCTS;
_tio.c_cc[VINTR] = 0;
_tio.c_cc[VTIME] = 0;
_tio.c_cc[VTIME] = 10; // 1 sec.
_tio.c_cc[VMIN] = 1;
_fd = 0;
}