Commit graph

45 commits

Author SHA1 Message Date
ehouse
fc17df2a7e When guest connects, check if providing too many players before
reponding to connection request so that we just deny the request (with
new error code) rather than revoking it later.
2009-12-14 04:10:23 +00:00
ehouse
26469d734c Modify state machine and return new error codes to force host to
connect first, guests second, with clear error messages if the order's
wrong.  This seems to make it simpler for users to get a connection
right.  Code holding multiple games worth of hosts and guests in a
cref is gone.
2009-12-04 08:03:27 +00:00
ehouse
2ecf415618 Remove on case where HandleEvents was being called recursively and
creating unexpected state transitions; add assert to catch any future
recursion.
2009-11-09 05:30:42 +00:00
ehouse
aae12428da Add limited support for store-and-forward (where limitations include
that all devices must be connected initially and that it's all memory
based so a crash wipes stored messages.)  Accept messages for
forwarding when in the MISSING state, not just the ALLHERE state.
Store messages that can't be sent now, and send any that have
accumulated when a host reconnects.  When a cref loses its last
connection, keep it around unless it has no messages stored (as will
be the case when a game ends.)
2009-11-08 21:35:39 +00:00
ehouse
ed52582ea4 get rid of states and code for checking numbers of players -- since
any number is allowed now.
2009-11-03 05:03:20 +00:00
ehouse
3bdfda6548 Make it possible for multiple games to connect using the same room
name.  All new connections are stored together, and after each
connection an attempt is made to build one complete game with a host
and however many guests.  All remaining devices are moved into a new
pending record in the same state, and the completed game is treated as
always.  Seems to work, though nearly 20% of linux instances are
failing to connect the relay run from the new test script samename.sh.
Need to figure out why.

Also added logging of seed and connname to comms.c since games
launched together can no longer be certain to connect on the relay.
This allows the test script to identify joined games from their logs
and detect success or failure.

This checkin changes the relay protocol, so relay and clients will
both need to be upgraded.
2009-11-02 01:01:47 +00:00
ehouse
7a71c4636b change varible names; remove instance variable than can be on the stack. 2009-11-01 01:38:03 +00:00
ehouse
0e43675abf Address problems matching [re]connections to games: first, go back to
setting connName when all in a game are present.  Second, have every
host include in connections a random number.  That number is made part
of the connName and in general used to test whether a host belongs in
a particular game.  Add this "seed" to web interface.  Means new
versions for relay protocol and game stream format.  Latter is handled
correctly so older games can be opened.
2009-09-26 14:37:49 +00:00
ehouse
6603949b0e Fix bug where device quitting one game to start another with same
cookie winds up connecting to the old game -- by flagging a cref as
full and no longer accepting connections without connNames even when
in the MISSING state.  Required a protocol changes so that devices get
their connNames as early as possible.
2009-09-14 01:55:03 +00:00
ehouse
dbf9daf71b Fix problems reconnecting hosts where some but not all received the
ALLHERE message and connName: change relay protocol so cookie is
included in RECONNECT message, and hostIDs are not assigned until
ALLHERE, and change host-to-game matching to use connName first but
fall back to cookie.  This fixes nearly all cases failing to reconnect
after relay goes down.
2009-08-21 12:00:09 +00:00
ehouse
e96becb05f variable name change only (for clarity) 2009-08-13 12:59:55 +00:00
ehouse
8be31357ad track per-cref lifetime and display it via http 2009-07-28 05:41:15 +00:00
ehouse
8284799abe Fix crashes resulting from deleting cref instances in one thread while
another wanted to operate on them.  The root problem is that you can't
dispose of a mutex while somebody's blocking on it.  So now the
locking mutexes live inside the cref class.  When the lock owner
realizes the cref needs to die, it sets a flag and it's moved to a
recycled list.  A thread blocking on the mutex will then get it, but
checks the flag and releases it immediately if it's being recycled.
(Also improve the http interface a bit.)  With these changes I've run
31K (and counting) games against the relay without a crash or deadlock
(using sim_real.sh.)  The main problem that remains is that sometimes
two games using the same cookie wind up with two crefs (and so never
connect.)
2009-07-28 05:15:26 +00:00
ehouse
2ef16d44ca Include number of games played in html output; don't report closed
sockets found while reporting closed sockets (to avoid deadlock);
remove sockets from crefmgr's map when closing them so new connections
using same (re-used) socket aren't treated as belonging to open games.
2009-07-06 01:50:51 +00:00
ehouse
fbe95478ba rename now() as uptime(); drop NTHREADS to 1 for now; include time of
server boot in connName and keep counter in memory rather than a file.
2009-03-10 12:52:17 +00:00
ehouse
6b3265ac47 Change config class from having a method for every configurable value
to returing values for string keys so adding a new config doesn't mean
modifying that class.  Then add new config for addr passed to bind so
relay can be run to accept http connections from remote machines.
2009-03-02 01:50:14 +00:00
ehouse
9a8abb770d in web console list hosts present rather than just the count 2009-02-28 19:35:32 +00:00
ehouse
3bf116c936 Add an http interface (read-only web console). 2009-02-28 16:15:59 +00:00
ehouse
ea6fff8f28 replace int with bool where appropriate; fix to compile with newer g++ 2008-12-30 05:13:30 +00:00
ehouse
25c4368231 Start adding ability to listen on multiple sockets and to dynamically
change the set listened on.  There's still some debugging to do but
nothing that worked before is broken.  Also begin to accept unique
prefixes (e.g. g for get) for commands and attributes on the control
port.  Note that relay-related code in comms seems broken now, but is
without this checkin.
2007-12-01 15:00:30 +00:00
ehouse
92485783af update email address in header comments: no code change 2006-01-08 01:25:02 +00:00
ehouse
92981942b3 add _Shutdown(); override logf() to tag with cookieid; make logs less
verbose.
2005-10-30 05:20:31 +00:00
ehouse
74b6ccbd52 cleanup ctrl printing; repeat most recent command; cleanup internal names. 2005-10-16 01:19:25 +00:00
ehouse
e18f66f587 remove dead code 2005-10-06 02:54:05 +00:00
ehouse
4e5f69f4e8 rename states so can format to 80 cols; add log level param. No
change to functionality in this checkin.
2005-10-02 16:08:42 +00:00
ehouse
6835b6d1eb New scheme for accepting and limiting reconnections. Now device must
send player counts, local and expected.  Based on these the relay
accepts connections, declares the game full and ready for message
forwarding, and decides whether to accept a reconnect.
2005-10-02 15:39:38 +00:00
ehouse
77319b570d make transmitted vars smaller where possible; new relay identifying
scheme where cookie is used only to connect, and is replaced for
reconnects by a relay-generated name that's supposed to be unique
across all games on all relays and includes a hostname read in from
config file; relay assign non-servers' hostIDs.
2005-10-01 16:33:45 +00:00
ehouse
7d9a78f996 comment out internal mutexes: shouldn't be needed now that only one
thread at a time is given access to a cref instance.
2005-09-14 05:15:27 +00:00
ehouse
cf5906eacf Add and handle disconnect message so a device can reuse its socket for
a new game.
2005-09-05 15:50:49 +00:00
ehouse
4882c92a07 generate XWRELAY_OTHERCONNECT message 2005-09-03 18:35:34 +00:00
ehouse
e6e9646253 make all APIs private and add as friends the safe classes that will
access them.  This should allow reduction in the locking within cref
instances since only one thread at a time will be permitted inside by
SafeCref.
2005-09-03 15:59:48 +00:00
ehouse
a4033a44c3 when one device is disconnected for heartbeat, tell others it's going
away.
2005-09-03 15:41:17 +00:00
ehouse
9a2567252b cleanup: get rid of unused states/actions and code to handle them. 2005-09-03 07:15:05 +00:00
ehouse
c82fd2e4f2 Send disconnect events with error codes on heartbeat and connect timer
failures; change how state machine handles heartbeats: only put events
into the machine when there's a failure.
2005-09-03 06:55:08 +00:00
ehouse
2ba0f451a7 fix failure to record bytes forwarded 2005-09-02 07:18:39 +00:00
ehouse
8f32f4f99a loads of changes: get settings from config file; remove sockets and
kill crefs via state machine, and protect access to a cref so it can
die without another thread being in it; do timers via timeout to
poll() rather than interrupt (and integrate into state machine);
detect when all players are present and change state so new
connections on that cookie will get a new cref.
2005-09-02 06:56:34 +00:00
ehouse
91abdb3bcc fix bug where client connecting before server would result in attempt
to forward packet to host not yet available.  Drop such packets now.
2005-08-02 04:57:13 +00:00
ehouse
d639e9ca45 Honor cookieID passed in connect message, falling back to cookie only
when the ID isn't set, and using it rather than assigning a new one
even if the game can't be found.
2005-07-06 00:54:38 +00:00
ehouse
1ae6c010c9 Make cookieID a 32-bit value instead of 16-bit 2005-07-05 23:02:15 +00:00
ehouse
db6f6c258d move to using a formal table-driven state machine for each game (cref
object).  While it makes things more complex at this point, it should
make it easier in the long run to add error handling, timeouts, etc.
2005-07-05 22:05:37 +00:00
ehouse
3054637842 heartbeats: send to clients in connection response; note when
heartbeat and other messages arrive; and periodically reap sockets
that haven't been active in long enough.
2005-06-23 04:26:44 +00:00
ehouse
df17fe4f1e reorganize; support ctrl functions 2005-04-20 12:10:05 +00:00
ehouse
7a15f44c12 move creation inside class so can be controlled by same rwlock 2005-04-08 14:13:25 +00:00
ehouse
3fd6998c2a add mutexes; general improvements 2005-03-25 02:59:44 +00:00
ehouse
73104819bd first checked in. primative, but works. 2005-03-19 22:14:27 +00:00