Hi there,
I've been using the MQTT-SN-GW with the Amazon MQTT Broker. I've noticed when the keep-alive time is exceeded that the SSL connection on the GW side may not be cleaned up properly. When the AWS client closes the SSL connection, the network receives an SSL_ERROR_ZERO_RETURN.
After the return -1, the client socket will be rechecked, receiving a return code of 0 (since _ssl is now 0) in
void BrokerRecvTask::run(void)
{
...
if ( rc == 0 ) // Disconnected
{
client->getNetwork()->close();
delete packet;
/* delete client when the client is not authorized & session is clean */
_gateway->getClientList()->erase(client);
if ( client )
{
client = client->getNextClient();
}
continue;
}
...
When client->getNetwork()->close(); is called, it will not fully run since the case SSL_ERROR_ZERO_RETURN cleaned up only part of the ssl connection.
Also line _gateway->getClientList()->erase(client); does not erase the cliet from the list either since in the erase function the _authorize with always be true.
So what I did to try and fix the leaks were the following:
However, now that the leak is fixed, I've been getting issues. now with _mutex.lock(). It will sometimes throw the following exception.
throw Exception( -1, "The same thread can't acquire a mutex twice.");
Clearly, the way I am going about trying to fix the memory leak is incorrect since this is happening. Do you have any recommendations or implementations that can fix this?
Hi there, I've been using the MQTT-SN-GW with the Amazon MQTT Broker. I've noticed when the keep-alive time is exceeded that the SSL connection on the GW side may not be cleaned up properly. When the AWS client closes the SSL connection, the network receives an SSL_ERROR_ZERO_RETURN.
After the return -1, the client socket will be rechecked, receiving a return code of 0 (since _ssl is now 0) in
When
client->getNetwork()->close();
is called, it will not fully run since thecase SSL_ERROR_ZERO_RETURN
cleaned up only part of the ssl connection. Also line_gateway->getClientList()->erase(client);
does not erase the cliet from the list either since in the erase function the _authorize with always be true.So what I did to try and fix the leaks were the following:
in src/Linux/Network.cpp
in src/MQTTSNGWClientList.cpp
After using Valgrind to check for any more possible leaks, I found that one more.
in src/linux/Network.cpp
However, now that the leak is fixed, I've been getting issues. now with _mutex.lock(). It will sometimes throw the following exception. throw Exception( -1, "The same thread can't acquire a mutex twice.");
Clearly, the way I am going about trying to fix the memory leak is incorrect since this is happening. Do you have any recommendations or implementations that can fix this?
Thanks for your time, Tim