aboutsummaryrefslogtreecommitdiff
path: root/tests/utils/adbd-server.h
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-10-21 14:19:54 +0000
committerBileto Bot <ci-train-bot@canonical.com>2016-10-21 14:19:54 +0000
commit3def83e1c5c34f63a3d36c4fff7f99a4d903a70f (patch)
tree337b9695c99dde56b25d6b20a20563adfb82bd41 /tests/utils/adbd-server.h
parent4f079d2faa6dd24f7ccd0566c4820a835fccce6a (diff)
parent7002fc4e6a6496fb5c0d3294540c957787689847 (diff)
downloadayatana-indicator-display-3def83e1c5c34f63a3d36c4fff7f99a4d903a70f.tar.gz
ayatana-indicator-display-3def83e1c5c34f63a3d36c4fff7f99a4d903a70f.tar.bz2
ayatana-indicator-display-3def83e1c5c34f63a3d36c4fff7f99a4d903a70f.zip
Fix test error in adbd-client-test
Approved by: unity-api-1-bot
Diffstat (limited to 'tests/utils/adbd-server.h')
-rw-r--r--tests/utils/adbd-server.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/utils/adbd-server.h b/tests/utils/adbd-server.h
index b574622..585380f 100644
--- a/tests/utils/adbd-server.h
+++ b/tests/utils/adbd-server.h
@@ -38,7 +38,7 @@ public:
GAdbdServer(const std::string& socket_path,
const std::vector<std::string>& requests):
m_requests{requests},
- m_socket_path{socket_path},
+ m_server_socket{create_server_socket(socket_path)},
m_cancellable{g_cancellable_new()},
m_worker_thread{&GAdbdServer::worker_func, this}
{
@@ -50,6 +50,7 @@ public:
g_cancellable_cancel(m_cancellable);
m_worker_thread.join();
g_clear_object(&m_cancellable);
+ g_clear_object(&m_server_socket);
}
const std::vector<std::string> m_requests;
@@ -59,18 +60,14 @@ private:
void worker_func() // runs in worker thread
{
- auto server_socket = create_server_socket(m_socket_path);
auto requests = m_requests;
- GError* error {};
- g_socket_listen (server_socket, &error);
- g_assert_no_error (error);
-
while (!g_cancellable_is_cancelled(m_cancellable) && !requests.empty())
{
// wait for a client connection
g_message("GAdbdServer::Impl::worker_func() calling g_socket_accept()");
- auto client_socket = g_socket_accept(server_socket, m_cancellable, &error);
+ GError* error {};
+ auto client_socket = g_socket_accept(m_server_socket, m_cancellable, &error);
if (error != nullptr) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
g_message("GAdbdServer: Error accepting socket connection: %s", error->message);
@@ -121,8 +118,6 @@ private:
// cleanup
g_clear_object(&client_socket);
}
-
- g_clear_object(&server_socket);
}
// bind to a local domain socket
@@ -139,11 +134,14 @@ private:
g_assert_no_error (error);
g_clear_object (&address);
+ g_socket_listen (socket, &error);
+ g_assert_no_error (error);
+
return socket;
}
- const std::string m_socket_path;
- GCancellable* m_cancellable = nullptr;
+ GSocket* m_server_socket {};
+ GCancellable* m_cancellable {};
std::thread m_worker_thread;
};