veyron/lib/bluetooth: Make the bluetooth net.Conn and net.Listener
implementations amenable to concurrent method invocations.

This is required to adhere to the net.Conn interface.

Prior to this commit, the net.Conn and net.Listener implementations in
the bluetooth package were subject to races where a read/write/accept
may be called on a file descriptor that has been closed and reassigned
to a different file/socket.

This commit introduces a "thread-safe" file descriptor wrapper in the
bluetooth.fd type. The basic idea is to replace one file descriptor with
two - the second one being an eventfd used to signal a pending Close
operation and then using a mutex and the select system call to ensure
that operations on the file descriptors cannot happen after they have
been closed.

Change-Id: Ic57161cf4f2b893138beba9cfefba36a4141aaec
6 files changed
tree: a15d30a6d4ac68b83005e7b722a92d43f5da513d
  1. examples/
  2. lib/
  3. runtimes/
  4. security/
  5. services/
  6. tools/