From fd27bdf5f056967193f1af2a97aa3de806606fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleix=20Conchillo=20Flaqu=C3=A9?= Date: Mon, 10 Feb 2014 15:38:08 -0800 Subject: [PATCH] shm: call close() after shutdown() shutdown() doesn't close the file descriptor so we leak sockets if we don't call close(). https://bugzilla.gnome.org/show_bug.cgi?id=724077 --- sys/shm/shmpipe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/shm/shmpipe.c b/sys/shm/shmpipe.c index e75fe308a3..6ee63506d0 100644 --- a/sys/shm/shmpipe.c +++ b/sys/shm/shmpipe.c @@ -428,8 +428,10 @@ void sp_writer_close (ShmPipe * self, sp_buffer_free_callback callback, void *user_data) { - if (self->main_socket >= 0) + if (self->main_socket >= 0) { shutdown (self->main_socket, SHUT_RDWR); + close (self->main_socket); + } if (self->socket_path) { unlink (self->socket_path); @@ -841,6 +843,7 @@ sp_writer_accept_client (ShmPipe * self) error: shutdown (fd, SHUT_RDWR); + close (fd); return NULL; } @@ -893,6 +896,7 @@ sp_writer_close_client (ShmPipe * self, ShmClient * client, ShmClient *item = NULL, *prev_item = NULL; shutdown (client->fd, SHUT_RDWR); + close (client->fd); again: for (buffer = self->buffers; buffer; buffer = buffer->next) {