DESCRIPTION

JVMCBC-209: Avoid race condition between disconnect and reconnect.

Motivation
----------
There is a (small) chance that both the disconnect and a reconnect
initiated by a closed socket race each other and the endpoint,
despite being explicitly disconnected, ends up in a reconnect
loop.

Modifications
-------------
The AbstractEndpoint now explicitly sets a volatile disconnected
flag which is always checked before a reconnect cycle is initiated.
This prevents the chance of states being messed up and racing
each other in the disconnect (and therefore, terminal) case.

In addition, to make sure that all states are properly observed
the state machine's observable is also serialized (this makes
sure that event transitions from multiple threads are observed
in the right order).

Result
------
Disconnect calls are now more strictly enforced, preventing
"endless" reconnects. Also, the state machine streams are
now properly serialized.

Change-Id: I586ced07a2ac3fc43f21b731ca80d3de80b4a098


COMMENTS

author: Natasha Sullivan
date: 2015-06-18 11:30:16.593000000

Uploaded patch set 1.

-------------------------------------
author: Natasha Sullivan
date: 2015-06-18 11:30:39.511000000

Patch Set 1: Verified+1

-------------------------------------
author: Gerrit Code Review
date: 2015-06-18 13:30:25.547000000

Change has been successfully cherry-picked as cd09fbf08337f1e0db842de7d323a6d5128b6c11

-------------------------------------
