Commit graph

17 commits

Author SHA1 Message Date
Solomon Hykes
c5b6f20d56 Fix Go formatting in beam and dockerscript
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 16:16:29 -07:00
Alexander Larsson
cd911b83ce beam: Fix double close of fds in SendUnix
Instead of calling syscall.Close() on the fds in sendUnix() we call
Close() on the *os.File in Send(). Otherwise the fd will be closed, but
the *os.File will continue to live, and when it is finalized the
fd will be closed (which by then may be reused and can be anything).

This also adds a note to Send() the the file is closed.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-22 15:50:22 -07:00
Solomon Hykes
9c5fdb249f beam: improve the API with Sender/Receiver interfaces and utilities: Copy/SendPipe/SendPair
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:21 -07:00
Alexander Larsson
071e5e5a65 beam: Make extracted Fds CloseOnExec
Grab forklock to make sure no forks accidentally inherit the new fds
before they are made CLOEXEC There is a slight race condition between
ReadMsgUnix returns and when we grap the lock, so this is not
perfect. Unfortunately There is no way to pass MSG_CMSG_CLOEXEC to
recvmsg() nor any way to implement non-blocking i/o in go, so this is
hard to fix.

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-04-22 15:50:21 -07:00
Solomon Hykes
5df3aaeda2 beam: fix FD leaks in SendPipe
This fixes file descriptor leaks in the SendPipe function.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:18 -07:00
Solomon Hykes
3b5c1c4203 beam: more hooks for interactive debugging
This inserts low-level hooks for interactive step-by-step debugging.
Hooks are triggered by setting the *TEST* environment variable.

This is particularly useful for tracking down file descriptor leaks,
double-closing, or other issues which are difficult to debug with
the usual toolbox.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:17 -07:00
Solomon Hykes
ccdcd9ff0c Beam: remove leftover debugging messages
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:17 -07:00
Solomon Hykes
b1090576ae Beam: fix bug in beamsh which 'swapped' FDs because of underlying implementation of net.FileConn
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:16 -07:00
Solomon Hykes
43331921b0 Beam: don't close the attachment FD when closing superfluous FDs
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:16 -07:00
Solomon Hykes
24c09d0029 Beam: debugging hooks for easy step-by-step inspection of the FD table
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:16 -07:00
Solomon Hykes
bccd390ead Beam: Send: pass the underlying error unchanged to allow io.EOF detection
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:15 -07:00
Solomon Hykes
968d5bb08f Beam: USocketPair returns a *net.UnixConn socket pair for convenience.
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:15 -07:00
Solomon Hykes
be03962d64 Beam: fix file descriptor leaks
* Close all file descriptors successfully sent as attachment
* Close duplicate file descriptors created by net.FileCon and net.UnixConn.File

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:15 -07:00
Solomon Hykes
95b759ad16 Beam: change the prototype of SendPipe() to return a *net.UnixSocket
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:14 -07:00
Solomon Hykes
0a187f629a Beam: allow sending messages without attachments.
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:14 -07:00
Solomon Hykes
c008283f8d Beam: convenience functions Listen and Connect
These convenience functions expose a familiar face to the unknown and bizarre world of beam networking.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:14 -07:00
Solomon Hykes
932149b2a7 Beam: a simple stream-oriented communication protocol for distributed systems.
This patch includes a stripped down implementation with a bare minimum
unix socket transport. It relies on fd passing for stream multiplexing.

The purpose of this first patch is to allow implementation of dynamic
linking, which will allow advanced service discovery.

Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
2014-04-22 15:50:14 -07:00