This is an automated email from the ASF dual-hosted git repository.

alexr pushed a commit to branch 1.6.x
in repository https://gitbox.apache.org/repos/asf/mesos.git

commit 55b0e94f0c8a1896ca079361d89527123faf22c6
Author: Andrei Budnik <[email protected]>
AuthorDate: Fri Sep 21 14:51:24 2018 +0200

    Fixed disconnection while sending acknowledgment to IOSwitchboard.
    
    Previously, an HTTP connection to the IOSwitchboard could be garbage
    collected before the agent sent an acknowledgment to the IOSwitchboard
    via this connection. This patch fixes the issue by keeping a reference
    count to the connection in a lambda callback until disconnection
    occurs.
    
    Review: https://reviews.apache.org/r/68768/
    (cherry picked from commit bfa2bd24780b5c49467b3c23260855e3d8b4c948)
---
 src/slave/http.cpp | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/slave/http.cpp b/src/slave/http.cpp
index 0afdce8..db039bb 100644
--- a/src/slave/http.cpp
+++ b/src/slave/http.cpp
@@ -3098,7 +3098,12 @@ Future<Response> Http::_attachContainerInput(
               // so that the IOSwitchboard process can terminate itself. This 
is
               // a workaround for the problem with dropping outstanding HTTP
               // responses due to a lack of graceful shutdown in libprocess.
-              acknowledgeContainerInputResponse(containerId);
+              acknowledgeContainerInputResponse(containerId)
+                .onFailed([containerId](const string& failure) {
+                  LOG(ERROR) << "Failed to send an acknowledgment to the"
+                             << " IOSwitchboard for container '"
+                             << containerId << "': " << failure;
+              });
             }));
     }));
 }
@@ -3114,6 +3119,13 @@ Future<Response> Http::acknowledgeContainerInputResponse(
       request.url.domain = "";
       request.url.path = "/acknowledge_container_input_response";
 
+      // This is a non Keep-Alive request which means the connection
+      // will be closed when the response is received. Since the
+      // 'Connection' is reference-counted, we must maintain a copy
+      // until the disconnection occurs.
+      connection.disconnected()
+        .onAny([connection]() {});
+
       return connection.send(request);
     });
 }

Reply via email to