Commit graph

64 commits

Author SHA1 Message Date
Eric House
720f78d18a get rid of ivars used only for http UI 2011-01-04 21:43:10 -08:00
Andy2
2c5c7a0dd1 init m_nRoomsFilled -- not sure when this http view feature broke 2010-11-15 20:08:59 -08:00
Andy2
c36679fe13 init isDead to false. Fixes prolem where if DB entry's missing the
value is uninitialized and so device gets warned that other device
resigned even if none did.
2010-11-15 18:21:40 -08:00
Andy2
edf0c40904 track isDead when creating SafeCref for devgone 2010-11-15 06:49:41 -08:00
Andy2
0787a06eb5 accept new message from device announcing the death of a game
(including seed so it's harder to spoof); respond to that by setting a
DEAD column in the db and flagging the device as gone.  Notify any
connected device of the fact.  Refuse to accept new connections to
that game.  As already-connected devices reconnect, allow them to do
so but send a new status message that their game is dead.  Not heavily
tested yet.
2010-11-11 06:40:50 -08:00
Andy2
89f967a016 pass remaining reconnect params in case connName's missing from db.
Should only matter if the relay's db's been deleted.
2010-10-04 18:39:26 -07:00
Andy2
9a035c66ff add assertion 2010-09-23 06:28:13 -07:00
Andy2
15cd3af62a just a comment 2010-09-20 05:35:29 -07:00
Andy2
a4913596db remove logging 2010-09-18 08:42:15 -07:00
Andy2
c5d113a8da remove _locked from name of method since it's not called when holding a lock. 2010-09-18 07:46:10 -07:00
Andy2
1490b2def9 simplify state table, getting rid of a bunch of states: we never leave
ALLCOND until it's time to kill the cref.  When one device connects
and leaves the cref is recycled, so when a new device joins and is
assigned the same game and a new cref is initialized the number of
players already registered must be set from the db entry; do that.
2010-09-16 18:59:56 -07:00
Andy2
2b702b48d6 need to clear CID of record in DB when killing corresponding in-memory
cref or reconnect will fail.
2010-09-16 04:47:17 -07:00
Andy2
06c8fdc67f stop tracking seeds separately until have a use for 'em separate from
HostRec.  This fixes failure to reconnect so that now a complete game
is possible (gtk version) without the two devices every being
connected at the same time.
2010-09-16 01:13:26 -07:00
Andy2
a870cac86d break connect and reconnect into separate paths to simplify. Be
consistent: nJoined in DB tracks players "ever seen and issued
connName" rather than "currently connected".  Next step: debug game
between two devices never connected at same time.
2010-09-15 14:05:51 -07:00
Eric House
54d268b718 pass through to database whether room is public 2010-09-14 21:20:11 -07:00
Andy2
f8c1c016cc remove special-case states and handling of first connect; track number
of players sought in the cref itself, adding in constructor, and not
in HostRec instances.  This is cleanup with no behavior change.
2010-09-13 13:49:13 -07:00
Andy2
ded6e22180 do finding of open games using database rather than cref list, which
requires updating the number of players when new devices join.  Drop
requirement that cid be unique.
2010-09-12 04:49:03 -07:00
Andy2
663551fcb5 improve db, adding uniqueness contraints. Pass in connName so can
meet that constraint.  Figure out next cid using a query at startup.
2010-09-12 03:57:23 -07:00
Eric House
c1da64b96a instantiate and use the new dbmgr class 2010-09-11 19:45:04 -07:00
Andy2
463e9c3ccf pass langCode in reconnect case too 2010-09-11 01:23:39 -07:00
Andy2
dc957e1a92 add match test on language code and number of players 2010-09-10 13:45:40 -07:00
Andy2
e60495ff93 read, pass, store and display langCode. Not yet used to route
connections to crefs.
2010-09-10 01:59:37 -07:00
Andy2
20312144dd tons of changes, still rough, snapshoted here: a gtk device vs device
game works to completion with both signing up as guests (no -s) with
one local and one remote player (identical commandlines.)  Not yet
tested: if any signs up as a host, reconnecting rather than
connecting, etc.  This is just a snapshot.
2010-09-10 01:30:40 -07:00
Eric House
89e7a506a4 reduce amount of logging 2010-09-08 20:28:14 -07:00
Andy2
416b379781 add second class of socket to be listened on, meant for per-device
rather than per-game connection, and when adding connected sockets to
active set track the type.
2010-08-12 06:42:33 -07:00
eehouse
8bb2fb9b09 track and display in web view the number of games actually joined
rather than the number attempted.
2010-05-28 02:31:27 +00:00
eehouse
3e83f50c84 use strcasecmp rather than strcmp on cookies (room names) to make
rooms case insensitive.
2010-05-01 02:49:19 +00:00
ehouse
a1be2fb8fc add ports relay is listening on to http display 2009-12-16 02:43:52 +00:00
ehouse
337c36dfd2 remove unused parameter 2009-12-04 07:59:07 +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
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
a9e8f5b493 shorten column headings; don't assign cid until game is full. 2009-09-17 03:42:12 +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
95a70862be Lock cref before calling method that assumes lock. 2009-08-30 15:18:40 +00:00
ehouse
b15665e041 serve http view from cached data and make cache refresh rate
configurable.  Should make it harder to attack the relay on http port.
2009-08-21 12:32:57 +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
acbf8180ef add missing lock(); track and display uptime of daemon child as well as parent 2009-07-31 12:56:04 +00:00
ehouse
2641ab6430 bug fix: mark after locking so will unlock in destructor 2009-07-30 12:39:45 +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
c5e73fd725 Add to http display number of games currently being hosted. 2009-07-13 03:01:22 +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
9b29e45ea4 plug valgrind-found leak; prefer localtime_r. 2009-06-29 12:58:30 +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
3bf116c936 Add an http interface (read-only web console). 2009-02-28 16:15:59 +00:00
ehouse
644dc3b5ad detect duplicate initial connect packets by checking what socket they're on. 2009-02-07 18:17:17 +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