Commit graph

116 commits

Author SHA1 Message Date
Andy2
928404be50 remove unused enum 2011-07-06 06:15:25 -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
38ad3aa81c cleanup; and: collapse HostRec and socket set into map of socket to
HostRec, protecting all accesses with ReadWrite locks.
2011-06-25 15:40:12 -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
63a4e6c953 get rid of per-cref mutex: it's redundant now that access is
synchronized.  Add method to check if new players are still welcome to
allow fix for race.
2011-06-23 18:57:48 -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
27346cf58b change AIP to remove several stored messages at a time. Will use
later to delete messages after proxy fetches and ACKs them so traffic
isn't repeated.
2011-03-31 18:15:03 -07:00
Eric House
720f78d18a get rid of ivars used only for http UI 2011-01-04 21:43:10 -08:00
Eric House
4bd5553596 track mtime per host rather than per game -- make it an array in the db. 2010-12-01 21:08:22 -08:00
Andy2
2c9f2572a8 use GameFull() 2010-11-15 06:48:57 -08:00
Andy2
43896ff187 remove unused method and variable 2010-11-12 18:25:15 -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
c7febf0d10 nuke unused constant 2010-11-03 18:30:05 -07:00
Andy2
0148a93f3e add a constraint to the stored messages table to avoid dupes. Then
remove the artificial limit on number of stored messages.  This seems
to fix problems where lots of chats in a row clog up the relay so that
messages never get flowing again.  Works more cleanly than
artificially ACKing.
2010-11-03 18:14:19 -07:00
Andy2
e909e4b343 remove redundant message; advance state to ALLCONNECTED on receipt of
RECONN or CONN that lists the game as full.  This means we get the
all-green icon (or the A in the gtk case) when in a consummated game
rather than only when all devices are actually connected.
2010-10-23 20:29:24 -07:00
Eric House
8a038dc748 Merge branch 'relay_proxy' of ssh://xwords.git.sf.net/gitroot/xwords/xwords into relay_proxy 2010-10-23 19:45:03 -07:00
Andy2
7cf4535b4c new dbmgr API returns number of players in game; use that rather than
currently connected devices to populate [RE]CONNECT message
2010-10-22 22:34:43 -07:00
Eric House
85d29cf560 if can't send allcond to a device because it's not connected queue the
message to be sent next time it does.  And since the cookieID will
change and should be there already anyway, remove it.  (Should remove
the hostID too for the same reason.)
2010-10-22 19:02:52 -07:00
Eric House
0d1542ca9d tweaks to logging 2010-10-12 05:18:44 -07:00
Eric House
86d73392d5 track bytes sent in db; use defaults to init ctime 2010-10-06 21:45:05 -07:00
Eric House
43bf3cd50f improve log statement 2010-10-04 20:01:00 -07: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
d35bc7d748 refuse to store more than four messages at a time for a single
connName/hid pair.  This works around a problem where a device,
continuing to connect and send all pending messages for another device
that is not connecting, winds up with hundreds of identical messages
stored.
2010-10-03 18:18:15 -07:00
Eric House
bc65377cfd track device seeds in db. 2010-09-28 18:06:50 -07:00
Andy2
40e1d29243 use new methods to store undeliverable messages in a db rather than in
memory.  Confirmed that devices can hookup without ever being
connected at the same time and that the messages survive a relay
reboot.  No further testing yet.
2010-09-23 06:32:57 -07:00
Andy2
85b4f3f075 move hostid assignment and tracking into db so it survives reboots and
recycling of crefs between when devices in a game connect.  This plus
movement of messages into the DB will re-enable games played without
the two devices ever being connected at the same time.
2010-09-23 05:33:27 -07:00
Eric House
047f41b516 send cookieid as part of [RE]CONNECT_RESPONSE in addition to ALL_COND (where it's now redundant). 2010-09-20 22:06:35 -07:00
Andy2
ac8891016f work on detecting duplicate packets and devices that have reconnected
on a different socket; print all present seeds for debugging.
2010-09-20 05:35:09 -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
50c387d75e remove players from db as well as runtime when ack times out 2010-09-16 06:49:35 -07:00
Andy2
25c1824c45 fix broken assertion and add missing state transitions to fix crashes. 2010-09-16 05:39:25 -07:00
Andy2
b25579b893 greatly simplify state machine for connections. Now (with DEVACK=20
on conf file) newrelay.sh will complete running 50 4-device gtk games.
Haven't tested reconnect case which I almost certianly broke.
2010-09-16 01:53:43 -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
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
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
d7d2a7523b kill cref when in bad state. 2010-07-29 19:46:52 -07:00
Eric House
b170a04dec drop duplicate [re]connect packets before they enter the state
machine.  Fixes problems where crefs get stuck in the
XWS_CHK_ALLHERE_2 state.  Still should probably kill a cref where
there's no state table entry.
2010-07-28 22:21:01 -07:00
Eric House
f70b9e1d10 use constructor to save some code; no behavior change 2010-07-28 20:17:54 -07:00
Eric House
ad1be65236 Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch 2010-07-27 20:47:42 -07:00
Eric House
b335151172 log when no event pushed while adding players -- this may be how state machine is getting screwed up 2010-07-27 20:47:04 -07:00
Andy2
f05bfcb3d8 log when dropping message that would mess up cref player counts 2010-07-16 06:23:20 -07:00
Eric House
a52fc5a4fd don't call removeSocket when none was added 2010-07-15 18:21:32 -07:00
Eric House
78f965b979 replace asserts that have been firing on integrating reconn events
with dropping the reconn messages; move log of state table lookup failure
into cref so cref id can be included
2010-07-14 21:32:19 -07:00