Commit graph

63 commits

Author SHA1 Message Date
ehouse
7ac98bfcfb Don't require a timeout waiting for a game to connect initially, and
make no timeout the default.
2009-12-27 18:17:24 +00:00
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
b219e8b279 Send notification when device disconnnects without closing socket (in
addition to the existing one sent when a socket is closed).
2009-09-20 18:47:47 +00:00
ehouse
a9e8f5b493 shorten column headings; don't assign cid until game is full. 2009-09-17 03:42:12 +00:00
ehouse
18e9301e87 rename Cookie to Invite, a change that may change. Rename everywhere
in clients but not in relay where cookie is too pervasive.  (There are
no code changes in this checkin.)
2009-09-14 03:11:11 +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
f537169db5 Assign 0 not NULL to pthread variables. 2009-07-31 12:43:04 +00:00
ehouse
503db9cc6f up copyright 2009-07-30 12:54:17 +00:00
ehouse
4a5d74a0af rename state to take up less space in browser; add number of respawns
to status display.
2009-07-29 04:25:21 +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
4a308f4f8e Don't use unitialized variables (thanks valgrind :-) 2009-04-05 18:47:45 +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
1ac4ef3bc6 Attempt to detect connections that are duplicates by checking if that
socket is already in a connection.  This doesn't seem to always work,
and I may be leaking cref instances when it does, so needs debugging
still.
2009-02-01 16:00:20 +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
cb1222c0f9 Make cooperation in a heartbeat scheme a compile-time option. This is
meant to allow comms to take over heartbeats.
2007-11-18 23:38:56 +00:00
ehouse
767b9f2908 initialize mutex before using; fixes a hang since could never aquire
lock.  (This bug has always been there, but didn't matter before;
maybe pthreads changed.)  Comment out self-spawning stuff until can
fix df-transfer problems.  Other minor changes around logging.
2007-02-06 05:52:22 +00:00
ehouse
b29bde8e37 include stdio.h for freebsd 2006-03-21 04:05:33 +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
e2e66f8057 Set a disconn timer when somebody leaves to make it parallel with case
where somebody never shows up; print more info about cref state to
ctrl port.
2005-10-19 03:44:55 +00:00
ehouse
74b6ccbd52 cleanup ctrl printing; repeat most recent command; cleanup internal names. 2005-10-16 01:19:25 +00:00
ehouse
deea73ad8b cancel all-connected timer when all are connected 2005-10-15 16:35:18 +00:00
ehouse
ecf5875d7e capitalize public methods on timermgr (no code change) 2005-10-15 15:49:22 +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
87d1c8f593 event name change 2005-09-09 03:15:06 +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
ebcc30dd5f send notice when a socket closes. This seems to be resulting in dups. 2005-09-04 20:37:42 +00:00
ehouse
4882c92a07 generate XWRELAY_OTHERCONNECT message 2005-09-03 18:35:34 +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