Commit Graph

270 Commits

Author SHA1 Message Date
Thad House
9047c98e68 Fixes possible indefinite timeout on multiple RPC calls (#120)
Calculates timeout before the RPC call checks ever loop.
2016-09-30 12:41:52 -07:00
Peter Johnson
53d0789660 Storage: Escape equal sign in strings. (#119)
This helps interoperability with standard config parser libraries
(such as Python's RawConfigParser).
2016-09-29 20:16:32 -07:00
Peter Johnson
d3ed26f7cc Logger: Use raw_ostream and SmallString. 2016-09-25 19:48:49 -07:00
Peter Johnson
c2ae897b02 Change API of raw_istream to be more similar to raw_ostream. 2016-09-25 19:48:49 -07:00
Peter Johnson
f6b700ea97 Move common utility classes to wpiutil library. (#79)
This is a breaking change to dependencies that use the static ntcore
library.  Unless the wpiutil library is also linked, linker errors will
result.  This does not affect the shared ntcore library.
2016-09-25 17:23:39 -07:00
Thad House
80e546b79f Adds a way to externally test C structures (#115)
For language interop, its nice to be able to create the structs from the
C side to make sure everything works properly.
2016-09-18 21:48:17 -07:00
Thad House
e952236e1a Reverts the last 2 Rpc changes (#114)
* Revert "Fully asigns the ConnectionInfo struct (#113)"

This reverts commit 9a3100b221.

* Revert "Passes the ConnectionInfo of the Rpc client on server callback (#112)"

This reverts commit 7e9754acff.
2016-09-16 22:23:58 -07:00
Thad House
9a3100b221 Fully asigns the ConnectionInfo struct (#113)
For some reason, it was putting garbage in for the things that shouldn't
have been, which doesn't make much sense.
2016-09-16 21:56:57 -07:00
Thad House
7e9754acff Passes the ConnectionInfo of the Rpc client on server callback (#112) 2016-09-16 20:20:55 -07:00
Thad House
fc48944b47 Fixes Rpc Cancel. Check was only in timeout case instead of global (#110) 2016-09-02 19:28:59 -07:00
Thad House
85156d15ca Fixes the final issue with VS 2013 builds (#109) 2016-08-30 21:27:48 -07:00
Thad House
7845caa100 Fixes GetRpcResult not removing calluid from call list on non blocking call (#100) 2016-08-19 21:48:30 -07:00
Thad House
66d214c8a8 Finishes blocking call canceling (#99) 2016-08-18 00:05:06 -07:00
Thad House
277cf2a08f Removes new line from mdns name (#98)
Closes #97
2016-08-17 21:21:55 -07:00
Thad House
7bf44e951c Fixes server side polled rpcs (#96) 2016-08-16 23:32:13 -07:00
Thad House
c0ce4270f0 Adds a way to cancel a blocking rpc call (#94) 2016-08-16 23:31:45 -07:00
Thad House
d6e8de21ef Fixes rpc timeouts and blocking call list error (#95) 2016-08-16 23:31:01 -07:00
Peter Johnson
1635cba827 Reduced minimum update rate from 100 ms to 10 ms. (#89) 2016-08-16 12:07:17 -07:00
Thad House
a786470623 Only allows 1 blocking call per Rpc Call Id (#93) 2016-08-15 22:46:49 -07:00
Thad House
0b80bd2b09 Adds timeout capabilities to blocking Rpc Calls (#86) 2016-08-15 20:24:07 -07:00
Thad House
bc99d341fb Changes remote_name to remote_ip (#87)
Was confusing, as remote_name seemed like a name but wasn't.
Also changes remote_ip in the C api to use an NT_String
2016-08-07 16:38:20 -05:00
Peter Johnson
a73166a665 Make many more utility classes/headers public. (#76)
Moving these headers from src to include enables other libraries to use the
functionality provided.

* tcpsockets
* atomic_static
* raw_istream
* timestamp
* SafeThread
* Base64
* LEB128
* ConcurrentQueue

The classes have been moved into the wpi namespace as they're generic.
2016-07-27 00:39:38 -07:00
Thad House
58092c5190 Adds SetDefault methods to NetworkTables (#54)
There was no way to atomically check for a key in the table,
and then setting if it if non existant. Back before persistent
this was not a problem, however now it is, as its possible for
values to be added before team's robot programs start. This makes
the old method of calling Put*** methods in RobotInit invalid.
This adds SetDefault methods, which do this atomically.
2016-07-13 00:31:03 -07:00
Peter Johnson
50a2612839 Notifier: maintain freelist to reuse uids. (#81)
This avoids endless growth of the vector.

Fixes #80.
2016-07-12 23:19:46 -07:00
Peter Johnson
4b516de183 Don't delete persistent entries in DeleteAllEntries. (#71)
This is a behavior change but without it DeleteAllEntries is dangerous and
not very useful, so I consider the current behavior to be a bug.
2016-06-17 22:33:02 -07:00
Peter Johnson
c7d9ecbab3 Fix mac build by not defining false and true. (#73) 2016-06-17 22:32:18 -07:00
Peter Johnson
3c77faaf61 Fix UTF8 conversion in Java. (#70)
Java doesn't use standard UTF8, so surrogate pairs were being converted
incorrectly and incompatibly with C++.

Fixes #69 (artf3973).
2016-06-10 22:24:42 -04:00
Peter Johnson
5ac68f74d4 Support client round robin to multiple server addresses.
Change-Id: If87dc64a485b1c8a340c5f6fa39ca09d40133e30
2016-04-08 22:02:52 -07:00
Thad House
836dc7a880 Fixes Connection Listeners
AddConnectionListener was returning the uid of entry listeners, which
would make connection listeners not work.
2016-02-08 15:40:34 -08:00
Peter Johnson
c90a8c586f getTable(): Don't prepend slash if key already starts with it.
This makes getTable("/foo") and getTable("foo") equivalent.
2016-01-14 21:38:04 -08:00
Peter Johnson
9092b74f4e TCPAcceptor: Check for socket creation failure. 2016-01-04 18:13:39 -08:00
Peter Johnson
ed92385469 Merge pull request #44 from ThadHouse/master
Fixes Android Build issues
2016-01-04 18:02:08 -08:00
Thad House
1247976a34 Fixes Android Build issues
Trying to build with the android standalone compiler, and these 2 things
were causing errors. I don't know what an equivalent to basename would
be, because I don't really know what it does.
2016-01-04 17:35:51 -08:00
Peter Johnson
20f23e0e31 TCPConnector: Don't leak socket descriptors.
Also check to see if socket() returns error (less than 0) and error out.
2016-01-04 13:08:00 -08:00
Peter Johnson
d9efcbc7a9 C++ NetworkTable: Add array and raw getters and setters.
For consistency with Java NetworkTable; also makes these data types easier
to use (although they are less efficient as they require a memory allocation
and data copy).
2016-01-04 09:37:29 -08:00
Peter Johnson
5e2a07d58a Fix client connection to 2.0 server.
Fixes #42.
2016-01-03 17:54:08 -08:00
Peter Johnson
2aaaed34f9 Unbreak build on VS2012. 2015-12-28 19:27:05 -08:00
Peter Johnson
fef8f933d9 Add SafeThread to fix thread JNI shutdown races.
During JVM shutdown, some JNI calls may not return, so it's not possible to
reliably perform a join() during static variable destruction (which occurs
as the JVM unloads the JNI module).

Also, due to static variable destruction, it's not safe to use any members
of a static class instance from a separate thread of execution.

SafeThread is a templated thread class and a related owner class that's
designed for safe operation and shutdown of threads in the presence of
callbacks that may not return.  It also passes ownership of variables from
the static instance to the thread, so the thread can safely operate until
it exits (the last operation of the thread being to destroy its instance).

Notifiers, RpcServer, and Logger now use SafeThread to ensure race-free
destruction in both C++ and Java.

All Java callback threads are now marked as Java daemon threads so they
don't keep the JVM running after main() terminates.

All Java callback threads are now named so their purpose is more easily
identified in a debugger.

Add SetRpcServerOnStart and SetRpcServerOnExit (similar to Listener).
2015-12-28 17:51:56 -08:00
Peter Johnson
44821c3e3c Change how Dispatcher is shut down.
The previous use of a timeout resulting in thread detach instead of thread
join resulted in a race condition on Mac between destruction and thread
closeout.  This commit removes the detach functionality and uses dup2() to
on Linux/Mac and connecting to itself on Windows to try to ensure accept()
exits.
2015-12-23 08:08:53 -08:00
Peter Johnson
2540f102b0 Include sys/select.h on Unix platforms. 2015-12-21 12:24:59 -08:00
Peter Johnson
32001427d4 Java: call JNI AttachCurrentThread less frequently.
Each call to AttachCurrentThread results in a new Java thread object being
created.  This is inefficient and also causes debugging issues with Eclipse
due to constant creation and removal of threads.  Now AttachCurrentThread is
only called once for (all) listeners and once for logging (if used).
2015-12-20 20:42:09 -08:00
Peter Johnson
b4c0583896 ContainsKey: Compare to nullptr.
This is a style change, not a functional change.
2015-12-19 22:36:32 -08:00
Peter Johnson
7528b6b8bf Fix NetworkTable::ContainsKey.
Previously this would always return false due to how explicit bool is
evaluated in a return context.

Also add a test for this function.

Reported by: jcreigh
2015-12-19 08:47:52 -08:00
Peter Johnson
e25d9fc96a Use correct condition variable in DispatchThreadMain(). 2015-12-11 21:13:41 -08:00
Peter Johnson
bc6da8effa Add noexcept shim for MSVC. 2015-12-09 01:22:21 -08:00
Peter Johnson
0d7106450b Make TableKeyNotDefinedException::what() const noexcept. 2015-12-09 01:18:00 -08:00
Peter Johnson
60647a2f8c Turn off Nagle algorithm to decrease latency.
This is safe because of the way writes are performed: for each transmission,
all outgoing messages are concatenated in memory and only a single write()
syscall is made.
2015-12-09 00:58:06 -08:00
Peter Johnson
76ee093e92 Add exception-generating C++ functions, but mark as deprecated.
These are good to have for backwards compatibility, but discouraged for new
development (default-taking functions should be used instead).  The reason
is that the exceptions must be explicitly handled and may initially work but
then fail at an inopportune moment.

Mark the similar Java functions as deprecated as well for the same reason.

Update all the docs for consistency.

Mark overridden functions as such in both C++ and Java.

Make IsPersistent and GetFlags const in C++.
2015-12-06 22:39:38 -08:00
Fredric Silberberg
9e6635ec13 Fixed log compilation on Mac
Change-Id: Ic231c56bdfd74c23d6086fb8ec485a0cec17d248
2015-12-06 16:14:26 -05:00
Peter Johnson
c2642f39ed Avoid null pointer deref on disconnect. 2015-11-30 20:02:40 -08:00