This is an automated email from the ASF dual-hosted git repository. alexr pushed a commit to branch 1.7.x in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 021a8f4de1ad65167946548e3ecfa74d8e41e9c5 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 2253ccc..51bc074 100644 --- a/src/slave/http.cpp +++ b/src/slave/http.cpp @@ -3147,7 +3147,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; + }); })); })); } @@ -3163,6 +3168,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); }); }
