Commit graph

791 commits

Author SHA1 Message Date
Eric House
2157706dcd add client version and a desc string to devices DB and to reg info sent to relay 2013-08-20 08:09:45 -07:00
Eric House
84d06b9fed use g_shell_parse_argv() to parse input buf (so messages can be in
quotes and contain whitespace)
2013-08-19 08:25:06 -07:00
Eric House
0868a33c83 print out whether message is ACK'd or not 2013-08-18 20:52:09 -07:00
Eric House
d0aca01289 clean up send message/alert code 2013-08-18 15:48:44 -07:00
Eric House
47203437cc register devices more often; add ctrl command to send text message to
device if possible, otherwise to post it to the db (mostly for testing).
2013-08-17 14:55:19 -07:00
Eric House
6a27bbba94 tweaks to new ctrl command 2013-08-15 19:22:23 -07:00
Eric House
d07bb5013d oops: function need to return something 2013-08-15 19:22:01 -07:00
Eric House
62f0819a82 Toward resurrecting ctrl feature to give runtime info about stuff that
isn't in the DB.  Step one: comment out the stuff that doesn't compile
and add ability to print all registered devices with their ages.
2013-08-15 08:44:33 -07:00
Eric House
06f0b7e411 treat KEEPALIVE same as RQSTMSGS (for now) 2013-08-15 07:25:20 -07:00
Eric House
61009cefc7 in advance of using memcache, keep track (in memory) of those devids
for which no messages are pending, since that's a query that can be
made by each device every minute.
2013-08-15 07:24:30 -07:00
Eric House
f1b60dab62 Don't assert when can't find state transition. At least in some cases
these result from unexpected/out-of-order packets that slip through.
2013-08-14 08:11:21 -07:00
Eric House
fe51d19c2e Device can't be 'alreadyHere' if has hostID of 0 since the only way a
device gets registered involves giving it a non-0 hostID.  Fixes array
OOB access.
2013-08-14 08:10:09 -07:00
Eric House
80f66d1df7 remove test for duplicates now that it's impossible 2013-08-13 08:20:57 -07:00
Eric House
5be8779749 remove redundant member variable 2013-08-13 08:19:32 -07:00
Eric House
c9406c36ae use a simple array rather than a vector to store currently connected
devices.  It's simpler, searching for hid is faster, and it makes it
easier to detect when we try to add the same device twice.
2013-08-13 08:04:19 -07:00
Eric House
fde50cce32 move timeout interval into config file; cleanup 2013-08-12 07:41:48 -07:00
Eric House
787367071d show only those devids in the visible games 2013-08-08 19:55:04 -07:00
Eric House
635b948c41 don't drop messages from devices without a devID -- lots of older
devices are in that boat.
2013-08-08 00:40:32 -07:00
Eric House
01c97c5716 null token is a possibility if message was stored by device connecting
via tcp and device is now connecting via udp
2013-08-07 21:59:21 -07:00
Eric House
cd9eea665b oops: still need to register device connecting via tcp so gcm sends
can work.
2013-08-07 21:36:06 -07:00
Eric House
84b77d4456 log threadid as unsigned int 2013-08-07 21:32:58 -07:00
Eric House
b49486fc3f cleanup: use constant and add/use isUDP() 2013-08-07 21:31:10 -07:00
Eric House
bac947d780 don't remember tcp-based addresses. Fixes problem when a device
switches from tcp- to udp-based connection.
2013-08-07 21:04:05 -07:00
Eric House
91c82d9874 tweak logging to match format gdb prints 2013-08-07 21:03:11 -07:00
Eric House
6dbabaa319 cleanup 2013-08-07 21:02:47 -07:00
Eric House
470dbb5304 oops: still remove address from set tracked if it's not tcp 2013-08-05 07:50:11 -07:00
Eric House
4ad6696ecc add delete-on-ack logic to another message sending site, and fix
assertion failure caused by not providing a client token on messages
being sent.
2013-08-02 22:33:06 -07:00
Eric House
1e35d676bf change constant name 2013-08-02 07:31:41 -07:00
Eric House
6e14a6d33a fix leak; remove unused variable 2013-08-02 06:11:08 -07:00
Eric House
8b936ea0ea iterator is invalid after erase() call, so advance first. Fixes problem valgrind found. 2013-08-02 06:08:41 -07:00
Eric House
a8cc920dcf new method 2013-08-01 07:49:12 -07:00
Eric House
4ecb0f534d For a subset of stored messages sent, don't remove from DB until
they're acked.  (This is the goal for all messages sent via UDP, but
will be harder elsewhere in the code.)
2013-08-01 07:48:44 -07:00
Eric House
684effd170 cleanup 2013-08-01 06:12:58 -07:00
Eric House
17b8eae1f1 clean up fetching of stored messages, and excluse those from dead games 2013-07-31 07:24:58 -07:00
Eric House
54c1e0c2ab drop bogus assert 2013-07-29 17:39:43 -07:00
Eric House
d8a4b5ce29 include udp maxInterval, the number of seconds the relay's configured
to assume an address is still good when it hasn't heard from it, in
reg response reply, send that reply always, and read and log the new
field on clients.  It will eventually be used to implement a
keepalive.
2013-07-29 07:27:30 -07:00
Eric House
cdea106824 change param to simplify code a bit 2013-07-29 06:33:31 -07:00
Eric House
5f9b2e431f optimization: test address before fetching messages for it 2013-07-28 07:28:32 -07:00
Eric House
9951064439 fetch all stored messages at once to reduce number of DB calls made. 2013-07-25 06:37:53 -07:00
Eric House
6bb2efbbd5 remove mistaken assert 2013-07-24 06:03:50 -07:00
Eric House
41160579ca remove duplicate 2013-07-23 18:30:08 -07:00
Eric House
bfc617720e add isCurrent() method on UDP addresses based on how long it's been
since we've received data from the same source, and use to drop
packets in response to reads that are older than when the test says
the endpoint of the address changed.
2013-07-23 06:21:57 -07:00
Eric House
572d3596ae add heretofore undocumented config 2013-07-23 06:18:17 -07:00
Eric House
ceacbc2cbe fix formatting error 2013-07-23 06:17:35 -07:00
Eric House
acca4d14d4 new files to track how long it's been since data's been received from
a UDP address.  The idea's that when there's too long a gap the
address has likely been recycled and we shouldn't send replies to
packets received before the reset.
2013-07-22 07:26:14 -07:00
Eric House
7b18da70db logging tweak 2013-07-22 06:11:10 -07:00
Eric House
48a2567edf log contents of incoming udp packets 2013-07-22 06:06:39 -07:00
Eric House
13550865ad drop packets in queue if they've been there longer than 30 seconds --
which should be a configurable value.
2013-07-22 06:05:24 -07:00
Eric House
13c234dfab log when address replaced 2013-07-20 11:59:00 -07:00
Eric House
5d8cd5a17f recognize already-seen devices. This seems to occasionally fix
reconnect problems but needs to be studied/tested more -- check logs.
2013-07-20 11:44:00 -07:00
Eric House
464ef49018 add new send_via_udp that may be able to check for address validity 2013-07-20 10:37:38 -07:00
Eric House
792a51a404 change ivar name 2013-07-20 08:33:22 -07:00
Eric House
61992943dd Add mapping from address to devid in order to catch when an address is
reused.  That required making AddrUnion a class rather than a simple union.
2013-07-20 08:06:14 -07:00
Eric House
32150049e2 assert that we aren't tracking two connected games with the same hid 2013-07-20 06:28:35 -07:00
Eric House
2ce097629f log contents of udp packets as b64-encoded strings for debugging; off
by default.
2013-07-18 06:52:07 -07:00
Eric House
06dd9a99a1 better logging 2013-07-17 21:34:52 -07:00
Eric House
3737f19548 better logging 2013-07-17 21:34:27 -07:00
Eric House
972dcfec81 cleanup 2013-07-17 21:33:59 -07:00
Eric House
1d5cf0bea7 don't remember devid unless it's valid 2013-07-17 21:33:36 -07:00
Eric House
d436232800 correctly log b64 dump of return address at record and use sites 2013-07-17 06:38:25 -07:00
Eric House
021d6370f3 drop, rather than asserting about, corrupt packets -- meaning where
the player counts don't make sense.
2013-07-16 06:40:00 -07:00
Eric House
1638d964fb log socket address to try to track down apparent misaddressing 2013-07-16 06:38:26 -07:00
Eric House
e80fe76652 assert we don't go out of bounds on array 2013-07-15 07:33:27 -07:00
Eric House
b5714e9d14 improve API: hide special numbers inside implementation 2013-07-12 08:24:44 -07:00
Eric House
5814febad5 better client token logging 2013-07-10 23:13:50 -07:00
Eric House
2060aa4577 don't match on empty devID 2013-07-10 23:12:57 -07:00
Eric House
dbf156fca7 remove excess logging 2013-07-10 08:02:28 -07:00
Eric House
d50c808f96 Merge branch 'android_branch' into gtk_multigame
Conflicts:
	xwords4/android/XWords4/src/org/eehouse/android/xw4/DlgDelegate.java
	xwords4/common/comms.c
	xwords4/linux/cursesmain.c
	xwords4/linux/cursesmain.h
	xwords4/linux/gtkmain.c
	xwords4/linux/gtkmain.h
	xwords4/linux/linuxmain.c
	xwords4/linux/main.h
	xwords4/linux/scripts/discon_ok2.sh
	xwords4/relay/xwrelay.cpp

(Note: The curses app crashes on exit with mempool assertions, but that's a problem before the merge.)
2013-07-09 07:18:00 -07:00
Eric House
232b27e06a combine two log lines 2013-07-05 21:31:39 -07:00
Eric House
f87ffe7a96 display new column 2013-07-05 21:28:27 -07:00
Eric House
e8022d44ea correctly parse hid from relayID, fixing assertion failure. I'm not
sure how it ever worked....
2013-07-05 21:26:17 -07:00
Eric House
713551fa43 only log recv() errors that aren't related to non-blocking sockets 2013-07-05 21:23:54 -07:00
Eric House
254b82104c reduce priority of log message 2013-07-05 08:03:31 -07:00
Eric House
2cd84c4229 test that address is good each time through loop 2013-07-05 08:03:03 -07:00
Eric House
23c66e93ab add flag required to compile on some linux systems 2013-07-05 08:02:22 -07:00
Eric House
a93eb4a511 fix assertion failure: log and drop packet when hid outside of accepted range. 2013-07-05 08:01:31 -07:00
Eric House
883cec0652 log whether b64 encoding is being used 2013-07-05 06:56:43 -07:00
Eric House
8e12a8ef84 when we get a fatal error from postgres server, try killing then
recreating the connection.  This is untested, as fatal errors are
rare.
2013-07-03 07:36:15 -07:00
Eric House
b53f9bc578 let Pqexec fail three times, usleeping between, before restarting with an assert 2013-07-02 07:27:31 -07:00
Eric House
a8f49ad94b Merge remote-tracking branch 'origin/android_branch' into android_branch 2013-07-02 06:08:23 -07:00
Eric House
3d18e5832e specify server's port in conf file since at least on one of my
machines it's not what libpq expects.  (Required by upgrade from 8.4
to 9.1.)
2013-07-02 05:46:48 -07:00
Eric House
2da26cf8a9 cleanup/comment 2013-07-01 07:52:02 -07:00
Eric House
8419bf2a04 close socket if length == 0 -- protocol violation or network error 2013-06-28 18:48:57 -07:00
Eric House
0a794f390f fix off-by-one error leading to malformed queries 2013-06-28 18:47:11 -07:00
Eric House
0447b9f5e5 column name changed 2013-06-27 06:58:17 -07:00
Eric House
f9cebfe444 track bytes sent per device rather than per game 2013-06-27 06:23:15 -07:00
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
909640c82f cleanup/improve logging 2013-06-26 00:36:02 -07:00
Eric House
d7f8e8e198 rq is hanging, so set timeouts on its blocking sockets 2013-06-26 00:27:55 -07:00
Eric House
d801b23a87 add missing config option 2013-06-25 23:40:46 -07:00
Eric House
a1d272bf4f log sockets associated with packets 2013-06-25 22:54:13 -07:00
Eric House
649969bc30 send ALL_HERE to all players 2013-06-25 22:52:13 -07:00
Eric House
aa7e9bf751 fix compile when debug define turned on 2013-06-25 07:59:40 -07:00
Eric House
27e9b48b78 fix timestamp math that had newer sometimes less than older 2013-06-25 07:58:15 -07:00
Eric House
519f90a69a go with non-blocking sockets for tcp connections, adding the ability
to reassemble packets that arrive in separate recv() calls.
2013-06-24 07:09:57 -07:00
Eric House
d4cf37d2ef fix misspelling 2013-06-24 07:05:09 -07:00
Eric House
ed16437f9a don't refuse to store message when devid isn't available 2013-06-23 19:07:45 -07:00
Eric House
d14688a6a0 fix almost-infinite loop; assert no dup devids 2013-06-22 22:24:18 -07:00
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