mirror of
				https://github.com/falk-werner/webfuse
				synced 2025-06-13 12:54:15 +00:00 
			
		
		
		
	renames jsonrpc server to jsonrpc proxy
This commit is contained in:
		
							parent
							
								
									36fcc84588
								
							
						
					
					
						commit
						4a90a24500
					
				@ -84,7 +84,7 @@ add_library(webfuse-adapter-static STATIC
 | 
			
		||||
	lib/webfuse/adapter/impl/operation/open.c
 | 
			
		||||
	lib/webfuse/adapter/impl/operation/close.c
 | 
			
		||||
	lib/webfuse/adapter/impl/operation/read.c
 | 
			
		||||
	lib/webfuse/adapter/impl/jsonrpc/server.c
 | 
			
		||||
	lib/webfuse/adapter/impl/jsonrpc/proxy.c
 | 
			
		||||
	lib/webfuse/adapter/impl/jsonrpc/request.c
 | 
			
		||||
	lib/webfuse/adapter/impl/jsonrpc/response.c
 | 
			
		||||
	lib/webfuse/adapter/impl/jsonrpc/util.c
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#include "webfuse/adapter/impl/filesystem.h"
 | 
			
		||||
#include "webfuse/adapter/impl/operations.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
#include <string.h>
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										140
									
								
								lib/webfuse/adapter/impl/jsonrpc/proxy.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										140
									
								
								lib/webfuse/adapter/impl/jsonrpc/proxy.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,140 @@
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/request.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
 | 
			
		||||
 | 
			
		||||
#define WF_DEFAULT_TIMEOUT (10 * 1000)
 | 
			
		||||
 | 
			
		||||
static void wf_impl_jsonrpc_proxy_timeout(
 | 
			
		||||
    struct wf_impl_timer * timer)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy = timer->user_data;
 | 
			
		||||
 | 
			
		||||
    if (proxy->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        wf_impl_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
 | 
			
		||||
        void * user_data = proxy->request.user_data;
 | 
			
		||||
 | 
			
		||||
        proxy->request.is_pending = false;
 | 
			
		||||
        proxy->request.id = 0;
 | 
			
		||||
        proxy->request.user_data = NULL;
 | 
			
		||||
        proxy->request.finished = NULL;
 | 
			
		||||
        wf_impl_timer_cancel(&proxy->request.timer);
 | 
			
		||||
 | 
			
		||||
        finished(user_data, WF_BAD_TIMEOUT, NULL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_proxy_init(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
    struct wf_impl_timeout_manager * timeout_manager,
 | 
			
		||||
    wf_impl_jsonrpc_proxy_send_fn * send,
 | 
			
		||||
    void * user_data)
 | 
			
		||||
{
 | 
			
		||||
    proxy->send = send;
 | 
			
		||||
    proxy->user_data = user_data;
 | 
			
		||||
    proxy->request.is_pending = false;
 | 
			
		||||
    
 | 
			
		||||
    wf_impl_timer_init(&proxy->request.timer, timeout_manager);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_proxy_cleanup(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy)
 | 
			
		||||
{
 | 
			
		||||
    wf_impl_timer_cleanup(&proxy->request.timer);
 | 
			
		||||
 | 
			
		||||
    if (proxy->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        proxy->request.finished(proxy->request.user_data, WF_BAD, NULL);
 | 
			
		||||
        proxy->request.is_pending = false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_proxy_invoke(
 | 
			
		||||
	struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
	wf_impl_jsonrpc_proxy_finished_fn * finished,
 | 
			
		||||
	void * user_data,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
    if (!proxy->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        proxy->request.is_pending = true;
 | 
			
		||||
        proxy->request.finished = finished;
 | 
			
		||||
        proxy->request.user_data = user_data;
 | 
			
		||||
        proxy->request.id = 42;
 | 
			
		||||
        wf_impl_timer_start(&proxy->request.timer, wf_impl_timepoint_in_msec(WF_DEFAULT_TIMEOUT), 
 | 
			
		||||
                &wf_impl_jsonrpc_proxy_timeout, proxy);
 | 
			
		||||
        
 | 
			
		||||
        va_list args;
 | 
			
		||||
        va_start(args, param_info);
 | 
			
		||||
        json_t * request = wf_impl_jsonrpc_request_create(method_name, proxy->request.id, param_info, args);
 | 
			
		||||
        va_end(args);
 | 
			
		||||
        if (NULL != request)
 | 
			
		||||
        {
 | 
			
		||||
            if (!proxy->send(request, proxy->user_data))
 | 
			
		||||
            {
 | 
			
		||||
                proxy->request.is_pending = false;
 | 
			
		||||
                proxy->request.finished = NULL;
 | 
			
		||||
                proxy->request.user_data = NULL;
 | 
			
		||||
                proxy->request.id = 0;
 | 
			
		||||
                wf_impl_timer_cancel(&proxy->request.timer);
 | 
			
		||||
 | 
			
		||||
                finished(user_data, WF_BAD, NULL);
 | 
			
		||||
            }
 | 
			
		||||
            json_decref(request);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        finished(user_data, WF_BAD_BUSY, NULL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_notify(
 | 
			
		||||
	struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
)
 | 
			
		||||
{            
 | 
			
		||||
    va_list args;
 | 
			
		||||
    va_start(args, param_info);
 | 
			
		||||
    json_t * request = wf_impl_jsonrpc_request_create(method_name, 0, param_info, args);
 | 
			
		||||
    va_end(args);
 | 
			
		||||
    if (NULL != request)
 | 
			
		||||
    {
 | 
			
		||||
        proxy->send(request, proxy->user_data);
 | 
			
		||||
        json_decref(request);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_proxy_onresult(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
    char const * message,
 | 
			
		||||
    size_t length)
 | 
			
		||||
{
 | 
			
		||||
	struct wf_impl_jsonrpc_response response;
 | 
			
		||||
	wf_impl_jsonrpc_response_init(&response, message, length);
 | 
			
		||||
 | 
			
		||||
    if ((proxy->request.is_pending) && (response.id == proxy->request.id))
 | 
			
		||||
    {
 | 
			
		||||
        wf_impl_jsonrpc_proxy_finished_fn * finished = proxy->request.finished;
 | 
			
		||||
        void * user_data = proxy->request.user_data;
 | 
			
		||||
 | 
			
		||||
        proxy->request.is_pending = false;
 | 
			
		||||
        proxy->request.id = 0;
 | 
			
		||||
        proxy->request.user_data = NULL;
 | 
			
		||||
        proxy->request.finished = NULL;
 | 
			
		||||
        wf_impl_timer_cancel(&proxy->request.timer);
 | 
			
		||||
 | 
			
		||||
        finished(user_data, response.status, response.result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    wf_impl_jsonrpc_response_cleanup(&response);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
#ifndef WF_ADAPTER_IMPL_JSONRPC_SERVER_H
 | 
			
		||||
#define WF_ADAPTER_IMPL_JSONRPC_SERVER_H
 | 
			
		||||
#ifndef WF_ADAPTER_IMPL_JSONRPC_PROXY_H
 | 
			
		||||
#define WF_ADAPTER_IMPL_JSONRPC_PROXY_H
 | 
			
		||||
 | 
			
		||||
#ifndef __cplusplus
 | 
			
		||||
#include <stdarg.h>
 | 
			
		||||
@ -20,12 +20,12 @@ using std::size_t;
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
typedef bool wf_impl_jsonrpc_server_send_fn(
 | 
			
		||||
typedef bool wf_impl_jsonrpc_proxy_send_fn(
 | 
			
		||||
	json_t * request,
 | 
			
		||||
    void * user_data);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
typedef void wf_impl_jsonrpc_server_finished_fn(
 | 
			
		||||
typedef void wf_impl_jsonrpc_proxy_finished_fn(
 | 
			
		||||
	void * user_data,
 | 
			
		||||
	wf_status status,
 | 
			
		||||
	struct json_t const * result);
 | 
			
		||||
@ -34,46 +34,46 @@ typedef void wf_impl_jsonrpc_server_finished_fn(
 | 
			
		||||
struct wf_impl_jsonrpc_request
 | 
			
		||||
{
 | 
			
		||||
    bool is_pending;
 | 
			
		||||
    wf_impl_jsonrpc_server_finished_fn * finished;
 | 
			
		||||
    wf_impl_jsonrpc_proxy_finished_fn * finished;
 | 
			
		||||
    void * user_data;
 | 
			
		||||
    int id;
 | 
			
		||||
    struct wf_impl_timer timer;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
struct wf_impl_jsonrpc_server
 | 
			
		||||
struct wf_impl_jsonrpc_proxy
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_jsonrpc_request request;
 | 
			
		||||
    wf_impl_jsonrpc_server_send_fn * send;
 | 
			
		||||
    wf_impl_jsonrpc_proxy_send_fn * send;
 | 
			
		||||
    void * user_data;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_init(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_init(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
    struct wf_impl_timeout_manager * manager,
 | 
			
		||||
    wf_impl_jsonrpc_server_send_fn * send,
 | 
			
		||||
    wf_impl_jsonrpc_proxy_send_fn * send,
 | 
			
		||||
    void * user_data);
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_cleanup(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server);
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_cleanup(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy);
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_invoke(
 | 
			
		||||
	struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
	wf_impl_jsonrpc_server_finished_fn * finished,
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_invoke(
 | 
			
		||||
	struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
	wf_impl_jsonrpc_proxy_finished_fn * finished,
 | 
			
		||||
	void * user_data,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_notify(
 | 
			
		||||
	struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_notify(
 | 
			
		||||
	struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_onresult(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
extern void wf_impl_jsonrpc_proxy_onresult(
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy,
 | 
			
		||||
    char const * message,
 | 
			
		||||
    size_t length);
 | 
			
		||||
 | 
			
		||||
@ -1,140 +0,0 @@
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include <string.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/request.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/response.h"
 | 
			
		||||
 | 
			
		||||
#define WF_DEFAULT_TIMEOUT (10 * 1000)
 | 
			
		||||
 | 
			
		||||
static void wf_impl_jsonrpc_server_timeout(
 | 
			
		||||
    struct wf_impl_timer * timer)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server = timer->user_data;
 | 
			
		||||
 | 
			
		||||
    if (server->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        wf_impl_jsonrpc_server_finished_fn * finished = server->request.finished;
 | 
			
		||||
        void * user_data = server->request.user_data;
 | 
			
		||||
 | 
			
		||||
        server->request.is_pending = false;
 | 
			
		||||
        server->request.id = 0;
 | 
			
		||||
        server->request.user_data = NULL;
 | 
			
		||||
        server->request.finished = NULL;
 | 
			
		||||
        wf_impl_timer_cancel(&server->request.timer);
 | 
			
		||||
 | 
			
		||||
        finished(user_data, WF_BAD_TIMEOUT, NULL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_server_init(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
    struct wf_impl_timeout_manager * timeout_manager,
 | 
			
		||||
    wf_impl_jsonrpc_server_send_fn * send,
 | 
			
		||||
    void * user_data)
 | 
			
		||||
{
 | 
			
		||||
    server->send = send;
 | 
			
		||||
    server->user_data = user_data;
 | 
			
		||||
    server->request.is_pending = false;
 | 
			
		||||
    
 | 
			
		||||
    wf_impl_timer_init(&server->request.timer, timeout_manager);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_server_cleanup(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server)
 | 
			
		||||
{
 | 
			
		||||
    wf_impl_timer_cleanup(&server->request.timer);
 | 
			
		||||
 | 
			
		||||
    if (server->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        server->request.finished(server->request.user_data, WF_BAD, NULL);
 | 
			
		||||
        server->request.is_pending = false;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_server_invoke(
 | 
			
		||||
	struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
	wf_impl_jsonrpc_server_finished_fn * finished,
 | 
			
		||||
	void * user_data,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
)
 | 
			
		||||
{
 | 
			
		||||
    if (!server->request.is_pending)
 | 
			
		||||
    {
 | 
			
		||||
        server->request.is_pending = true;
 | 
			
		||||
        server->request.finished = finished;
 | 
			
		||||
        server->request.user_data = user_data;
 | 
			
		||||
        server->request.id = 42;
 | 
			
		||||
        wf_impl_timer_start(&server->request.timer, wf_impl_timepoint_in_msec(WF_DEFAULT_TIMEOUT), 
 | 
			
		||||
                &wf_impl_jsonrpc_server_timeout, server);
 | 
			
		||||
        
 | 
			
		||||
        va_list args;
 | 
			
		||||
        va_start(args, param_info);
 | 
			
		||||
        json_t * request = wf_impl_jsonrpc_request_create(method_name, server->request.id, param_info, args);
 | 
			
		||||
        va_end(args);
 | 
			
		||||
        if (NULL != request)
 | 
			
		||||
        {
 | 
			
		||||
            if (!server->send(request, server->user_data))
 | 
			
		||||
            {
 | 
			
		||||
                server->request.is_pending = false;
 | 
			
		||||
                server->request.finished = NULL;
 | 
			
		||||
                server->request.user_data = NULL;
 | 
			
		||||
                server->request.id = 0;
 | 
			
		||||
                wf_impl_timer_cancel(&server->request.timer);
 | 
			
		||||
 | 
			
		||||
                finished(user_data, WF_BAD, NULL);
 | 
			
		||||
            }
 | 
			
		||||
            json_decref(request);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        finished(user_data, WF_BAD_BUSY, NULL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_jsonrpc_server_notify(
 | 
			
		||||
	struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
	char const * method_name,
 | 
			
		||||
	char const * param_info,
 | 
			
		||||
	...
 | 
			
		||||
)
 | 
			
		||||
{            
 | 
			
		||||
    va_list args;
 | 
			
		||||
    va_start(args, param_info);
 | 
			
		||||
    json_t * request = wf_impl_jsonrpc_request_create(method_name, 0, param_info, args);
 | 
			
		||||
    va_end(args);
 | 
			
		||||
    if (NULL != request)
 | 
			
		||||
    {
 | 
			
		||||
        server->send(request, server->user_data);
 | 
			
		||||
        json_decref(request);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void wf_impl_jsonrpc_server_onresult(
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server,
 | 
			
		||||
    char const * message,
 | 
			
		||||
    size_t length)
 | 
			
		||||
{
 | 
			
		||||
	struct wf_impl_jsonrpc_response response;
 | 
			
		||||
	wf_impl_jsonrpc_response_init(&response, message, length);
 | 
			
		||||
 | 
			
		||||
    if ((server->request.is_pending) && (response.id == server->request.id))
 | 
			
		||||
    {
 | 
			
		||||
        wf_impl_jsonrpc_server_finished_fn * finished = server->request.finished;
 | 
			
		||||
        void * user_data = server->request.user_data;
 | 
			
		||||
 | 
			
		||||
        server->request.is_pending = false;
 | 
			
		||||
        server->request.id = 0;
 | 
			
		||||
        server->request.user_data = NULL;
 | 
			
		||||
        server->request.finished = NULL;
 | 
			
		||||
        wf_impl_timer_cancel(&server->request.timer);
 | 
			
		||||
 | 
			
		||||
        finished(user_data, response.status, response.result);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    wf_impl_jsonrpc_response_cleanup(&response);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <jansson.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/core/util.h"
 | 
			
		||||
 | 
			
		||||
void wf_impl_operation_close(
 | 
			
		||||
@ -13,12 +13,12 @@ void wf_impl_operation_close(
 | 
			
		||||
	struct fuse_file_info * file_info)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, inode);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, inode);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
		int handle = (int) (file_info->fh & INT_MAX);
 | 
			
		||||
		wf_impl_jsonrpc_server_notify(rpc, "close", "iii", inode, handle, file_info->flags);
 | 
			
		||||
		wf_impl_jsonrpc_proxy_notify(rpc, "close", "iii", inode, handle, file_info->flags);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	fuse_reply_err(request, 0);
 | 
			
		||||
 | 
			
		||||
@ -7,7 +7,7 @@
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <unistd.h> 
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/util.h"
 | 
			
		||||
#include "webfuse/core/util.h"
 | 
			
		||||
 | 
			
		||||
@ -81,7 +81,7 @@ void wf_impl_operation_getattr (
 | 
			
		||||
{
 | 
			
		||||
    struct fuse_ctx const * context = fuse_req_ctx(request);
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, inode);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, inode);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
@ -91,7 +91,7 @@ void wf_impl_operation_getattr (
 | 
			
		||||
		getattr_context->gid = context->gid;
 | 
			
		||||
		getattr_context->timeout = user_data->timeout;
 | 
			
		||||
 | 
			
		||||
		wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "i", inode);
 | 
			
		||||
		wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_getattr_finished, getattr_context, "getattr", "i", inode);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
@ -10,7 +10,7 @@
 | 
			
		||||
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/util.h"
 | 
			
		||||
#include "webfuse/core/util.h"
 | 
			
		||||
 | 
			
		||||
@ -90,7 +90,7 @@ void wf_impl_operation_lookup (
 | 
			
		||||
{
 | 
			
		||||
    struct fuse_ctx const * context = fuse_req_ctx(request);
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, parent);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, parent);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
@ -100,7 +100,7 @@ void wf_impl_operation_lookup (
 | 
			
		||||
		lookup_context->gid = context->gid;
 | 
			
		||||
		lookup_context->timeout = user_data->timeout;
 | 
			
		||||
 | 
			
		||||
		wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "is", (int) (parent & INT_MAX), name);
 | 
			
		||||
		wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_lookup_finished, lookup_context, "lookup", "is", (int) (parent & INT_MAX), name);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
#include <errno.h>
 | 
			
		||||
#include <jansson.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/core/util.h"
 | 
			
		||||
#include "webfuse/core/status.h"
 | 
			
		||||
 | 
			
		||||
@ -47,11 +47,11 @@ void wf_impl_operation_open(
 | 
			
		||||
	struct fuse_file_info * file_info)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, inode);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, inode);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
		wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "ii", inode, file_info->flags);
 | 
			
		||||
		wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_open_finished, request, "open", "ii", inode, file_info->flags);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
@ -6,7 +6,7 @@
 | 
			
		||||
#include <jansson.h>
 | 
			
		||||
#include <libwebsockets.h>
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
 | 
			
		||||
#define WF_MAX_READ_LENGTH 4096
 | 
			
		||||
 | 
			
		||||
@ -87,13 +87,13 @@ void wf_impl_operation_read(
 | 
			
		||||
	struct fuse_file_info * file_info)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, inode);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, inode);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
		int const length = (size <= WF_MAX_READ_LENGTH) ? (int) size : WF_MAX_READ_LENGTH;
 | 
			
		||||
		int handle = (file_info->fh & INT_MAX);
 | 
			
		||||
		wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "iiii", inode, handle, (int) offset, length);
 | 
			
		||||
		wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_read_finished, request, "read", "iiii", inode, handle, (int) offset, length);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@
 | 
			
		||||
#include <sys/stat.h>
 | 
			
		||||
#include <unistd.h> 
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/core/util.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -137,7 +137,7 @@ void wf_impl_operation_readdir (
 | 
			
		||||
	struct fuse_file_info * WF_UNUSED_PARAM(file_info))
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_operations_context * user_data = fuse_req_userdata(request);
 | 
			
		||||
    struct wf_impl_jsonrpc_server * rpc = wf_impl_operations_context_get_server(user_data, inode);
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * rpc = wf_impl_operations_context_get_proxy(user_data, inode);
 | 
			
		||||
 | 
			
		||||
	if (NULL != rpc)
 | 
			
		||||
	{
 | 
			
		||||
@ -146,7 +146,7 @@ void wf_impl_operation_readdir (
 | 
			
		||||
	readdir_context->size = size;
 | 
			
		||||
	readdir_context->offset = offset;
 | 
			
		||||
 | 
			
		||||
	wf_impl_jsonrpc_server_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "i", inode);
 | 
			
		||||
	wf_impl_jsonrpc_proxy_invoke(rpc, &wf_impl_operation_readdir_finished, readdir_context, "readdir", "i", inode);
 | 
			
		||||
	}
 | 
			
		||||
	else
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
@ -3,18 +3,18 @@
 | 
			
		||||
#include "webfuse/adapter/impl/session.h"
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
struct wf_impl_jsonrpc_server * wf_impl_operations_context_get_server(
 | 
			
		||||
struct wf_impl_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
 | 
			
		||||
	struct wf_impl_operations_context * context,
 | 
			
		||||
	fuse_ino_t inode)
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_jsonrpc_server * server = NULL;
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy * proxy = NULL;
 | 
			
		||||
 | 
			
		||||
    struct wf_impl_session_manager * session_manger = context->session_manager;
 | 
			
		||||
    struct wf_impl_session * session = wf_impl_session_manager_get_by_inode(session_manger, inode);
 | 
			
		||||
    if (NULL != session)
 | 
			
		||||
    {
 | 
			
		||||
        server = &session->rpc;
 | 
			
		||||
        proxy = &session->rpc;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return server;
 | 
			
		||||
    return proxy;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
struct wf_impl_session_manager;
 | 
			
		||||
struct wf_impl_jsonrpc_proxy;
 | 
			
		||||
 | 
			
		||||
struct wf_impl_operations_context
 | 
			
		||||
{
 | 
			
		||||
@ -47,7 +48,7 @@ extern void wf_impl_operation_read(
 | 
			
		||||
	fuse_ino_t ino, size_t size, off_t off,
 | 
			
		||||
			struct fuse_file_info *fi);
 | 
			
		||||
 | 
			
		||||
extern struct wf_impl_jsonrpc_server * wf_impl_operations_context_get_server(
 | 
			
		||||
extern struct wf_impl_jsonrpc_proxy * wf_impl_operations_context_get_proxy(
 | 
			
		||||
	struct wf_impl_operations_context * context,
 | 
			
		||||
	fuse_ino_t inode);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
#define WF_ADAPTER_IMPL_SERVER_PROTOCOL_H
 | 
			
		||||
 | 
			
		||||
#include "webfuse/adapter/impl/filesystem.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
#include "webfuse/adapter/impl/time/timeout_manager.h"
 | 
			
		||||
#include "webfuse/adapter/impl/authenticators.h"
 | 
			
		||||
#include "webfuse/adapter/impl/session_manager.h"
 | 
			
		||||
@ -18,7 +18,7 @@ struct wf_server_protocol
 | 
			
		||||
{
 | 
			
		||||
    struct wf_impl_timeout_manager timeout_manager;
 | 
			
		||||
    struct wf_impl_filesystem filesystem;
 | 
			
		||||
    struct wf_impl_jsonrpc_server rpc;
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy rpc;
 | 
			
		||||
    struct wf_impl_authenticators authenticators;
 | 
			
		||||
    struct wf_impl_session_manager session_manager;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,7 @@
 | 
			
		||||
#include "webfuse/adapter/impl/authenticators.h"
 | 
			
		||||
#include "webfuse/core/message_queue.h"
 | 
			
		||||
#include "webfuse/core/message.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
 | 
			
		||||
#include <libwebsockets.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
@ -40,14 +40,14 @@ void wf_impl_session_init(
 | 
			
		||||
    session->wsi = wsi;
 | 
			
		||||
    session->is_authenticated = false;
 | 
			
		||||
    session->authenticators = authenticators;
 | 
			
		||||
    wf_impl_jsonrpc_server_init(&session->rpc, timeout_manager, &wf_impl_session_send, session);
 | 
			
		||||
    wf_impl_jsonrpc_proxy_init(&session->rpc, timeout_manager, &wf_impl_session_send, session);
 | 
			
		||||
    wf_message_queue_init(&session->queue);
 | 
			
		||||
 }
 | 
			
		||||
 | 
			
		||||
void wf_impl_session_cleanup(
 | 
			
		||||
    struct wf_impl_session * session)
 | 
			
		||||
{
 | 
			
		||||
    wf_impl_jsonrpc_server_cleanup(&session->rpc);
 | 
			
		||||
    wf_impl_jsonrpc_proxy_cleanup(&session->rpc);
 | 
			
		||||
    wf_message_queue_cleanup(&session->queue);
 | 
			
		||||
    session->is_authenticated = false;
 | 
			
		||||
    session->wsi = NULL;
 | 
			
		||||
@ -83,5 +83,5 @@ void wf_impl_session_receive(
 | 
			
		||||
    char const * data,
 | 
			
		||||
    size_t length)
 | 
			
		||||
{
 | 
			
		||||
    wf_impl_jsonrpc_server_onresult(&session->rpc, data, length);
 | 
			
		||||
    wf_impl_jsonrpc_proxy_onresult(&session->rpc, data, length);
 | 
			
		||||
}
 | 
			
		||||
@ -10,7 +10,7 @@ using std::size_t;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#include "webfuse/core/message_queue.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/server.h"
 | 
			
		||||
#include "webfuse/adapter/impl/jsonrpc/proxy.h"
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C"
 | 
			
		||||
@ -29,7 +29,7 @@ struct wf_impl_session
 | 
			
		||||
    bool is_authenticated;
 | 
			
		||||
    struct wf_message_queue queue;
 | 
			
		||||
    struct wf_impl_authenticators * authenticators;
 | 
			
		||||
    struct wf_impl_jsonrpc_server rpc;
 | 
			
		||||
    struct wf_impl_jsonrpc_proxy rpc;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
extern void wf_impl_session_init(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user