Commit graph

793 commits

Author SHA1 Message Date
Eric House
5dadbfdad3 drop messages without enough delivery info 2013-06-22 06:01:42 -07:00
Eric House
acd7c8519f give timers ids so can be tracked in logs 2013-06-22 05:56:27 -07:00
Eric House
07d6851a26 logging changes for debugging -- main not belong in main branch 2013-06-22 05:55:38 -07:00
Eric House
c1cc11866f tweak logging 2013-06-22 05:54:32 -07:00
Eric House
25bf0e7191 assertion: should never have two recs for same socket 2013-06-22 05:53:54 -07:00
Eric House
5d20ef872e cleanup 2013-06-22 05:53:32 -07:00
Eric House
6027c94a43 don't pass uninitialized variables to logf 2013-06-21 07:26:11 -07:00
Eric House
b1ef09625e pair delete[] with new[] 2013-06-21 07:25:41 -07:00
Eric House
c587848349 cleanup 2013-06-21 06:59:44 -07:00
Eric House
8b8d22a7ba fix compile error: move function back to being inline since header
can't be readily included from .h file
2013-06-21 06:14:10 -07:00
Eric House
2a35fac1e8 rather than invalidating socket in AddrRec when it's closed, add a
timestamp set when it's opened.  Older copies with the same socket can
be tested against the cannonical copy maintained by tpool and sending
avoided when the timestamp shows the endpoint has likely changed.
Change tpool's list of sockets to a map for faster lookup, and get rid
of similar structure in udpqueue.
2013-06-21 06:05:26 -07:00
Eric House
11d299606e test for socket == -1 (invalidated) before sending 2013-06-20 07:10:09 -07:00
Eric House
46bd4d0047 inval tcp sockets in return addresses of packets waiting processing
when they're closed to prevent attempting to write replies to the
wrong device should the socket be reopened.
2013-06-20 07:07:56 -07:00
Eric House
985f7bfea0 tweak: don't restart whole loop on unlikely random result 2013-06-19 07:27:34 -07:00
Eric House
ecef687471 drop message, rather than asserting, if device id isn't in db. 2013-06-17 07:52:58 -07:00
Eric House
3e9dfb9a9d allow a thread to get a cidlock it already has. 2013-06-17 07:26:54 -07:00
Eric House
950e754ca2 cleanup 2013-06-17 07:26:10 -07:00
Eric House
a546c025d5 Rather than queuing sockets needing reading, read them immediately and
queue the packets for processing.  Add ids so they can be tracked in
the logs.  In addition to making tcp and udp packet processing more
similar this fixes the case where a read is delayed until after the
client has closed the connection (and so returns an error.)
2013-06-17 07:25:25 -07:00
Eric House
1928554444 add asserts and clarifying comments 2013-06-17 06:54:38 -07:00
Eric House
7ce939f5c0 pass rather than hard-coding column name 2013-06-17 06:48:22 -07:00
Eric House
e89fd3e8cc fix names to make units clear -- no code change 2013-06-10 06:38:42 -07:00
Eric House
e6488ff8c1 save space by shortening column names 2013-06-07 20:54:57 -07:00
Eric House
bf767577e3 msg64 will not always be set! Don't delete in that case. 2013-06-07 20:54:16 -07:00
Eric House
8b888b8d96 fix compile errors due to stricter compiler post debian upgrade 2013-05-29 06:36:54 -07:00
Eric House
eccd31472f fix crash when udp not in use 2013-05-27 16:17:58 -07:00
Eric House
31c443e4b1 Merge branch 'android_branch' into gtk_multigame
Conflicts:
	xwords4/android/XWords4/src/org/eehouse/android/xw4/GCMIntentService.java
	xwords4/android/XWords4/src/org/eehouse/android/xw4/RelayService.java
2013-05-22 07:01:08 -07:00
Eric House
78b3a91925 format: send array of message bodies rather than just one 2013-05-22 06:40:02 -07:00
Eric House
11709b21bd remove redundant parameters 2013-05-22 05:51:33 -07:00
Eric House
7d81083d7d send using old message format to old clients, new to new 2013-05-22 05:39:20 -07:00
Eric House
9b5607d829 send message along with GCM notification that ... there's a message.
Should eventually allow GCM-aware clients to skip connecting on
launch, and for now to make them a tiny bit snappier.
2013-05-21 19:35:34 -07:00
Eric House
9e67dda5a9 make use of base-64 encoding runtime-configurable 2013-05-09 22:16:48 -07:00
Eric House
f9f7874a55 make use of base-64 encoding runtime-configurable 2013-05-09 21:53:54 -07:00
Eric House
d74814a806 part of previous (merge) commit that got left out -- files not saved. 2013-05-09 06:33:19 -07:00
Eric House
7d8cddb31f Merge branch 'android_branch' into gtk_multigame
Conflicts:
	xwords4/linux/gtkmain.c
	xwords4/linux/linuxmain.c
	xwords4/relay/xwrelay.cpp
2013-05-08 07:37:55 -07:00
Eric House
eafac8724e don't stop processing message referring to multiple games as soon as
one of them can't be found.
2013-02-08 20:58:09 -08:00
Eric House
6a1b86380e add missing files from gtk_multigame branch -- to fix broken compile 2013-02-04 21:33:35 -08: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
2cfa56c2d8 update to not require incomplete gcm module 2013-01-29 18:34:33 -08:00
Eric House
9ee16adc3a add support for udp-based delete and anonymous (relay-provided) regIDs 2013-01-29 07:38:07 -08:00
Eric House
4aee75aeab ack all packets from clients; log acks. This is for debugging and may
not need to stay.
2013-01-27 21:26:27 -08:00
Eric House
302ac9d55c script to list who's attached to the db 2013-01-27 08:30:02 -08:00
Eric House
82dc986c79 remove bad asserts and unused variable 2013-01-26 21:49:17 -08:00
Eric House
cc69901632 reset to null in loop in case exit due to exceeding retry count 2013-01-26 21:17:46 -08:00
Eric House
a9b459ea2e log rather than assert 2013-01-26 21:16:48 -08:00
Eric House
06bc80fcc9 let's make 1 the default number of threads 2013-01-26 20:59:27 -08:00
Eric House
cba04e4b95 Merge branch 'android_branch' into gtk_multigame
Conflicts:
	xwords4/relay/xwrelay.cpp
2013-01-26 20:20:54 -08:00
Eric House
2fdcea54f5 fix logging of sockets 2013-01-26 18:55:55 -08:00
Eric House
7ecf57c556 increase size of buffer for incoming proxy packets, since now that I
have 50+ saved network games requests for moves are that big.  (This
is a temporary fix.)
2013-01-26 18:48:57 -08:00
Eric House
336e3cd289 handle all three types of message in a single thread, punting all
synchronization issues to a future point where the load demands it.
2013-01-26 11:54:48 -08:00
Eric House
9e1d09648d fix log statement 2013-01-26 11:04:20 -08:00
Eric House
8cb0a8a7a7 fix crash on startup (as done already on gtk branch) 2013-01-26 09:23:44 -08:00
Eric House
7ee402d2ae move callback into queueelem so same queue can service udp and tcp (eventually) 2013-01-25 07:19:44 -08:00
Eric House
23b7e5a2eb fix syntax error in query 2013-01-24 21:11:15 -08:00
Eric House
af58e7c4e1 comment 2013-01-24 20:27:56 -08:00
Eric House
084643ca82 don't include dead-game messages when fetching for devices 2013-01-24 20:27:36 -08:00
Eric House
7253cfa313 assert that map.insert() is actually doing something in those cases
where I expect it to.
2013-01-24 19:34:20 -08:00
Eric House
036c908b72 remove token from XWPDEV_HAVEMSGS message 2013-01-24 19:33:33 -08:00
Eric House
5f2d628855 update protocol description 2013-01-24 19:33:02 -08:00
Eric House
55c117c9fc fix assert by nulling out variable 2013-01-24 19:25:32 -08:00
Eric House
481e50aaae don't bother pushing do-we-ack decision out of static method 2013-01-24 19:23:05 -08:00
Eric House
c465a0bb0c add loop to print when packets haven't been ack'd 2013-01-24 07:43:24 -08:00
Eric House
ce7cdab3f0 add msgid and acking to protocol -- maybe for debugging only. 2013-01-23 07:40:52 -08:00
Eric House
ff70e3fbc2 fix use of map.insert: check for existing key and overwrite value 2013-01-23 07:35:20 -08:00
Eric House
2d7977e4b5 fix test: unset TEXT column returns as "", not NULL. 2013-01-22 06:52:50 -08:00
Eric House
29acab1ef2 tweak display 2013-01-21 19:44:08 -08:00
Eric House
90b8f966f6 comment out unnecessary assert 2013-01-21 19:40:56 -08:00
Eric House
2744e8698c optionally (compile-time change for now) store message data as
b64-encoded TEXT instead of BYTEA, which on my laptop is getting
corrupted sometimes.
2013-01-21 19:40:20 -08:00
Eric House
d374d0f3d8 optionally (compile-time change for now) store message data as
b64-encoded TEXT instead of BYTEA, which on my laptop is getting
corrupted sometimes.
2013-01-21 19:39:57 -08:00
Eric House
991cc8f04c fail in main mode if udp socket not set 2013-01-20 21:03:43 -08:00
Eric House
21570ec9b4 Merge remote-tracking branch 'origin/android_branch' into gtk_multigame 2013-01-20 19:27:25 -08:00
Eric House
016b16a8b2 change relay alert message format to length-plus-string rather than
null-terminated for easier handling on the java end.
2013-01-20 13:06:34 -08:00
Eric House
9023440a88 reply with alert to any connection attempt when in maint mode 2013-01-20 10:03:20 -08:00
Eric House
b768d8fccc fall through to using hard-coded maxsocks value 2013-01-20 09:22:35 -08:00
Eric House
3313c776ab fix unregister sql error 2013-01-19 22:37:12 -08:00
Eric House
65e9789c3f add mainentance mode, triggered by a commandline flag, that does
nothing but loop waiting for connections on the UDP socket and sending
them back the error message provided on the commandline.
2013-01-19 15:17:51 -08:00
Eric House
63d3f70cdf more changes to storage and fetching of messages and to protocol so
presence of messages is reported on connect (as are bad relayIDs).
Now a game with a robot player in a "closed" game can continue.  Once
the next set of linux-side chances is committed.
2013-01-19 14:34:04 -08:00
Eric House
99307e45a0 queue incoming packets and process them in order in a separate thread 2013-01-18 19:56:21 -08:00
Eric House
c999bbae92 always test those last-minute pre-checkin cleanups 2013-01-18 07:22:56 -08:00
Eric House
3984d85795 oops -- prev checkin didn't compile 2013-01-18 07:12:26 -08:00
Eric House
1c5fef6a38 relay improvements for UDP connection: record addresses, prepare to
run in separate thread, etc.
2013-01-18 07:10:47 -08:00
Eric House
932778f700 stubbed-out thread manager for udp connection 2013-01-18 06:57:57 -08:00
Eric House
7fec736947 add udp socket and protocol for use over it so that a device can
manage a single connection to the relay for all of its games.  Works
so far to the extent that the game's playable with all boards on the
same device (with checkins about to come) as long as all boards are
open.  (Client doesn't handle opening closed games yet.)
2013-01-15 18:41:17 -08:00
Eric House
5a51af489a Merge branch 'android_branch' into gtk_multigame 2013-01-13 10:41:14 -08:00
Eric House
dc0cfdf001 bug in recent changes: need to mark socket unused to avoid double removal 2013-01-13 10:37:47 -08:00
Eric House
98679c8363 cleanup: better encapsulation for AddrInfo 2013-01-13 10:14:06 -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
33735ae7a5 Merge branch 'android_branch' into gtk_multigame 2013-01-11 20:48:44 -08:00
Eric House
b46df07237 Merge remote branch 'origin/android_branch' into android_branch 2013-01-11 20:48:04 -08:00
Eric House
6dcd7022d4 don't pass .css file in; it's ignored 2013-01-11 20:42:57 -08:00
Eric House
55514719be include thread ptr in hung threads logging; assert (restart) when hung for too long 2013-01-11 20:42:04 -08:00
Eric House
39d12d088a use usleep when waiting for cref to be available 2013-01-11 20:37:08 -08:00
Eric House
aed2b6135c Merge branch 'android_branch' into gtk_multigame 2013-01-10 21:10:48 -08:00
Eric House
2ccc297463 make number of sockets at which we assert/reboot configurable so tests
can be done with large numbers of clients.
2013-01-10 21:10:18 -08:00
Eric House
7437a71aa6 use string_printf 2013-01-09 06:29:12 -08:00
Eric House
f827bebf80 ignore .pyc file 2013-01-02 21:13:36 -08:00
Eric House
ad78129e74 changes made over the past couple of months toward tracking an
apparent thread leak.
2013-01-02 21:12:42 -08:00
Eric House
d34ac1f86d rewrite to work without gcm library (whose lack of support for some
documented params makes it impossible to try using them)
2013-01-02 21:08:10 -08:00
Eric House
e920fbcaff unregister (flag in db) devids google says are unregistered 2012-12-01 11:55:16 -08:00
Eric House
2859ec9132 stime is the name of the column in actual use 2012-12-01 10:31:55 -08:00
Eric House
618d8530f2 some changes accumulated as script was running 2012-12-01 10:27:02 -08:00
Eric House
4dddd2da42 some changes accumulated as script was running 2012-12-01 10:26:00 -08:00
Eric House
e16245d19e include new column 2012-12-01 09:33:38 -08:00
Eric House
694857dd4e add, but disable with compile flags, ability to mark sent messages
with a timestamp rather than delete them.  Plan is to experiement with
this as a way of keeping devices from sending too many identical
messages when GCM's in use -- since constraints on the msgs table will
not allow identical messages to be added.
2012-11-15 06:25:22 -08:00
Eric House
c847ec127e add and use function that does formatted printing to a std::string so
query buffers can no longer overflow.
2012-11-15 06:15:44 -08:00
Eric House
c4f5b4522e minor printing tweaks 2012-11-13 07:17:56 -08:00
Eric House
6a85661095 lots of improvements: make useful for testing with non-android clients; shelve backoff data, etc. 2012-11-10 19:31:22 -08:00
Eric House
1316ae4b67 Fix relay devid protocol to deal with case where client submits a
ID_TYPE_RELAY id that's not in the devices table (as has happened when
a device switches relay URLs during testing, but might also happen if
I have to delete an entry from the devices table.)  In that case,
return ID_TYPE_NONE to the client, which will be its clue to delete
its ID_TYPE_RELAY id and submit the platform-specific id again.

Note: android won't compile this revision thanks to util.h change
2012-11-10 15:05:44 -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
2df4199a77 test script for messaging devices 2012-11-08 06:13:01 -08:00
Eric House
af89047969 treat an empty devID string as TYPE_NONE regardless of what the client claims. 2012-11-07 22:03:58 -08:00
Eric House
e6cd2265df fix crash: make formatParams work with empty strings 2012-11-07 21:57:18 -08:00
Eric House
83754d626e add backoff for resending for messages still not removed from msgs table 2012-11-07 08:05:45 -08:00
Eric House
45d0b2dbc8 various improvements, including printing a period on every loop when
there's no work to do.  All that remains is backoff.
2012-11-07 07:31:52 -08:00
Eric House
8516dca1cb what I really meant to check in 2012-11-07 06:23:20 -08:00
Eric House
9b48523ff3 fix to work with new DB scheme and to send json client now expects 2012-11-07 06:17:33 -08:00
Eric House
2c339ed7a5 fix to work with new devid/table scheme 2012-11-06 07:25:38 -08:00
Eric House
9ad28908bb assert enum within range 2012-11-06 07:07:14 -08:00
Eric House
03108f311a Merge branch 'android_branch' into android_gcm 2012-11-05 06:14:21 -08:00
Eric House
59937b8514 modify how devids are handled on the relay and the protocol through
which they're communicated to the device.  Device is expected to have
a platform-specific notion of ID which the relay stores in a new
devices table and indexes with a 32-bit number which is returned to
the device -- which is encouraged but not required to use it in lieu
of the longer ID in future communications.  Modify linux client and
test script to use the relay-supplied id.  Some of this is commented
out for now.
2012-11-03 10:58:01 -07:00
Eric House
fe819982da Merge remote-tracking branch 'origin/android_branch' into android_gcm 2012-10-31 07:44:16 -07:00
Eric House
3d6a170921 python script to check relay and invoke GCM to notify recipients 2012-10-31 07:20:40 -07:00
Eric House
d97c057b8c Merge branch 'android_branch' into android_gcm 2012-10-31 06:33:54 -07:00
Eric House
1cae4e9a4c increase buffer size, and test rather than assert for overflow. Fixes
crash with new large GCM devids.
2012-10-31 06:12:24 -07:00
Eric House
6014e3d76f turn on devid code and implement support in java. Untested, but should work. 2012-10-30 07:57:17 -07: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
37c698f41b fix link problem with upgrade from natty to oneiric (Ubuntu): -lpq
param must follow object file list.
2012-10-19 17:54:18 -07:00
Eric House
0f9500cea3 comment out unused param/variable 2012-10-19 17:53:15 -07:00
Eric House
72b4b02c20 improve messages display 2012-09-11 20:44:07 -07:00
Eric House
a0b564c7e8 show related messages as well 2012-09-11 19:07:16 -07:00
Eric House
45de62818b format to 80 columns -- no code change. 2012-09-09 15:49:55 -07:00
Eric House
240d308d07 move nperdevice and ntotal side-by-side 2012-05-28 11:08:43 -07:00
Eric House
49b04257d3 tweak date format 2012-03-01 18:16:04 -08:00
Eric House
840385b3ad print dates in shorter format so columns don't wrap as frequently 2012-02-27 18:28:04 -08:00
Eric House
e7a5882ed9 add a state transition lack of which fired an assert -- and that's
rare but consistent with others.
2012-02-15 18:17:26 -08:00
Eric House
bf5b6ada77 include public-room column 2012-02-07 18:59:17 -08:00
Eric House
edaef7f0a4 add new column 2012-01-26 23:02:56 -08:00
Eric House
adf49dffd7 init/take down thread local storage in constructor/destructor rather
than as static initializer (and then leaking on shutdown.)
2012-01-26 05:48:10 -08: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
960dfc7825 draw alternating game lines in alternating colors 2012-01-16 12:13:35 -08:00
Eric House
edd1dd95dd Merge remote branch 'origin/android_branch' into android_branch 2012-01-13 07:54:40 -08:00
Eric House
546ec8a3f4 get non-printing column out of cols array to be treated separately. 2012-01-13 07:54:11 -08:00
Eric House
2902b38405 Merge remote-tracking branch 'origin/android_branch' into android_branch
Conflicts:
	xwords4/relay/scripts/showgames.php
2012-01-13 07:50:53 -08:00
Eric House
ca49078730 improve to print each game as multiple rows, one per device. 2012-01-12 19:17:38 -08:00
Eric House
8c52836f9d php file to display state of relay's DB. This is the first and rough cut. 2012-01-12 06:30:30 -08:00
Eric House
7de8a90df3 silence compiler warning. 2012-01-11 18:29:14 -08:00
Eric House
37b333001b outline of php script to print contents of games DB 2012-01-05 20:25:34 -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
Eric House
03e6db5107 remove logging 2012-01-03 18:27:25 -08:00
Eric House
cb04eb8840 finally got the socket leak: use keepalive ioctl to detect sockets
whose other ends have gone down without closing properly.
2011-12-21 18:18:30 -08:00
Eric House
166d8f8c03 log number of sockets tracked -- it's climbing on server and I need to
figure out why.  This and listening for POLLRDHUP are a start (but not
sufficient).
2011-12-15 18:41:07 -08:00
eehouse@eehouse.org
b2a3c444f3 Merge branch 'android_branch' into send_in_background 2011-12-07 19:09:36 -08:00
Andy2
0d4e839dba log an error and drop bad fwd packet rather than assert 2011-12-07 18:43:13 -08:00
Eric House
6cc3770cd1 script to trace history of one game in db by polling db and listing
changes
2011-12-07 18:37:28 -08:00
Andy2
17edc79aaf Merge branch 'android_branch' into send_in_background
Conflicts:
	xwords4/android/XWords4/src/org/eehouse/android/xw4/XWApp.java
2011-12-06 19:56:10 -08:00
Eric House
7015ae500b exit after showing usage 2011-12-06 18:50:04 -08:00
Eric House
dc42e63974 fix read_packet() logging 2011-12-02 18:55:47 -08:00
Eric House
b706486b6e get rid of stringstream: it's either buggy or I'm using it
incorrectly, but regardless postgres doesn't like random chars
terminating queries.
2011-12-02 18:32:37 -08:00
Eric House
3f5e62c9b7 remove logging 2011-12-02 18:31:05 -08:00
Eric House
c1e420f726 Merge branch 'android_branch' into send_in_background
Conflicts:
	xwords4/relay/rq.c
2011-11-29 06:45:32 -08:00
Eric House
ba5ff6cb5d fix too-small buffer. Seems I've done this before. 2011-11-28 20:35:34 -08:00
Eric House
e5a943eecb tweak output 2011-11-28 18:15:09 -08:00
Eric House
f20f9d6503 complain if conf file not found (rather than leaving relay to crash
with an assert whose cause may not be obvious)
2011-11-28 18:14:39 -08:00
Eric House
72a3ed1891 increase buffer size: longer relay name caused stack overwrite
failures.
2011-11-21 17:33:44 -08:00
Eric House
cd699ba547 close socket when done 2011-11-17 19:56:54 -08:00
Andy2
da5da3dd89 wait for connection rather than asserting immediate success so can be
started before server.
2011-10-07 18:50:37 -07:00
Andy2
28e5c39845 get rid of stringstream where it wasn't working (maybe because of user
error -- whatever); fix error check to avoid false conclusion that
query didn't work so that update of num bytes sent in background works.
2011-09-30 18:20:28 -07:00
Andy2
d9e97d2f32 reduce logging 2011-09-30 18:10:22 -07:00
Andy2
6553546642 cleanup; add logging for debugging background packets stuff. 2011-09-30 06:36:56 -07:00
Andy2
cb6a16f8f8 add ability to connect on nbs socket and use as destination for
messages fetched from relay, and to receive replies on same socket for
forwarding to relay.
2011-09-30 06:34:09 -07:00
Andy2
58be931558 remove messages after sending them if they appear to have been sent
successfully.
2011-08-17 19:52:55 -07:00
Andy2
2c26fc03e3 Track messages sent via proxy and credit nsent (accumulator) if
successful.  Previously messages sent via proxy were not counted.
2011-08-17 18:09:10 -07:00
Andy2
b511b4c455 add new RecordSent to take list of msg ids -- and use stringstream
instead of static buffer and snprintf in one case.  May make sense
elsewhere too.
2011-08-17 18:07:21 -07: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
Andy2
dc273c7162 fix proxy msg handling to process more than one relayID per message.
Formerly all but the first were dropped.
2011-08-15 18:27:00 -07:00
Eric House
421e2a4ae3 fix uninitialized variable 2011-07-08 05:53:08 -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
Andy2
928404be50 remove unused enum 2011-07-06 06:15:25 -07:00
Eric House
a3dbde9b88 more dealing with edge cases. 2011-07-05 21:42:03 -07:00
Eric House
98a65d82ed fix crash in rare edge case 2011-07-05 21:40:13 -07:00
Eric House
d3108aac79 split method in two to provide new API (I'm not using yet) 2011-07-05 21:39:38 -07:00
Andy2
999d4c11e7 simple script for watching what messages the relay has pending for a
game.
2011-07-04 12:51:27 -07:00
eehouse@eehouse.org
8f782070ac Merge branch 'android_invite' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_invite 2011-07-03 09:28:36 -07:00
Andy2
175aace629 fix a couple of rare failures due to race conditions testing or
valgrind flushed out.
2011-07-02 13:28:24 -07:00
Eric House
09b81c6ad7 fix rare crash: don't call PQgetvalue when there are no results. 2011-06-30 19:39:00 -07:00
Eric House
b4a513ce87 reduce logging; log errno on syscall failure 2011-06-29 21:38:31 -07:00
Eric House
8e31fd88c3 reduce logging; and fix valgrind-found problem using wrong
synchronization primative.
2011-06-29 21:37:33 -07:00
Eric House
04740486fb wrap more logging in ifdefs 2011-06-29 21:35:21 -07:00
Eric House
2b4f439a2f rough script to parse logs looking for threads that have hung (stopped logging) 2011-06-29 21:32:18 -07:00
Andy2
57cfefb6a9 fix leaks -- that don't really matter as process is exiting, but
quiets valgrind.
2011-06-29 18:45:02 -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
c84722fc22 add ack 2011-06-27 06:45:14 -07:00
Andy2
fffcbb677e under testing I'm running up against the 1024-files-open limit and
dying with an assert.  Log something -- but still die as there's
nothing to be done in code except hope some connections don't
reconnect right away.  Fixes: 'ulimit -n' or edit 'nofile' param in
/etc/security/limits.conf on the relay host.
2011-06-27 06:20:51 -07:00
Andy2
c2cd3a709a specify name of database in config file rather than hard-coding it. 2011-06-25 21:32:18 -07:00
Andy2
ffeb94e4bd start getting rid of super-verbose logging 2011-06-25 21:30:32 -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
df60ec648b Don't return new error XWRELAY_ERROR_NORECONN as devices don't have it
yet.
2011-06-24 18:32:53 -07:00
Andy2
9ff149fe2d fix race: if we get a cid from the DB while another thread has claimed
that cid, then by the time we can claim it there's no longer space for
us.  Call new method after the claim succeeds to make sure there's
still room, and if not relinquish and loop back to the DB for another
try.
2011-06-23 19:00:32 -07:00
Andy2
c51e5e41f4 fix ClaimSocket: it was neither marking claims nor checking for marks. 2011-06-23 18:58:50 -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
Andy2
aecdd8922f don't show times -- not interesting for debugging right now 2011-06-20 18:55:17 -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
44af266db6 add logging 2011-06-20 18:10:42 -07:00
Eric House
238fac3696 add new ack column to track whether devices have ACKd yet. 2011-06-20 18:10:07 -07:00
Andy2
7eb099d3a6 show seeds 2011-06-15 06:49:32 -07:00
eehouse@eehouse.org
32143d8116 Merge branch 'android_branch' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into android_branch 2011-03-31 18:19:31 -07:00
Andy2
9f76bdede9 hold mutex for slightly shorter time 2011-03-31 18:16:56 -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
7aeb0a4df0 make default socket timeout 5 seconds, not 20. 2011-03-31 18:13:16 -07:00
Andy2
cd4ddd5dbb fix help 2011-03-31 06:41:39 -07:00
Andy2
8bb2857e63 The relay is hanging inside recv(). Use setsockopt to set a 20-second
receive (and send) timeout on all sockets accept() returns.  Sockets
that timeout should then get closed and dropped.
2011-03-12 05:13:54 -08:00
Eric House
e196cfb352 add state table entry lack of which caused a bunch of crashes in a
short time on the live relay.  I'm not sure why it's needed, why they
happened only this time (likely due to a single device) or
alternatively why I don't see those crashes in testing, but the
addition doesn't break anything.
2011-02-04 05:41:44 -08:00
Eric House
dc82e57f14 add ability to fetch messages for more than one game at a time 2011-01-27 21:08:17 -08:00
Andy2
57ec020330 change format of reply to MSG_GET: include number of messages per
device to support fetching for more than one at once.  This is
meaningless for rq as written now but a device will want to do this.
2011-01-27 06:37:36 -08:00
Eric House
63d16a99a2 turn off http view 2011-01-24 22:20:01 -08:00
Andy2
42d1a713c9 add new -f flag to invoke new fetch-message proxy command. Write the
results to stdout in stream format (len + message).  Goal is to be
able to pipe output to the linux clients to test.
2011-01-22 12:54:47 -08:00
Andy2
f96f4a040b add new proxy command that fetches actual messages stored for a device. 2011-01-22 12:52:26 -08:00
Andy2
96fead3164 add msglen column to msgs table to be used to avoid calculating size
later.  Stores size of string as it was passed to db, not as stored.
2011-01-21 06:46:49 -08:00
Eric House
725888cb6c run proxy sockets through same thread pool as game sockets. This
prevents race conditions that are turning up when I'm running multiple
threads -- by allowing me to really not be running multiple threads.
Tested with the usual script.
2011-01-20 18:14:56 -08:00
Andy2
b506673946 use only one thread until race condition's fixed 2011-01-19 18:36:50 -08:00
Andy2
3ae62e4704 use an index rather than a ptr to track fd array (so a parallel array
can be added)
2011-01-19 18:36:24 -08:00
Eric House
720f78d18a get rid of ivars used only for http UI 2011-01-04 21:43:10 -08:00
Eric House
11d7de5f0d display the number of devices (pids) running 2010-12-21 20:52:01 -08:00
Eric House
b65338b643 script for use on relay host 2010-12-07 20:46:02 -08:00
Eric House
d1244da284 script encapsulating sql query that's useful to run (with 'watch') along with discon_ok2.sh 2010-12-02 22:29:36 -08:00
Eric House
ae9dbd1e5c create mtimes array rather than mtimes timestamp 2010-12-01 21:09:25 -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
1720fbbd50 fix parsing of relay ids by replacing separating \n with \0. 2010-11-23 17:46:16 -08:00
Andy2
daecc807c1 don't init nPerDevice, and deal with it not being inited. 2010-11-22 20:43:37 -08:00
Eric House
b91187d6a5 test result when parsing; drop if didn't parse 2010-11-16 20:30:43 -08:00
Eric House
4c6c3c1ded when marking a device in a dead game, negate its nperdevice entry rather than always using -1. 2010-11-16 20:28:53 -08:00
Andy2
635ae053b6 cut down on printing; don't assert-fail when relay's crashed. 2010-11-15 20:40:59 -08:00
Andy2
2c5c7a0dd1 init m_nRoomsFilled -- not sure when this http view feature broke 2010-11-15 20:08:59 -08:00
Andy2
ea292c7e2f exclude dead games when looking for open public rooms 2010-11-15 19:01:11 -08:00
Andy2
c6bd2125a4 java uses '/' to delimit device id, so we'll make that standard. 2010-11-15 18:27:36 -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
d4e810c9cb delimiter changed 2010-11-15 06:51:05 -08:00
Andy2
ce5738a4e1 write the count 2010-11-15 06:50:09 -08:00
Andy2
edf0c40904 track isDead when creating SafeCref for devgone 2010-11-15 06:49:41 -08:00
Andy2
2c9f2572a8 use GameFull() 2010-11-15 06:48:57 -08:00
Andy2
feca7345dc add GameFull -- database, not in-memory state, knows if game is full. 2010-11-15 06:48:36 -08:00
eehouse@eehouse.org
14579c6e30 Merge branch 'relay_proxy' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into relay_proxy 2010-11-14 19:40:35 -08:00
Eric House
528ae0c986 allow more than one device death per message 2010-11-14 15:19:38 -08:00
Eric House
a8ac30b180 add -d option to test dev-gone on relay 2010-11-14 15:18:49 -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