Skip to content

Commit eb58aa7

Browse files
committed
When cloning the client list, do it cleanly
1 parent 2d5f45f commit eb58aa7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/wdctl_thread.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ wdctl_restart(int afd)
253253
char *sock_name;
254254
struct sockaddr_un sa_un;
255255
s_config *conf = NULL;
256-
t_client *client = NULL;
256+
t_client *client, *head;
257257
char *tempstring = NULL;
258258
pid_t pid;
259259
socklen_t len;
@@ -329,7 +329,9 @@ wdctl_restart(int afd)
329329

330330
/* The child is connected. Send them over the socket the existing clients */
331331
LOCK_CLIENT_LIST();
332-
client = client_get_first_client();
332+
client_list_dup(&head);
333+
UNLOCK_CLIENT_LIST();
334+
client = head;
333335
while (client) {
334336
/* Send this client */
335337
safe_asprintf(&tempstring,
@@ -341,7 +343,7 @@ wdctl_restart(int afd)
341343
free(tempstring);
342344
client = client->next;
343345
}
344-
UNLOCK_CLIENT_LIST();
346+
client_list_destroy(head);
345347

346348
close(fd);
347349

0 commit comments

Comments
 (0)