libc: close all handles of a socket before release

This prevents diagnostic messages like

  Error: partial write detected 0 vs 31

for writes into already released socket directories due to a still-open
handle to the socket data file.
This commit is contained in:
Christian Helmuth 2018-02-27 14:57:38 +01:00
parent cd7cb5fbf4
commit adc3aa452a
1 changed files with 4 additions and 1 deletions

View File

@ -927,11 +927,14 @@ int Socket_fs::Plugin::close(Libc::File_descriptor *fd)
Socket_fs::Context *context = dynamic_cast<Socket_fs::Context *>(fd->context);
if (!context) return Errno(EBADF);
::unlink(context->path.base());
Absolute_path path = context->path;
Genode::destroy(&global_allocator, context);
Libc::file_descriptor_allocator()->free(fd);
/* finally release the socket path after all handles are closed */
::unlink(path.base());
return 0;
}