esp-nimble-cpp
esp-nimble-cpp copied to clipboard
NimBLEClient::connect, when returning false, does not delete the client object when deleteOnConnectFail=true
During debugging, I somewhat randomly discovered that
pClient->setSelfDelete(true, true);
if (!pClient->connect(false, true, true)) {
NimBLEDevice::deleteClient(pClient); // still needs to be called manually
}
when I was getting a number of clients exceeded log despite enabling self delete. Is this behaving correctly? In my case, technically, connect returns early, skipping the connection attempt, but semantically this wasn't obvious to me.
Thanks @dcodeIO, a bit of an oversight for sure. If the connect call fails then the event isn't triggered that would delete the client instance so this may need to be tweaked a bit to handle the case where the call itself fails.