server: Use ringbuffer for socket backlog

Currently, the socket handler uses a linear buffer for the backlog data;
this means we need to shift up to 128kB of data after each socket
write().

This change introduces a single-producer-multiple-consumer ringbuffer,
to avoid the need for memmove()ing data around; we can simply update
pointers instead of shifting data.

We add this as a new file (ringbuffer.c), to make it a little more
modular. To mitigate the risk of subtle pointer arithmetic issues, we
add a set of tests too.

Change-Id: Ib7c5151d3cf1f588436f5461000b6fed22d0681c
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
14 files changed
tree: 13c1931684122480f2b2c1cc88f93b05948ac074
  1. test/
  2. .travis.yml
  3. bootstrap.sh
  4. config.c
  5. configure.ac
  6. console-client.c
  7. console-server.c
  8. console-server.h
  9. console-socket.c
  10. LICENSE
  11. log-handler.c
  12. Makefile.am
  13. obmc-console.conf.sample
  14. README.md
  15. ringbuffer.c
  16. socket-handler.c
  17. tty-handler.c
  18. util.c
README.md

To Build

Note: In addition to a toolchain and autoconf tools, this requires autotools-archive to be installed.

To build this project, run the following shell commands:

./bootstrap.sh
./configure ${CONFIGURE_FLAGS}
make

To fully clean the repository, run:

./bootstrap.sh clean

To Run Server

Running the server requires a serial port (e.g. /dev/ttyS0):

touch obmc-console.conf
./obmc-console-server --config obmc-console.conf ttyS0

To Connect Client

To connect to the server, simply run the client:

./obmc-console-client

To disconnect the client, use the standard ~. combination.