mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-29 06:50:38 +03:00
Fix a couple of resource leaks in daemon-common server code -- filehandles and
unjoined threads were leaked for each connection.
This commit is contained in:
parent
55bdb63f34
commit
e31a3a6da6
@ -251,9 +251,6 @@ static void *client_thread(void *baton)
|
||||
if (!req.cft)
|
||||
fprintf(stderr, "error parsing request:\n %s\n", req.buffer);
|
||||
res = b->s.handler(b->s, b->client, req);
|
||||
if (req.cft)
|
||||
dm_config_destroy(req.cft);
|
||||
dm_free(req.buffer);
|
||||
|
||||
if (!res.buffer) {
|
||||
dm_config_write_node(res.cft->root, buffer_line, &res);
|
||||
@ -261,12 +258,17 @@ static void *client_thread(void *baton)
|
||||
dm_config_destroy(res.cft);
|
||||
}
|
||||
|
||||
if (req.cft)
|
||||
dm_config_destroy(req.cft);
|
||||
dm_free(req.buffer);
|
||||
|
||||
write_buffer(b->client.socket_fd, res.buffer, strlen(res.buffer));
|
||||
|
||||
free(res.buffer);
|
||||
}
|
||||
fail:
|
||||
/* TODO what should we really do here? */
|
||||
close(b->client.socket_fd);
|
||||
free(baton);
|
||||
return NULL;
|
||||
}
|
||||
@ -291,6 +293,8 @@ static int handle_connect(daemon_state s)
|
||||
if (pthread_create(&baton->client.thread_id, NULL, client_thread, baton))
|
||||
return 0;
|
||||
|
||||
pthread_detach(baton->client.thread_id);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user