Commit Graph

135 Commits

Author SHA1 Message Date
Ivan Kozlovic
811e0868ed [FIXED] Data RACE on Unsubscribe when client connection is closed
Resolves #331
2016-08-17 16:46:34 -06:00
Ivan Kozlovic
6f9d542393 Minor changes based on comments 2016-07-26 12:25:33 -06:00
Ivan Kozlovic
fda5bd7ac7 [ADDED] Server sends INFO with cluster URLs to clients with support
Clients that will be at the ClientProtoInfo protocol level (or above)
will now receive an asynchronous INFO protocol when the server
they connect to adds a *new* route. This means that when the cluster
adds a new server, all clients in the cluster should now be notified
of this new addition.
2016-07-26 10:55:55 -06:00
Derek Collison
ab11e04bf9 Fixes for gofmt -s 2016-07-11 12:16:21 -07:00
Derek Collison
8d07e06b91 Always check for pruning 2016-06-20 09:10:54 -07:00
Derek Collison
fa95bd936b spelling 2016-06-17 10:09:14 -07:00
Derek Collison
67ed61c837 fixups for PR comments 2016-06-17 09:59:39 -07:00
Derek Collison
248bd8d366 bug fix for _SYS. 2016-06-16 21:46:54 -07:00
Derek Collison
a55b7c2744 log errors cleanup 2016-06-16 20:42:54 -07:00
Derek Collison
7730fac9e2 Authorization enforcement and performance tweaks 2016-06-16 17:07:25 -07:00
Derek Collison
8e81a1803c Fix for #288 2016-06-09 12:27:11 -07:00
Derek Collison
f2c17eb159 Merge pull request #294 from nats-io/auth_timeout_race
Fix possible authentication timeout after accepting CONNECT proto
2016-06-07 11:43:26 -08:00
Ivan Kozlovic
674109b922 Fix possible authentication timeout after accepting CONNECT proto
This PR addresses the issue by testing the result of the
`Timer.Stop()` method, which if `false` indicates that the callback
may be in progress. When that happens, the `processConnect` method
will wait for the callback to finish and simply return. The auth
timeout error will therefore be received by the client during the
synchronous connect process, which will allow it to try again.

Resolves #289
2016-06-06 21:27:45 +02:00
Justin Nuß
6715821140 Simplify processMsg
This commit has 3 changes:

- Remove duplicate logic for creating cache results map.
- Move code out of an if that will always be true and remove the if.
- Use == 0 instead of <= 0 for comparing the return value of len(X) as the value can never be < 0.
2016-06-05 14:18:03 +02:00
Ivan Kozlovic
188f7bf84c Fix possible blocking on socket write or connection close (when using TLS)
Ensure that all socket writes are protected with deadlines.
For connection Close(), also use deadlines since in case of TLS,
the Close() will send an alert (do a write) if the handshake was
completed. If the peer is not reading, this would cause the Close()
to hang.
2016-05-23 19:57:54 -06:00
Derek Collison
26caad27c1 Clear subs activity cache 2016-05-09 13:56:34 -07:00
Derek Collison
fd27025aa3 Ignore client pings for last connection activity 2016-05-09 09:56:38 -07:00
Ivan Kozlovic
3850b05388 Fix data race
When processing a connect request, there was a risk of race condition
when the server was being shutdown. Capture fields that are checked
under lock and lock when setting the route's remote ID.

Resolves #255
2016-04-22 17:28:41 -06:00
Ivan Kozlovic
3a999c1299 Add tracking of most go routines started by the server
Refactor the way client is initialized. We need to ensure that
clients are not added to the clients map and readLoop started if
the server is in the process of being shutdown otherwise there
is a chance that the server already gathered the list of connections
to close and this one would not be included, leaving a readLoop
running.
Same occurs for routes, with the complexity that the readLoop is
started well before the route connection is added to the server
routes' list. We need a temporary map that contains those connections
to be able to close them on server Shutdown.

Fixed some flapping tests.
2016-04-21 11:48:39 -06:00
Ivan Kozlovic
3aa09ecc01 Ensure Shutdown() waits for outstanding routes go routines
We need to make sure that when Shutdown() returns, routes go routines
that try to connect or reconnect have returned. Otherwise, this may
affect tests running one after the other (a server from one test
may connect to a server in the next test).
2016-04-21 11:48:39 -06:00
Derek Collison
0cb85b18ec remove need for atomic 2016-04-15 18:32:19 -07:00
Derek Collison
b3388db53f Enable dynamic write buffers for client connections 2016-04-15 18:16:13 -07:00
Derek Collison
4f333416bb Revert race on interest graph since it could cause dropped interest propogation, fix test instead 2016-04-15 15:46:29 -07:00
Derek Collison
3e2c3714bc Fix race in interest propogation to new routes 2016-04-15 13:16:13 -07:00
Justin Nuß
4bf0b47e74 Remove unnecessary string allocation 2016-04-05 15:25:55 +02:00
Derek Collison
768f23b5b4 dynamic read buffers 2016-04-03 14:30:17 -07:00
Derek Collison
96d9ce5048 Queue subscriber performance
Reworked sublist to sort out normal subscribers from queue subscribers into
a result set that can be cached and easily iterated over.
2016-04-03 13:04:06 -07:00
Derek Collison
d0a9a47ea3 L1 client cache for sublist and accounting optimizations 2016-04-03 05:41:45 -07:00
Derek Collison
df02bc0bcf Removed sublist, hash and hashmap, no longer needed. 2016-04-02 12:52:48 -07:00
Ivan Kozlovic
76324844a9 Fixed handling of unprompted PONG protocols
- The number of outstanding PINGs is now reset whenever the server
receives a PONG from the client.
- Updated parser test to check c.pout.
- Added a test to check for unprompted PONGs.

Resolves issue: https://github.com/nats-io/gnatsd/issues/168
2016-03-23 14:30:44 -07:00
Colin Sullivan
2baac47820 Address issues found by golint.
* No functional changes
* Did not address the ALL_CAPS issues
* Did not modify public APIs and field names.
2016-03-15 15:21:13 -06:00
Derek Collison
d09b6bdcf7 Optimize last activity and revert queue performance to alleviate normal sub performance hit 2016-03-07 06:24:23 +00:00
Ivan Kozlovic
7c0a3b49a6 Fix cluster formation when servers connect quickly
Both seed and chained cases are now handled properly when servers
connect quickly and concurrently to one another.
When accepting a route, the server will forward the new route INFO
protocol to its known routes. In turn those routes will connect
to the new server (if not already connected).
A retry for implicit route was introduced to mitigate the issue
with two servers connecting to each other and electing the opposite
connection as the winner, resulting in both connections being dropped.
The server with smaller ID will try once to reconnect.
Some tests were fixed to handle possible extra INFO protocol.
New tests added.

Fix issue: https://github.com/nats-io/gnatsd/issues/206
2016-02-24 19:44:25 -07:00
Derek Collison
7237972420 support for bcrypt in cluster auth 2016-02-23 12:47:46 -08:00
Ivan Kozlovic
112413a466 Fix infinite server attempt to connect route to itself
Attempt to address issue #175.
Instead of trying to detect if route URL will point to route listen address, detects that the route remoteID is server's ID.
If so, closes the connection and stop trying.
2016-02-10 14:19:54 -07:00
Derek Collison
853b4d720b Randomize distribution to subscribers
Better performance for queue subscriber distribution.
2016-02-05 09:06:17 -08:00
Derek Collison
703f928a4d Fix race on last activity 2016-02-05 05:58:09 -08:00
Derek Collison
9702156d72 Connection sort updates
- fix bug that did not update last activity on message delivery
- added sort capabilities for last activity
- avoid extra Reverse by simply changing Less func
2016-02-05 05:49:53 -08:00
Derek Collison
26185a9722 Support for connection last activity tracking 2016-02-04 17:33:40 -08:00
Ivan Kozlovic
1d6dafc6a7 Fix race on connz monitor (issue #189) 2016-02-03 21:26:26 -07:00
Derek Collison
b0c22e9dfd Track start and uptime per connection 2016-01-09 08:20:24 -08:00
Derek Collison
8393c3c994 Basic INFO for cluster auto-discovery, Addresses #126 2015-12-16 12:36:24 -08:00
Ivan Kozlovic
5036bbbf36 Fix TLS issue where server started to receive TLS data on non TLS connection.
Without the server fix, tls_test.go would likely report an error. The server would show a parser error with protocol snippet containing "random" bytes, likely encrypted data.
2015-12-07 19:44:12 -07:00
Derek Collison
6b8e8d89c8 Use smaller cost function for test, fix race 2015-11-30 18:29:53 -08:00
Ivan Kozlovic
97da466312 Fix races, add a test and adjust others.
* There was a race during unsubscribe()
* 'go test -race' reports a race in TestSetLogger test. This one could be ignored since we normally invoke SetLogger only on server startup. That being said, Travis failed when I tried to submit a PR for the fix of the unsubscribe race. So proposing to fix the logger too.
2015-11-18 20:39:56 -07:00
Derek Collison
200f2d95c6 Merge pull request #139 from nats-io/issue-138
Fix possible non-propagation of subscription interest to routed server.
2015-11-17 22:01:21 -08:00
Ivan Kozlovic
b62835363a Fix possible non-propagation of subscription interest to routed server.
If processRoute executes before createRoute finishes registering the route, and before a subscriber has connected (or reconnected), and the subscriber connects (or reconnects) before the route is registered, then this subscription will stay local and not be forwarded to the route.
2015-11-17 21:36:18 -07:00
Ivan Kozlovic
17d231361d Fix handling of duplicate SUB protocol.
This is issue #136. With routes, it is possible that a subscriber connects (or reconnects) and is about to broadcast the SUB protocol to the routed server, and at the same time, the server sends the list of the local subscriptions. This would result in a SUB processed twice, adding the same sub in the sublist twice. If the server sending the subscription list is restarted, this will leave "detached" subscriptions in the sublist which would trigger the "Bad or Missing ROUTER info" for every message published on that subject.
2015-11-17 20:58:54 -07:00
Derek Collison
b8af53e67a Added in clustered TLS 2015-11-08 14:20:01 -08:00
Derek Collison
749d4f89cc First pass at client TLS support 2015-10-22 03:30:27 +02:00