summaryrefslogtreecommitdiffstats
path: root/src/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.c')
-rw-r--r--src/client.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/client.c b/src/client.c
index 52e569d..7395046 100644
--- a/src/client.c
+++ b/src/client.c
@@ -251,6 +251,20 @@ int client_accept(int listenfd)
251 251
252void client_close(struct mux_client *client) 252void client_close(struct mux_client *client)
253{ 253{
254 int found = 0;
255 pthread_mutex_lock(&client_list_mutex);
256 FOREACH(struct mux_client *lc, &client_list) {
257 if (client == lc) {
258 found = 1;
259 break;
260 }
261 } ENDFOREACH
262 if (!found) {
263 // in case we get called again but client was already freed
264 usbmuxd_log(LL_DEBUG, "%s: ignoring for non-existing client %p", __func__, client);
265 pthread_mutex_unlock(&client_list_mutex);
266 return;
267 }
254#ifdef SO_PEERCRED 268#ifdef SO_PEERCRED
255 if (log_level >= LL_INFO) { 269 if (log_level >= LL_INFO) {
256 struct ucred cr; 270 struct ucred cr;
@@ -278,7 +292,6 @@ void client_close(struct mux_client *client)
278 free(client->ib_buf); 292 free(client->ib_buf);
279 plist_free(client->info); 293 plist_free(client->info);
280 294
281 pthread_mutex_lock(&client_list_mutex);
282 collection_remove(&client_list, client); 295 collection_remove(&client_list, client);
283 pthread_mutex_unlock(&client_list_mutex); 296 pthread_mutex_unlock(&client_list_mutex);
284 free(client); 297 free(client);