1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2026-03-02 04:09:18 +00:00

chore: cleanup jsonrpc library

This commit is contained in:
Falk Werner
2020-02-29 02:32:03 +01:00
parent e3a3427ca8
commit 69a1faaa3f
38 changed files with 792 additions and 345 deletions

View File

@@ -11,7 +11,7 @@ struct jsonrpc_proxy * wf_impl_operations_context_get_proxy(
struct wf_impl_session * session = context->session;
if (NULL != session)
{
proxy = &session->rpc;
proxy = session->rpc;
}
return proxy;

View File

@@ -11,6 +11,7 @@
#include "webfuse/adapter/impl/credentials.h"
#include "jsonrpc/request.h"
#include "webfuse/adapter/impl/uuid_mountpoint_factory.h"
#include "webfuse/core/status_intern.h"
static int wf_impl_server_protocol_callback(
struct lws * wsi,
@@ -42,7 +43,7 @@ static int wf_impl_server_protocol_callback(
&protocol->authenticators,
&protocol->mountpoint_factory,
&protocol->timeout_manager,
&protocol->server);
protocol->server);
if (NULL != session)
{
@@ -159,7 +160,7 @@ static void wf_impl_server_protocol_authenticate(
}
else
{
jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED);
jsonrpc_respond_error(request, WF_BAD_ACCESS_DENIED, wf_status_tostring(WF_BAD_ACCESS_DENIED));
}
}
@@ -222,7 +223,7 @@ static void wf_impl_server_protocol_add_filesystem(
}
else
{
jsonrpc_respond_error(request, status);
jsonrpc_respond_error(request, status, wf_status_tostring(status));
}
@@ -240,9 +241,9 @@ void wf_impl_server_protocol_init(
wf_impl_session_manager_init(&protocol->session_manager);
wf_impl_authenticators_init(&protocol->authenticators);
jsonrpc_server_init(&protocol->server);
jsonrpc_server_add(&protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
jsonrpc_server_add(&protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
protocol->server = jsonrpc_server_create();
jsonrpc_server_add(protocol->server, "authenticate", &wf_impl_server_protocol_authenticate, protocol);
jsonrpc_server_add(protocol->server, "add_filesystem", &wf_impl_server_protocol_add_filesystem, protocol);
}
void wf_impl_server_protocol_cleanup(
@@ -250,7 +251,7 @@ void wf_impl_server_protocol_cleanup(
{
protocol->is_operational = false;
jsonrpc_server_cleanup(&protocol->server);
jsonrpc_server_dispose(protocol->server);
wf_impl_timeout_manager_cleanup(&protocol->timeout_manager);
wf_impl_authenticators_cleanup(&protocol->authenticators);
wf_impl_session_manager_cleanup(&protocol->session_manager);

View File

@@ -25,7 +25,7 @@ struct wf_server_protocol
struct wf_impl_authenticators authenticators;
struct wf_impl_mountpoint_factory mountpoint_factory;
struct wf_impl_session_manager session_manager;
struct jsonrpc_server server;
struct jsonrpc_server * server;
bool is_operational;
};

View File

@@ -59,7 +59,7 @@ struct wf_impl_session * wf_impl_session_create(
session->authenticators = authenticators;
session->server = server;
session->mountpoint_factory = mountpoint_factory;
jsonrpc_proxy_init(&session->rpc, timeout_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
session->rpc = jsonrpc_proxy_create(timeout_manager, WF_DEFAULT_TIMEOUT, &wf_impl_session_send, session);
wf_slist_init(&session->messages);
}
@@ -83,15 +83,10 @@ static void wf_impl_session_dispose_filesystems(
void wf_impl_session_dispose(
struct wf_impl_session * session)
{
jsonrpc_proxy_cleanup(&session->rpc);
jsonrpc_proxy_dispose(session->rpc);
wf_message_queue_cleanup(&session->messages);
wf_impl_session_dispose_filesystems(&session->filesystems);
session->is_authenticated = false;
session->wsi = NULL;
session->authenticators = NULL;
session->mountpoint_factory = NULL;
session->server = NULL;
free(session);
}
@@ -161,7 +156,7 @@ void wf_impl_session_receive(
{
if (jsonrpc_is_response(message))
{
jsonrpc_proxy_onresult(&session->rpc, message);
jsonrpc_proxy_onresult(session->rpc, message);
}
else if (jsonrpc_is_request(message))
{

View File

@@ -36,7 +36,7 @@ struct wf_impl_session
struct wf_impl_authenticators * authenticators;
struct wf_impl_mountpoint_factory * mountpoint_factory;
struct jsonrpc_server * server;
struct jsonrpc_proxy rpc;
struct jsonrpc_proxy * rpc;
struct wf_slist filesystems;
};