Commit Graph

173 Commits

Author SHA1 Message Date
Peter Johnson
9c576b10d0 NetworkTable: Don't prefix path with / if key is empty.
This avoids NetworkTable("").putValue("foo") resulting in key "//foo".
2015-08-28 12:24:33 -07:00
Peter Johnson
b488cdd6ff Support immediate notify of connection listener.
Also only perform immediate notification to the callback actually
requesting the notification, not all existing callbacks.

Offset returned uids by 1 so uid=0 can be used to indicate immediate
notification.
2015-08-28 00:13:56 -07:00
Peter Johnson
302cc064c6 ConnectionListener: Use bool instead of int for connected parameter. 2015-08-27 23:48:40 -07:00
Peter Johnson
6e4d7ca933 NetworkTable: Protect listeners with mutex. 2015-08-27 23:39:52 -07:00
Peter Johnson
6c8a5935c9 NetworkTable: Fix table and key listener behavior.
The implemented behavior didn't match the old networktables implementation.
2015-08-27 22:22:51 -07:00
Peter Johnson
86445b6670 Import llvm::SmallPtrSet. 2015-08-27 22:16:56 -07:00
Peter Johnson
330ba39939 Unbreak Unix build. 2015-08-24 21:45:41 -07:00
Peter Johnson
a3dbe9a800 Fix Windows client.
Windows returns WSAEWOULDBLOCK on a connect() attempt on a nonblocking socket.

Also wrap socket error handling so errors are correctly reported on Windows.

Fixes #19.
2015-08-24 21:21:13 -07:00
Peter Johnson
822dc45834 Close persistent file before attempting to rename.
Windows requires the file be closed in order to rename it.
2015-08-24 20:38:33 -07:00
Peter Johnson
29f73cb5c1 Don't dispose in ConvertToC for NT_String and NT_Value.
Fixes #16.
2015-08-22 19:31:53 -07:00
Tyler Veness
ab9de550d9 Replaced time.h with std::chrono
This implementation returns the same values as the previous one on both a Linux machine and the roboRIO.
2015-08-20 16:04:55 -07:00
Peter Johnson
9cb9c3beb0 Logger: Move m_min_level init to header. 2015-08-19 22:04:31 -07:00
Peter Johnson
2d1bc2f4c7 Uninline constructors to reduce GetInstance() inlined code size. 2015-08-19 21:49:18 -07:00
Peter Johnson
c6bed1f464 Dispatcher: Move several fixed initial values to header. 2015-08-19 21:16:44 -07:00
Peter Johnson
c41341c7e3 Clean up trailing whitespace. 2015-08-19 20:41:59 -07:00
Peter Johnson
f0e31487f0 raw_istream and kin: a few cleanups.
anchor() doesn't seem to change compiler output in current compilers, so
remove it.  Use default where appropriate rather than empty bodies.
2015-08-19 20:37:27 -07:00
Peter Johnson
ca9ce0f3a3 Implement automatic persistent saves.
Also loads persistent file on server start.
2015-08-19 19:18:09 -07:00
Fredric Silberberg
9458da0454 Added building for arm, x86, and x64 with Gradle. This only builds ntcore currently, I'm working getting Google Test to work. 2015-08-15 21:46:21 -07:00
Peter Johnson
80247e98e5 Use relative include paths in tcpsockets. 2015-08-13 23:07:45 -07:00
Peter Johnson
a395e3577f Notifier: Fix condition variable race. 2015-08-13 21:35:33 -07:00
Peter Johnson
8d7cdeabbf Implement remote procedure calls. 2015-08-13 21:32:16 -07:00
Peter Johnson
e9618df1b5 Avoid pointer aliasing for double/bits conversions.
Instead use the llvm MathExtras.h functions for this, which use union
aliasing.
2015-08-12 17:15:10 -07:00
Peter Johnson
c34ba968f1 Message: Remove ArrayRef-taking ExecuteRpc/RpcResponse. 2015-08-12 17:11:09 -07:00
Peter Johnson
cd53feb193 Log DEBUG() macros: avoid spurious warnings in release builds. 2015-08-04 20:36:39 -07:00
Peter Johnson
7d409f071e Add win32 tcpsockets implementation. 2015-08-04 00:01:13 -07:00
Peter Johnson
4146db6fc8 Visual Studio 2013 compilation fixes.
- Missing header file callouts in some cases (library deltas)
- Lack of support for auto parameters in lambdas
- Defining of ERROR by windows.h
- Dispatcher::Connection needs a move constructor (default not generated)
- Need explicit enable_if on std::string move template in Value to avoid trying to move const char[] (string literal)
- Compile flags
2015-08-03 01:27:02 -07:00
Peter Johnson
a86f65db1e Dispatcher: Implement transmit combining.
This handles most of the major cases, but not a loop of delete/assign, which
should be uncommon anyway.
2015-08-02 23:21:23 -07:00
Peter Johnson
53a0531def Storage::ProcessIncoming(): Don't override parameter with local. 2015-08-02 23:20:42 -07:00
Peter Johnson
7db00575c9 NetworkConnection: Add a bit more debugging. 2015-08-02 22:23:14 -07:00
Peter Johnson
5b65bfb64d Storage: Fix comparison for client update-on-assign. 2015-08-02 22:18:46 -07:00
Peter Johnson
e9073a3cc0 Implement notifiers.
The notifier thread is lazily started when the first notifier is added.
This avoids the extra thread/processing overhead when notifiers are not used.
2015-08-02 21:47:01 -07:00
Peter Johnson
538a19fd47 Implement GetConnections(). 2015-08-02 10:47:05 -07:00
Peter Johnson
84ff80710c Refactor TCP-specific pieces of Dispatcher. 2015-08-02 00:33:41 -07:00
Peter Johnson
0dcaf56ed1 Add NetworkAcceptor and NetworkStream interfaces.
These allow mocking of TCPAcceptor and TCPStream respectively.
2015-08-02 00:06:27 -07:00
Peter Johnson
6703968f73 Dispatcher: Fix shutdown order race.
We need to wait until after the dispatch and client/server threads have
been stopped before closing connections, as these threads can add connections.
2015-08-01 23:37:13 -07:00
Peter Johnson
8ec65dbfc8 Use unique_ptr instead of shared_ptr for m_server_acceptor. 2015-08-01 20:29:16 -07:00
Peter Johnson
35e6400174 Storage: Add vector include. 2015-08-01 16:33:39 -07:00
Peter Johnson
67de7af7b2 Storage: Use unique_ptr instead of shared_ptr for Entry. 2015-08-01 11:47:35 -07:00
Peter Johnson
b5274a495e Dispatcher: Don't call Storage::GetInstance() internally.
This makes it difficult to test.  Instead, store reference as member variable,
and populate it at constuction (with an alternate constructor available for
test purposes).
2015-08-01 11:15:04 -07:00
Peter Johnson
11508b77d1 Ensure initial synchronization is atomic. 2015-07-31 23:56:06 -07:00
Peter Johnson
0a10778697 NetworkConnection: Kill write thread when read dies and vice-versa. 2015-07-31 23:40:16 -07:00
Peter Johnson
ecbf76e94b Update tcpsockets classes to use log framework. 2015-07-31 23:34:54 -07:00
Peter Johnson
6c0103639c Make LOG() usable from other namespaces. 2015-07-31 23:33:41 -07:00
Peter Johnson
c2eb4a766e Dispatcher: Provide some INFO-level connection messages. 2015-07-31 23:26:38 -07:00
Peter Johnson
3a71acec52 Automatically reconnect client.
Also clean up some condition variable handling to make it more robust.
2015-07-31 23:14:26 -07:00
Peter Johnson
a9af4589ac Don't send empty message lists from dispatch.
This terminates the write thread.
2015-07-31 22:49:43 -07:00
Peter Johnson
4356e313ec Add logging framework.
DEBUG messages are completely optimized out if NDEBUG is defined.
2015-07-31 22:41:26 -07:00
Peter Johnson
ead125555c Implement client/server handshaking. 2015-07-31 20:32:52 -07:00
Peter Johnson
98ad6d1b43 Message: Handle receiving Server Hello. 2015-07-31 20:14:15 -07:00
Peter Johnson
978cdadda0 Storage::GetEntryType(): Check for null entry. 2015-07-31 14:16:13 -07:00