From 5fa7e29b5cca7ca0cb89e5d4f936a38af88f45e9 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Tue, 7 May 2019 21:47:10 +0200 Subject: [PATCH] fixes eary trigger of is_connected (provider) --- lib/webfuse/provider/impl/client_protocol.c | 12 ++++++++++-- test/integration/provider.cc | 3 ++- test/integration/test_integration.cc | 6 +----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/webfuse/provider/impl/client_protocol.c b/lib/webfuse/provider/impl/client_protocol.c index 2bd00d6..cf31a98 100644 --- a/lib/webfuse/provider/impl/client_protocol.c +++ b/lib/webfuse/provider/impl/client_protocol.c @@ -35,6 +35,15 @@ static void wfp_impl_client_protocol_process_request( json_t * request = json_loadb(message, length, 0, NULL); if (NULL != request) { + // FIXME: is_connected should be invoked, when filesystem added + if ((!protocol->is_connected) && (NULL != json_object_get(request, "result"))) + { + protocol->is_connected = true; + protocol->provider.connected(protocol->user_data); + } + + + struct wfp_impl_invokation_context context = { .provider = &protocol->provider, @@ -84,8 +93,7 @@ static int wfp_impl_client_protocol_callback( { case LWS_CALLBACK_CLIENT_ESTABLISHED: wfp_impl_client_protocol_add_filesystem(protocol); - protocol->is_connected = true; - protocol->provider.connected(protocol->user_data); + // Defer is_connected until response received break; case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: protocol->is_connected = false; diff --git a/test/integration/provider.cc b/test/integration/provider.cc index 25ada5b..3ee4285 100644 --- a/test/integration/provider.cc +++ b/test/integration/provider.cc @@ -22,12 +22,13 @@ public: client = wfp_client_create(config); wfp_client_connect(client, url); - while (!wfp_impl_client_is_connected(client)) + while (!wfp_impl_client_is_connected(client)) { wfp_client_service(client, 100); } thread = std::thread(Run, this); + webfuse_test::msleep(200); } ~Private() diff --git a/test/integration/test_integration.cc b/test/integration/test_integration.cc index 33167f9..8bd21c6 100644 --- a/test/integration/test_integration.cc +++ b/test/integration/test_integration.cc @@ -15,7 +15,6 @@ #include #include "webfuse/core/lws_log.h" -#include "msleep.hpp" #include "die_if.hpp" using webfuse_test::Server; @@ -69,7 +68,6 @@ TEST_F(IntegrationTest, HasMountpoint) TEST_F(IntegrationTest, ProvidesTextFile) { - webfuse_test::msleep(200); std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt"; ASSERT_EXIT({ @@ -87,7 +85,6 @@ TEST_F(IntegrationTest, ProvidesTextFile) TEST_F(IntegrationTest, ReadTextFile) { - webfuse_test::msleep(200); std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt"; ASSERT_EXIT({ @@ -108,8 +105,7 @@ TEST_F(IntegrationTest, ReadTextFile) } TEST_F(IntegrationTest, ReadDir) -{ - webfuse_test::msleep(200); +{ std::string dir_name = std::string(GetBaseDir()) + "/cprovider/default"; ASSERT_EXIT({