1
0
mirror of https://github.com/falk-werner/webfuse synced 2024-10-27 20:34:10 +00:00

fixes eary trigger of is_connected (provider)

This commit is contained in:
Falk Werner 2019-05-07 21:47:10 +02:00
parent b35c78eab6
commit 5fa7e29b5c
3 changed files with 13 additions and 8 deletions

View File

@ -35,6 +35,15 @@ static void wfp_impl_client_protocol_process_request(
json_t * request = json_loadb(message, length, 0, NULL); json_t * request = json_loadb(message, length, 0, NULL);
if (NULL != request) 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 = struct wfp_impl_invokation_context context =
{ {
.provider = &protocol->provider, .provider = &protocol->provider,
@ -84,8 +93,7 @@ static int wfp_impl_client_protocol_callback(
{ {
case LWS_CALLBACK_CLIENT_ESTABLISHED: case LWS_CALLBACK_CLIENT_ESTABLISHED:
wfp_impl_client_protocol_add_filesystem(protocol); wfp_impl_client_protocol_add_filesystem(protocol);
protocol->is_connected = true; // Defer is_connected until response received
protocol->provider.connected(protocol->user_data);
break; break;
case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: case LWS_CALLBACK_CLIENT_CONNECTION_ERROR:
protocol->is_connected = false; protocol->is_connected = false;

View File

@ -22,12 +22,13 @@ public:
client = wfp_client_create(config); client = wfp_client_create(config);
wfp_client_connect(client, url); wfp_client_connect(client, url);
while (!wfp_impl_client_is_connected(client)) while (!wfp_impl_client_is_connected(client))
{ {
wfp_client_service(client, 100); wfp_client_service(client, 100);
} }
thread = std::thread(Run, this); thread = std::thread(Run, this);
webfuse_test::msleep(200);
} }
~Private() ~Private()

View File

@ -15,7 +15,6 @@
#include <jansson.h> #include <jansson.h>
#include "webfuse/core/lws_log.h" #include "webfuse/core/lws_log.h"
#include "msleep.hpp"
#include "die_if.hpp" #include "die_if.hpp"
using webfuse_test::Server; using webfuse_test::Server;
@ -69,7 +68,6 @@ TEST_F(IntegrationTest, HasMountpoint)
TEST_F(IntegrationTest, ProvidesTextFile) TEST_F(IntegrationTest, ProvidesTextFile)
{ {
webfuse_test::msleep(200);
std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt"; std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt";
ASSERT_EXIT({ ASSERT_EXIT({
@ -87,7 +85,6 @@ TEST_F(IntegrationTest, ProvidesTextFile)
TEST_F(IntegrationTest, ReadTextFile) TEST_F(IntegrationTest, ReadTextFile)
{ {
webfuse_test::msleep(200);
std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt"; std::string file_name = std::string(GetBaseDir()) + "/cprovider/default/hello.txt";
ASSERT_EXIT({ ASSERT_EXIT({
@ -109,7 +106,6 @@ TEST_F(IntegrationTest, ReadTextFile)
TEST_F(IntegrationTest, ReadDir) TEST_F(IntegrationTest, ReadDir)
{ {
webfuse_test::msleep(200);
std::string dir_name = std::string(GetBaseDir()) + "/cprovider/default"; std::string dir_name = std::string(GetBaseDir()) + "/cprovider/default";
ASSERT_EXIT({ ASSERT_EXIT({