Use refcounting for async shutdown

fix some memory leaks
This commit is contained in:
Wim Taymans 2017-01-12 14:57:07 +01:00
parent ee0aa6a2ac
commit 6d4db64767
21 changed files with 216 additions and 260 deletions

View file

@ -180,6 +180,7 @@ client_new (PinosProtocolNative *impl,
PinosProtocolNativeClient *this;
PinosClient *client;
socklen_t len;
struct ucred ucred, *ucredp;
this = calloc (1, sizeof (PinosProtocolNativeClient));
if (this == NULL)
@ -200,7 +201,15 @@ client_new (PinosProtocolNative *impl,
if (this->connection == NULL)
goto no_connection;
client = pinos_client_new (impl->core, NULL);
len = sizeof (ucred);
if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len) < 0) {
pinos_log_error ("no peercred: %m");
ucredp = NULL;
} else {
ucredp = &ucred;
}
client = pinos_client_new (impl->core, ucredp, NULL);
if (client == NULL)
goto no_client;
@ -210,14 +219,6 @@ client_new (PinosProtocolNative *impl,
client_send_func,
this);
len = sizeof (client->ucred);
if (getsockopt (fd, SOL_SOCKET, SO_PEERCRED, &client->ucred, &len) < 0) {
client->ucred_valid = false;
pinos_log_error ("no peercred: %m");
} else {
client->ucred_valid = true;
}
spa_list_insert (impl->client_list.prev, &this->link);
pinos_global_bind (impl->core->global,