From 5e7d773d82251d78f1799a62deb0fe76d380fdeb Mon Sep 17 00:00:00 2001 From: Han Pengfei Date: Thu, 1 Feb 2018 14:46:45 +0800 Subject: [PATCH 1/6] Fix missing the release of lock in AdbMessageProcessor when process waiting_for_guest_accept_command. Signed-off-by: Han Pengfei --- src/anbox/qemu/adb_message_processor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/anbox/qemu/adb_message_processor.cpp b/src/anbox/qemu/adb_message_processor.cpp index 24d3bb7..5652be1 100644 --- a/src/anbox/qemu/adb_message_processor.cpp +++ b/src/anbox/qemu/adb_message_processor.cpp @@ -74,10 +74,11 @@ void AdbMessageProcessor::advance_state() { if (state_ == closed_by_host) { host_connector_.reset(); - return; + } else { + wait_for_host_connection(); } - wait_for_host_connection(); + lock_.unlock(); break; case waiting_for_host_connection: messenger_->send(reinterpret_cast(ok_command.data()), From 083b54cc2d81361ef265b810e7b46048374ccba9 Mon Sep 17 00:00:00 2001 From: Han Pengfei Date: Thu, 1 Feb 2018 15:00:23 +0800 Subject: [PATCH 2/6] Just waiting 3 seconds when stop container. If container manager dies before session manager dying, the session manager cannot exit if it waits for all. This patch fix the above issue. Signed-off-by: Han Pengfei --- src/anbox/container/management_api_stub.cpp | 5 ++++- src/anbox/container/management_api_stub.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/anbox/container/management_api_stub.cpp b/src/anbox/container/management_api_stub.cpp index 1806daf..b810db8 100644 --- a/src/anbox/container/management_api_stub.cpp +++ b/src/anbox/container/management_api_stub.cpp @@ -24,6 +24,9 @@ namespace anbox { namespace container { + +const std::chrono::milliseconds ManagementApiStub::stop_waiting_millis{3000}; + ManagementApiStub::ManagementApiStub( const std::shared_ptr &channel) : channel_(channel) {} @@ -75,7 +78,7 @@ void ManagementApiStub::stop_container() { channel_->call_method("stop_container", &message, c->response.get(), google::protobuf::NewCallback(this, &ManagementApiStub::container_stopped, c.get())); - c->wh.wait_for_all(); + c->wh.wait_for_pending(stop_waiting_millis); if (c->response->has_error()) throw std::runtime_error(c->response->error()); } diff --git a/src/anbox/container/management_api_stub.h b/src/anbox/container/management_api_stub.h index 11ebeeb..a883131 100644 --- a/src/anbox/container/management_api_stub.h +++ b/src/anbox/container/management_api_stub.h @@ -56,6 +56,7 @@ class ManagementApiStub : public DoNotCopyOrMove { mutable std::mutex mutex_; std::shared_ptr channel_; + static const std::chrono::milliseconds stop_waiting_millis; }; } // namespace container } // namespace anbox From 15803e186865217689bbc8a15e611f78b033abc4 Mon Sep 17 00:00:00 2001 From: Han Pengfei Date: Thu, 1 Feb 2018 15:00:23 +0800 Subject: [PATCH 3/6] Just waiting 3 seconds when stop container. If container manager dies before session manager dying, the session manager cannot exit if it waits for all. This patch fix the above issue. Signed-off-by: Han Pengfei --- src/anbox/container/management_api_stub.cpp | 7 ++++++- src/anbox/container/management_api_stub.h | 1 + src/anbox/qemu/adb_message_processor.cpp | 5 ++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/anbox/container/management_api_stub.cpp b/src/anbox/container/management_api_stub.cpp index 1806daf..ebe7632 100644 --- a/src/anbox/container/management_api_stub.cpp +++ b/src/anbox/container/management_api_stub.cpp @@ -24,6 +24,9 @@ namespace anbox { namespace container { + +const std::chrono::milliseconds ManagementApiStub::stop_waiting_timeout{3000}; + ManagementApiStub::ManagementApiStub( const std::shared_ptr &channel) : channel_(channel) {} @@ -75,7 +78,9 @@ void ManagementApiStub::stop_container() { channel_->call_method("stop_container", &message, c->response.get(), google::protobuf::NewCallback(this, &ManagementApiStub::container_stopped, c.get())); - c->wh.wait_for_all(); + // If container manager dies before session manager, the session manager + // cannot exit if it waits for all, so just wait for 3 seconds. + c->wh.wait_for_pending(stop_waiting_timeout); if (c->response->has_error()) throw std::runtime_error(c->response->error()); } diff --git a/src/anbox/container/management_api_stub.h b/src/anbox/container/management_api_stub.h index 11ebeeb..e40df94 100644 --- a/src/anbox/container/management_api_stub.h +++ b/src/anbox/container/management_api_stub.h @@ -56,6 +56,7 @@ class ManagementApiStub : public DoNotCopyOrMove { mutable std::mutex mutex_; std::shared_ptr channel_; + static const std::chrono::milliseconds stop_waiting_timeout; }; } // namespace container } // namespace anbox diff --git a/src/anbox/qemu/adb_message_processor.cpp b/src/anbox/qemu/adb_message_processor.cpp index 5652be1..0387088 100644 --- a/src/anbox/qemu/adb_message_processor.cpp +++ b/src/anbox/qemu/adb_message_processor.cpp @@ -72,11 +72,10 @@ void AdbMessageProcessor::advance_state() { // one is established but will not use it until the active one is closed. lock_.lock(); - if (state_ == closed_by_host) { + if (state_ == closed_by_host) host_connector_.reset(); - } else { + else wait_for_host_connection(); - } lock_.unlock(); break; From 04ceffa6b600c38de6764508e216b8f6c9a1e4e5 Mon Sep 17 00:00:00 2001 From: Han Pengfei Date: Fri, 23 Feb 2018 11:03:34 +0800 Subject: [PATCH 4/6] Reset the unlock. Signed-off-by: Han Pengfei --- src/anbox/qemu/adb_message_processor.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/anbox/qemu/adb_message_processor.cpp b/src/anbox/qemu/adb_message_processor.cpp index 0387088..24d3bb7 100644 --- a/src/anbox/qemu/adb_message_processor.cpp +++ b/src/anbox/qemu/adb_message_processor.cpp @@ -72,12 +72,12 @@ void AdbMessageProcessor::advance_state() { // one is established but will not use it until the active one is closed. lock_.lock(); - if (state_ == closed_by_host) + if (state_ == closed_by_host) { host_connector_.reset(); - else - wait_for_host_connection(); + return; + } - lock_.unlock(); + wait_for_host_connection(); break; case waiting_for_host_connection: messenger_->send(reinterpret_cast(ok_command.data()), From 5cc79d9782daf9bec13b3f67c6af5bb6efc6ce35 Mon Sep 17 00:00:00 2001 From: Ondra Pelech Date: Sun, 1 Apr 2018 16:19:28 +0200 Subject: [PATCH 5/6] Use the `z` as print format for `size_t` variable instead of `l` to make it platform independent `l` is a format for `long int`. It accidentally worked on 64 bit architectures, because `long int` has the same length as `size_t` there. It didn't work on 32 bit architectures, where `size_t` is shorter than `long int`. Let's use `z`, because that's the proper format for `size_t` -- it works on any platform. --- src/anbox/qemu/qemud_message_processor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anbox/qemu/qemud_message_processor.cpp b/src/anbox/qemu/qemud_message_processor.cpp index d9ee009..b47f078 100644 --- a/src/anbox/qemu/qemud_message_processor.cpp +++ b/src/anbox/qemu/qemud_message_processor.cpp @@ -70,7 +70,7 @@ void QemudMessageProcessor::process_commands() { void QemudMessageProcessor::send_header(const size_t &size) { char header[header_size + 1]; - std::snprintf(header, header_size + 1, "%04lx", size); + std::snprintf(header, header_size + 1, "%04zx", size); messenger_->send(header, header_size); } From c288083bb3168bbb2440f61fe88a128eaeba7b22 Mon Sep 17 00:00:00 2001 From: misha98857 Date: Tue, 3 Apr 2018 21:54:27 +0400 Subject: [PATCH 6/6] fix GLM error fix this problem: "GLM: GLM_GTX_transform is an experimental extension and may change in the future" --- src/anbox/graphics/emugl/Renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anbox/graphics/emugl/Renderer.cpp b/src/anbox/graphics/emugl/Renderer.cpp index a807131..98d26cc 100644 --- a/src/anbox/graphics/emugl/Renderer.cpp +++ b/src/anbox/graphics/emugl/Renderer.cpp @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +#define GLM_ENABLE_EXPERIMENTAL #include "anbox/graphics/emugl/Renderer.h" #include "anbox/graphics/emugl/DispatchTables.h" #include "anbox/graphics/emugl/RenderThreadInfo.h"