Commit graph

66 commits

Author SHA1 Message Date
Eric House
9138cd15b7 fix problems with devices reconnecting when their ACKs didn't arrive
and their slots are empty or have been reassigned: basically we check
if a device goes where it expects, and if not treat it as a new
connection rather than a reconnect, meaning its hostid may change.
Existing device code seems ok with that -- and at any rate I don't
think ACKs get dropped much in the wild.
2013-06-26 00:38:34 -07:00
Eric House
950e754ca2 cleanup 2013-06-17 07:26:10 -07:00
Eric House
5e0fd89c9e update with all relay/ changes from gtk_multigame. This is what the
live relay's running anyway.
2013-02-04 06:08:39 -08:00
Eric House
c567647a8d get rid of mapping of socket->game_connection, which will not work
once UDP sockets and/or per-device (not per-game) connections come
along.  Lots of changes, most not involving code flow but a couple
that did.  So far two gtk games can connect and exchange moves.
Haven't tested reconnection or store-and-forward.
2013-01-12 16:09:24 -08:00
Eric House
f1ee77882b Send devid with RECONN as well as CONN so games present when device
upgrades can also use GCM.  Tested on relay but not device.
2012-11-09 06:54:12 -08:00
Eric House
3469975d2a add, still disabled by compile-time flags, code to transmit device ID
(e.g. ID Android devices get via GCM) to relay and to associate it
there with messages that need to be delivered.
2012-10-30 07:01:47 -07:00
Eric House
45de62818b format to 80 columns -- no code change. 2012-09-09 15:49:55 -07:00
Eric House
866aeb2387 change relay connect message format to include client version (meaning
of which is TBD).  When a new-version client connects, store the value
it's passed. At first this will let me track how quickly people
upgrade.  Later I can use it to let different clients have different
formats to their messages e.g. to proxy.
2012-01-26 05:43:54 -08:00
Eric House
caa40fa023 store most recent IP address each device has come in on. Requires new
column in db.  Not really used yet but interesting to watch....
2012-01-04 18:14:12 -08:00
Andy2
30145deba7 add new proxy message handler for no-conn message, and feed into
existing store-and-forward system.  With this checkin a robot-vs-robot
game plays for quite a few moves without either game every loaded into
the foreground (via a BoardActivity instance on Android), with all
moves transmitted as a result of relay checks.  One of the games
refuses to open later, however, and there are certainly other bugs.
And I'm not sure what happens when a message sent no-conn (without a
cookie ID) is received in the foreground.  But this is progress.
2011-08-16 19:41:33 -07:00
eehouse@eehouse.org
ba4d898de1 Merge branch 'android_invite' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_invite 2011-07-06 19:12:16 -07:00
Andy2
86e3cc7286 When device reconnects to a dead game, just deny the connection with a
new error message rather than allow it as if it were a normal game
only to send a game-dead message after.  This solves the problem of
how device knows not to put up welcoming message or suggestion to
invite to a game that's suddenly missing players.  BUT: this change is
incompatible with existing versions and so needs to get pushed out
before the in-use relay can be upgraded to include this code.
2011-07-06 06:47:25 -07:00
Eric House
a3dbde9b88 more dealing with edge cases. 2011-07-05 21:42:03 -07:00
Andy2
f3a4ff9dfc use cid for variables of type CookieID everywhere instead of almost
everywhere
2011-06-29 18:42:41 -07:00
Andy2
cdc16ee974 variable/method name change only: cookieid->cid 2011-06-25 15:43:52 -07:00
Andy2
6c121dac57 final set of changes -- all test cases now seem to be passing. Stop
duplicating set of sockets owned by a cref, moving it from cinfo into
cref and caching a copy outside when cref is unclaimed (after which no
change is possible until it's claimed again.)
2011-06-24 18:34:34 -07:00
Andy2
e886a1aefe lots more changes -- another snapshot, this, rather than stuff
carefully polished and reviewed.  Shows progress, though, in getting
through tests.
2011-06-23 07:12:50 -07:00
Andy2
3ebcc01e86 beginning -- this is a snapshot -- of rewrite of how relay keeps
multiple thread out of a single game.  Add new class that locks
per-cid and start using it.  Very incomplete.
2011-06-22 06:51:26 -07:00
Eric House
85d484a881 major mod to deal with devices that fail to receive ACK and then
reconnect.  I was putting both (i.e. the same device twice) in the
same game.  Now I detect this based on the seed being duplicated and
treat the device as having failed to ACK then proceed with the CONNECT
as if it were new.  Tested pretty heavily but only with two-device
games.
2011-06-20 18:13:15 -07:00
Eric House
720f78d18a get rid of ivars used only for http UI 2011-01-04 21:43:10 -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
Eric House
4ad735124c add logging and assertions. There's a race condition in cref
recycling and may be one in tpool socket checking-out.
2010-09-20 22:11:13 -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
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
821e4d9c39 add ACK to protocol, returned by device after gets connName on initial
connection.  Space is held for device on assumption ack will come
back, then given up if it fails.
2010-09-14 13:54:52 -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
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
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
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
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
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
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
e96becb05f variable name change only (for clarity) 2009-08-13 12:59:55 +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
503db9cc6f up copyright 2009-07-30 12:54:17 +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
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