You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/09/28 21:44:45 UTC
[2/8] mesos git commit: Prevented a race when relinking with SSL
downgrade enabled.
Prevented a race when relinking with SSL downgrade enabled.
If there are two or more actors, on the same OS process, that try to
relink at the same time, there is a potential CHECK failure when SSL
downgrade is also enabled. The following interleaving is problematic:
| Actor A | Actor B |
|---------------------------------+---------------------------------|
| Starts to relink. | Starts to relink. |
| Creates socket A. | |
| Replaces link with Socket A. | |
| Tries to connect with Socket A. | |
| | Creates socket B. |
| Connection fails due to SSL. | Replaces link with Socket B. |
| Attempts to downgrade. | |
| Tries to replace link. | |
The last step in the interleaving fails because we assert that the
socket we are swapping out exists in the `SocketManager`s state.
Review: https://reviews.apache.org/r/52182/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/be7d29a3
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/be7d29a3
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/be7d29a3
Branch: refs/heads/1.0.x
Commit: be7d29a3159d3e7d042a0e24476ed9d4a8cb5bcb
Parents: 152484b
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Wed Sep 28 12:33:31 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Wed Sep 28 13:22:16 2016 -0700
----------------------------------------------------------------------
3rdparty/libprocess/src/process.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/be7d29a3/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 5b7be3a..7a750a0 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1453,6 +1453,14 @@ void SocketManager::link_connect(
// POLL socket.
if (attempt_downgrade) {
synchronized (mutex) {
+ // It is possible that a prior call to `link()` with `RECONNECT`
+ // semantics has swapped out this socket before we finished
+ // connecting. In this case, we simply stop here and allow the
+ // latest created socket to complete the link.
+ if (sockets.count(socket) <= 0) {
+ return;
+ }
+
Try<Socket> create = Socket::create(Socket::POLL);
if (create.isError()) {
VLOG(1) << "Failed to link, create socket: " << create.error();