You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SIOClient::connect(std::string uri) returns a pointer to a "global" client by calling SIOClientRegistry::instance()->getClient(fullpath). If a client to a specific URI already exists, SIOClient::connect returns a pointer to the existing client.
If the user "creates" multiple clients connecting the same server by calling SIOClient::connect, the user actually receives pointers to the same "global" client. The user does not know that without reading the source code. When the user disconnects the clients by calling client->disconnect(), they will all call code:
SIOClient::connect(std::string uri) returns a pointer to a "global" client by calling SIOClientRegistry::instance()->getClient(fullpath). If a client to a specific URI already exists, SIOClient::connect returns a pointer to the existing client.
If the user "creates" multiple clients connecting the same server by calling SIOClient::connect, the user actually receives pointers to the same "global" client. The user does not know that without reading the source code. When the user disconnects the clients by calling client->disconnect(), they will all call code:
void
SIOClient::disconnect() {
_socket->disconnect(_endpoint);
delete this;
}
This results in a segfault, because all the client pointers become invalid when the first client calls disconnect.
Possible solution:
Use reference counting and delete the actual client only when the last reference calls SIOClient::disconnect().
The text was updated successfully, but these errors were encountered: