Eric House
a444786a28
reduce logging
2010-10-05 20:57:19 -07:00
Eric House
2e844d798f
replace single db connection protected by a mutex with one connection per thread kept in thread-local storage.
2010-10-04 20:04:14 -07:00
Eric House
d9ca6f5e11
block TERM and INT from all but the main thread. (Pretty much untested; doesn't fix hang-on-SIGINT.)
2010-10-04 20:03:19 -07:00
Eric House
1ff4d67bc0
block TERM and INT from all but the main thread. (Pretty much untested; doesn't fix hang-on-SIGINT.)
2010-10-04 20:03:00 -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
1f87379cd0
change default port
2010-09-29 07:37:26 -07:00
Eric House
1b93654f7e
use stored procedure sum_array instead of C macro
2010-09-29 06:21:08 -07:00
eehouse@eehouse.org
d0797af6e5
Merge branch 'relay_proxy' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into relay_proxy
2010-09-28 21:11:17 -07:00
Andy2
978fa010f1
commented-out sleep positioned to give download progress time to come up.
2010-09-28 18:35:33 -07:00
Eric House
bc65377cfd
track device seeds in db.
2010-09-28 18:06:50 -07:00
Andy2
1de029f3f0
skip public rooms if full. (Should do this in the query....)
2010-09-28 06:42:01 -07:00
Eric House
8f77886f72
make column name shorter
2010-09-24 20:18:20 -07:00
Andy2
f7bad05390
send msg count query and print results
2010-09-24 05:51:42 -07:00
Andy2
b0c6e6da9c
add db method to count messages for connName/hid pairs and handle
...
query using it.
2010-09-24 05:50:02 -07:00
Andy2
c3e1b243b6
add timestamp to msgs db and set it on adding new records. I will
...
likely need to add periodic culling on the server for games that will
never fetch their messages.
2010-09-24 05:46:30 -07:00
Andy2
c44324a32a
log, for now as I've seen assertions failures suggesting a race, the
...
set of checked-out sockets at insert and remove time.
2010-09-23 06:34:18 -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
74764a493b
create the new db
2010-09-23 06:31:42 -07:00
Andy2
eee41377f4
new methods for storing/retrieving messages in new db.
2010-09-23 06:31:29 -07:00
Andy2
9a035c66ff
add assertion
2010-09-23 06:28:13 -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
Andy2
1d0c207521
add test command for proxy feature to fetch for connNames whether
...
there are messages pending for them. Not handled yet on relay.
2010-09-21 18:28:31 -07:00
Andy2
e06baf566f
get public rooms from the db rather than stubbing it out.
2010-09-21 06:54:47 -07:00
Andy2
be23e06b60
use read_packet to replace duplicate code
2010-09-21 06:38:43 -07:00
Andy2
e7b5923883
finish first pass at sending open public room names -- but with actual
...
list harvesting stubbed out.
2010-09-21 06:27:31 -07:00
Andy2
2ec67c8ed1
finish rq to work with current format; add to makefile
2010-09-21 06:26:49 -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
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
a549ade1fa
a bit more work on rc
2010-09-20 18:31:17 -07:00
Andy2
15cd3af62a
just a comment
2010-09-20 05:35:29 -07:00
Andy2
e1c99f53cd
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:19 -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
430b033ae0
a bit of progress on cmdline tool
2010-09-20 04:59:09 -07:00
Andy2
df1ec1628a
replace killSocket(), which jumped right into crefmgr and could get
...
ahead of processing data arrived on the same socket, with EnqueueKill
that adds to same queue from which data's taken. So if device dies
immediately after sending data there won't be a race between closing
the cref (if this is the last open socket) and handling the data. I'm
still dying with assert fails when running 100 games at once, but much
less frequently
2010-09-18 08:47:56 -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
53b3d7c32f
enque sockets in new object that contains type so later other events
...
(e.g. socket closes) can also be queued; track what sockets are
currently being handled so no two threads are ever processing events
on same socket. This makes running 'NGAMES=50
./scripts/discon_ok2.sh' crash very infrequently rather than every
time, but the race condition in crefmgr remains. Queuing socket
closes should help.
2010-09-18 07:44:14 -07:00
Andy2
9c8889b429
get rid of mutex guarding reconnect. There shouldn't be any need
...
since game slots are already assigned, and it's slowing down
reconnects in their race with kills.
2010-09-18 05:07:23 -07:00
Eric House
bb1e46fa81
Merge branch 'relay_proxy' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into relay_proxy
2010-09-16 20:13:54 -07:00
Eric House
d0e707a48e
get started with test/cmdline app to query relay's new proxy interface.
2010-09-16 20:13:24 -07:00
Andy2
c5eef29bcc
some suspicious crashes and subsequent reading say that multiple
...
threads can't share the same db connection. So synchronize all
queries. Multiple threads *can* access the db concurrently as long as
each has its own connection, so I could add connections to the tpool
threads. But this will probably be performant enough for the first
10K simultaneous users. :-)
2010-09-16 20:08:32 -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
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
d1a9c3962a
rename cookie->room in db; reposition columns.
2010-09-16 03:30:24 -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
8961910263
field name change
2010-09-15 14:03:59 -07:00
Eric House
b8a431cf01
fix bug in sql statement
2010-09-14 21:28:18 -07:00
Eric House
54d268b718
pass through to database whether room is public
2010-09-14 21:20:11 -07:00
Eric House
e3053370d0
add cmd to build the database and main table
2010-09-14 21:18:04 -07:00
Eric House
ddcc338ed7
don't break out of loop without unlocking mutex
2010-09-14 21:16:16 -07:00
Eric House
56a920740a
remove unused funtion declaraion
2010-09-14 21:15:24 -07:00
Andy2
3b5b5f0241
factor dbmgr code; add and call method to zero CIDs on boot.
2010-09-15 01:14:28 -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
100ed8532f
timestamp records on creation
2010-09-12 05:04:52 -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
Eric House
87de53cf96
add new class to interface with postgres database in an experiment to
...
simplify things by using a db to survive a crash/reboot. So far (with
next checkin) manages to update a db. Next need to do queries instead
of searches through in-memory data.
2010-09-11 19:44:37 -07:00
Andy2
54d49d450a
add back state and table entries to get rid of an unused cref.
2010-09-11 01:40:40 -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
Andy2
f7c5ff619d
turn off heartbeats
2010-09-10 01:24:03 -07:00
Eric House
89e7a506a4
reduce amount of logging
2010-09-08 20:28:14 -07:00
Eric House
90d505abea
call accept() in main thread rather than in thread proc to fix
...
long-standing bug where main thread kept finding socket to be readable
and forking new threads to call accept() on it and then block forever.
2010-09-08 20:24:36 -07:00
Andy2
33d60452a3
fork a thread to handle proxy connects. Later may want to use thread
...
pool as for game threads.
2010-08-23 18:52:52 -07:00
Andy2
a34ccb424f
device now passes list of "relayID"s, consisting of connName plus
...
device id, to relay, one for each stored game that's communicating via
the relay. Relay parses out each relayID. Next relay can use these
to look up whether messages are available and reply with that, and
device can put up a notification.
2010-08-22 12:16:57 -07:00
Andy2
56b6a425e2
proxy now writes one byte to relay and reads one byte reply.
2010-08-19 18:34:28 -07:00
Andy2
019da83d60
meant to check this in
2010-08-12 06:42:59 -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@eehouse.org
3b7abc2a31
Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch
2010-07-29 21:13:00 -07:00
Eric House
e857b01783
ignore logs and core files
2010-07-29 21:07:20 -07:00
Eric House
d7a3795355
add static decl
2010-07-29 21:04:33 -07:00
Eric House
d7d2a7523b
kill cref when in bad state.
2010-07-29 19:46:52 -07:00
eehouse@eehouse.org
13ecb2f929
Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch
2010-07-29 05:41:48 -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
eehouse@eehouse.org
958ec15a19
Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch
2010-07-27 21:32:17 -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
51ffdce185
comment out pthread_create failure log; seeing it too often and it's
...
just for the web view.
2010-07-26 18:37:44 -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
8e5abb189b
add mutex for reconns too; log socket and ip addr connecting on it
2010-07-15 18:14:44 -07:00
Eric House
5ea1f3b470
list newest crefs first
2010-07-15 18:13:01 -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
eehouse@eehouse.org
f9d8df8cea
don't track xwrelay.conf so local changes don't show as local mods
2010-07-14 06:29:50 -07:00
Andy2
41f8f574b1
use git describe for version info/stamp
2010-07-07 20:26:25 -07:00
Andy2
5365ea4f4e
fix crash when empty string given on ctrl port
2010-07-07 18:59:48 -07:00
Eric House
6456165a92
replace svnversion with gitversion.sh
2010-06-05 07:27:14 -07:00
Eric House
8aaaa06bcb
identify rev number as from git
2010-06-05 07:25:24 -07:00
ehouse
43181f5cd2
accept multiple cref ids and names on console
2010-06-03 03:00:35 +00: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
c92d919934
log error from read
2010-05-26 02:25:58 +00:00
eehouse
7a279702c0
add sterrror to what's logged when pthread_create fails -- as is
...
happening often.
2010-05-20 04:28:07 +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
eehouse
4ed87fecb4
add once-per-day date line to logs since they can span weeks now.
2010-05-01 02:48:47 +00:00
eehouse
f4b64fe97d
add option, off by default, to stall each message forward by some time
...
to better simulate network conditions when testing against local relay.
2010-03-28 16:09:07 +00:00
eehouse
e5f3384050
another .gitignore
2010-02-24 04:30:21 +00:00
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
a1be2fb8fc
add ports relay is listening on to http display
2009-12-16 02:43:52 +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
015b0d42d8
include title in head with summary readable in tab
2009-12-08 14:51:03 +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
337c36dfd2
remove unused parameter
2009-12-04 07:59:07 +00:00
ehouse
7ad59e3e2b
cleanup
2009-12-04 07:54:14 +00:00
ehouse
55478369e4
listen on only one port by default
2009-11-22 16:29:23 +00:00
ehouse
c1827562dc
be consistent is use of variable vs real name
2009-11-10 14:37:42 +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
393cccb86c
Add MSGONLY state to indicate cref being kept alive only to preserve
...
messages for a latter connection.
2009-11-09 05:29:06 +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
2d4ae3e44a
When forwarding message, lookup cref by socket if cookieID == 0, as
...
can be the case when through to a non-all-connected game.
2009-11-08 21:32:36 +00:00
ehouse
8e0dad43c7
get rid of overlogged message
2009-11-08 21:25:43 +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
11b586cd4b
lookup hearbeat recipient by socket rather then cookieID since
...
cookieID isn't always correct until later
2009-11-02 00:45:54 +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
030ae52a4b
Store start time as time_t rather than string.
2009-09-26 14:05:51 +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
ffacbcb36a
Move "For" column left.
2009-09-19 04:59:19 +00:00
ehouse
45bdccd4e8
Format time more compactly
2009-09-18 03:50:01 +00:00
ehouse
a9e8f5b493
shorten column headings; don't assign cid until game is full.
2009-09-17 03:42:12 +00:00
ehouse
d5d20293ce
print log timestamps with padding 0s for better sorting
2009-09-15 12:54:40 +00:00
ehouse
135048a3cf
Extend name change to relay's web interface
2009-09-14 03:31:54 +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
7eeede45c3
exit if unable to open socket
2009-09-13 15:27:19 +00:00
ehouse
7ca629a2f5
don't log socket closing as an error
2009-09-04 11:02:09 +00:00
ehouse
95a70862be
Lock cref before calling method that assumes lock.
2009-08-30 15:18:40 +00:00
ehouse
2a569df97f
For privacy, don't show host IP unless connection is local.
2009-08-30 15:16:06 +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
493d3c226f
log when crash
2009-08-20 12:12:43 +00:00
ehouse
53133839a4
don't log list of sockets by default
2009-08-20 03:50:40 +00:00
ehouse
e96becb05f
variable name change only (for clarity)
2009-08-13 12:59:55 +00:00
ehouse
47d6d53419
make log file location configurable; remember start time as used for
...
permenent IDs on spawn rather than overall boot to avoid duplicating
cids.
2009-07-31 13:02:05 +00:00
ehouse
7077a11af6
pass .css file
2009-07-31 12:58:47 +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
80ccdd6d04
spelling...
2009-07-31 12:47:58 +00:00
ehouse
f537169db5
Assign 0 not NULL to pthread variables.
2009-07-31 12:43:04 +00:00
ehouse
bcc887c0b1
Need to remove before inserting. Todo: is there a replace?
2009-07-31 12:39:47 +00:00