Allow shutting down sockets for read, write or both

This replaces half-closing sockets with calls to shut down a socket
endpoint for read, write, or both as a separate operation from closing.
Shutting an endpoint down for read disables all further reads from that
endpoint (past data already buffered) and all further writes into the
peer endpoint. Shutting an endpoint down for writing disables all
further writing into that endpoint and all reader from the peer
endpoint (past data already buffered).

Shutting a socket endpoint down no longer raises the PEER_CLOSED
signal on the peer endpoint. Separate signals are raised when reading and
writing are disabled and the PEER_CLOSED signal is only raised when the peer
is actually closed.

In mxio, this fully implements the posix shutdown(2) calls for local sockets
created with the socketpair(2) call.  Remote sockets support shutdown(SHUT_WR)
using their existing mechanism. Once remote sockets are migrated to use an
mx_socket directly, they can re-use this machinery to fully support partial

This is a reland of 2f2e0a0f8f1cefdd9505d5ba18d4c8aeaacb4188 which was reverted
in a8fa45f268598f75478464f568d543ad3e58a0cb, with the following changes:

mxio/remotesocket.c updated to use the new shutdown bits for reading
and writing

The READ_DISABLED signal is now only raised when reading is disabled in
that direction on the socket and the socket is drained in that

New tests added for blocking recv() and send() and fixes in the mxio
bindings to behave correctly for these cases.

Change-Id: I455855d29a6a79d2e98ad47b37222965332b9b98
12 files changed
tree: 255dce0a8be489903479f0e8b2c4bcb895d5e9c2
  1. .clang-format
  2. .dir-locals.el
  3. .gitignore
  4. .travis.yml
  9. bootloader/
  10. docs/
  11. kernel/
  12. make/
  13. makefile
  15. prebuilt/
  16. scripts/
  17. system/
  18. third_party/


Magenta is the core platform that powers the Fuchsia OS. Magenta is composed of a microkernel (source in kernel/...) as well as a small set of userspace services, drivers, and libraries (source in system/...) necessary for the system to boot, talk to hardware, load userspace processes and run them, etc. Fuchsia builds a much larger OS on top of this foundation.

The canonical Magenta Git repository is located at:

A read-only mirror of the code is present at:

The Magenta Kernel provides syscalls to manage processes, threads, virtual memory, inter-process communication, waiting on object state changes, and locking (via futexes).

Currently there are some temporary syscalls that have been used for early bringup work, which will be going away in the future as the long term syscall API/ABI surface is finalized. The expectation is that there will be 10s, not 100s of syscalls.

Magenta syscalls are generally non-blocking. The wait (one, many, set) family of syscalls, ioport reads, and thread sleep being the notable exceptions.

This page is a non-comprehensive index of the magenta documentation.