The shell script previously used to launch the daemon is now called
"initscript". The script files have had the ".js" extension removed
from their names.
The Makefile can be used to build and install rlgwebd. On systems with
systemd, the unit file controls starting and stopping the service, and
the shell script is not needed.
The unit file uses KillMode=none because socat does not actually stop
rlgwebd, it only asks it to stop and exits without waiting for a
response. Until a better stopping method is introduced, this setting
prevents systemd from killing all the rlgwebd processes as soon as
socat exits.
The crashes apparently resulted from reading a ttyrec header and
then trying to read the data chunk before dgamelaunch produced it.
When the data chunk did become available, it would be read by the
header function.
The simplest solution was to store the position for reading the
ttyrec file in the DGLSession, and to leave it unchanged if anything
unexpected occurs when reading.
Multiple games can now run at the same time, and data will be sent to
the proper place. The interaction of multiple players with watchers
has not yet been tested.
Failure is now signaled with a TermSession.failed flag.
Playing two games at the same time no longer causes crashes, but it
does send the same output to both players.
DglSession objects read a 12-byte TTYREC header, extract therefrom the
length of the data chunk, and then read the data. In between these two
reads, the file watcher could trigger another readchunk() invocation,
which might attempt to read a header from the beginning of the data
chunk. This usually results in expecting a data chunk of several GB
and failing to create a Buffer for it.
The race is remedied by setting a flag on the DglSession object
whenever readchunk() is called, clearing it when both reads complete,
and refusing to read if it is already set.
The /status WebSocket now only sends a complete list when opened. At
40-second intervals, it sends a list of games that have been updated in
the last minute. The client now uses this to keep its own list.
TermSessions now store the timestamp of the latest data. This removes
the need to use fstat() to calculate idle times.
The reaper() function is removed. It may be useful to find another way
to remove old login keys.
Games will be indentified by gamename/username pairs. This will allow
better interoperability with dgamelaunch.
Polling clients are no longer supported; the code remnants need to be
removed. The reaper() function will likely crash. Unexpectedly, the
WebSocket client still works well enough to play. Watching and listing
current games are probably broken.
watcher.c is a subprocess which uses inotify to watch the inprogress
directories. A C program is used because node's fs.watch() can't tell
the difference between creation and deletion.