shm: use shutdown() instead of close()

we make sure both ends get notified when the socket is closed by using
shutdown() instead of close().

https://bugzilla.gnome.org/show_bug.cgi?id=724077
This commit is contained in:
Aleix Conchillo Flaqué 2014-02-10 14:33:49 -08:00 committed by Olivier Crête
parent 73d9a8b0c9
commit f5a1ccd0de

View file

@ -429,7 +429,7 @@ sp_writer_close (ShmPipe * self, sp_buffer_free_callback callback,
void *user_data) void *user_data)
{ {
if (self->main_socket >= 0) if (self->main_socket >= 0)
close (self->main_socket); shutdown (self->main_socket, SHUT_RDWR);
if (self->socket_path) { if (self->socket_path) {
unlink (self->socket_path); unlink (self->socket_path);
@ -840,7 +840,7 @@ sp_writer_accept_client (ShmPipe * self)
return client; return client;
error: error:
close (fd); shutdown (fd, SHUT_RDWR);
return NULL; return NULL;
} }
@ -892,7 +892,7 @@ sp_writer_close_client (ShmPipe * self, ShmClient * client,
ShmBuffer *buffer = NULL, *prev_buf = NULL; ShmBuffer *buffer = NULL, *prev_buf = NULL;
ShmClient *item = NULL, *prev_item = NULL; ShmClient *item = NULL, *prev_item = NULL;
close (client->fd); shutdown (client->fd, SHUT_RDWR);
again: again:
for (buffer = self->buffers; buffer; buffer = buffer->next) { for (buffer = self->buffers; buffer; buffer = buffer->next) {