mirror of
https://github.com/falk-werner/webfuse-provider
synced 2024-10-27 20:44:10 +00:00
removes shutdown method (#27)
This commit is contained in:
parent
9130f00289
commit
09df34debc
@ -11,6 +11,7 @@
|
|||||||
#include <webfuse_adapter.h>
|
#include <webfuse_adapter.h>
|
||||||
#include <userdb.h>
|
#include <userdb.h>
|
||||||
|
|
||||||
|
#define SERVICE_TIMEOUT (1 * 1000)
|
||||||
|
|
||||||
struct args
|
struct args
|
||||||
{
|
{
|
||||||
@ -19,7 +20,7 @@ struct args
|
|||||||
bool show_help;
|
bool show_help;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct wf_server * server;
|
static bool shutdown_requested = false;
|
||||||
|
|
||||||
static void show_help(void)
|
static void show_help(void)
|
||||||
{
|
{
|
||||||
@ -150,7 +151,7 @@ static void on_interrupt(int signal_id)
|
|||||||
{
|
{
|
||||||
(void) signal_id;
|
(void) signal_id;
|
||||||
|
|
||||||
wf_server_shutdown(server);
|
shutdown_requested = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
@ -167,10 +168,14 @@ int main(int argc, char * argv[])
|
|||||||
if (!args.show_help)
|
if (!args.show_help)
|
||||||
{
|
{
|
||||||
signal(SIGINT, on_interrupt);
|
signal(SIGINT, on_interrupt);
|
||||||
server = wf_server_create(args.config);
|
struct wf_server * server = wf_server_create(args.config);
|
||||||
if (NULL != server)
|
if (NULL != server)
|
||||||
{
|
{
|
||||||
wf_server_run(server);
|
while (!shutdown_requested)
|
||||||
|
{
|
||||||
|
wf_server_service(server, SERVICE_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
wf_server_dispose(server);
|
wf_server_dispose(server);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "webfuse_provider.h"
|
#include "webfuse_provider.h"
|
||||||
|
|
||||||
|
#define SERVICE_TIMEOUT (1 * 1000)
|
||||||
|
|
||||||
struct config
|
struct config
|
||||||
{
|
{
|
||||||
char * url;
|
char * url;
|
||||||
@ -314,13 +316,12 @@ static void fs_read(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wfp_client * client;
|
static volatile bool shutdown_requested = false;
|
||||||
|
|
||||||
static void on_interrupt(int signal_id)
|
static void on_interrupt(int signal_id)
|
||||||
{
|
{
|
||||||
(void) signal_id;
|
(void) signal_id;
|
||||||
|
shutdown_requested = true;
|
||||||
wfp_client_shutdown(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
@ -362,10 +363,13 @@ int main(int argc, char* argv[])
|
|||||||
wfp_client_config_set_onopen(config.client_config, &fs_open);
|
wfp_client_config_set_onopen(config.client_config, &fs_open);
|
||||||
wfp_client_config_set_onread(config.client_config, &fs_read);
|
wfp_client_config_set_onread(config.client_config, &fs_read);
|
||||||
|
|
||||||
client = wfp_client_create(config.client_config);
|
struct wfp_client * client = wfp_client_create(config.client_config);
|
||||||
wfp_client_connect(client, config.url);
|
wfp_client_connect(client, config.url);
|
||||||
|
|
||||||
wfp_client_run(client);
|
while (!shutdown_requested)
|
||||||
|
{
|
||||||
|
wfp_client_service(client, SERVICE_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
wfp_client_dispose(client);
|
wfp_client_dispose(client);
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,9 @@ extern WF_API struct wf_server * wf_server_create(
|
|||||||
extern WF_API void wf_server_dispose(
|
extern WF_API void wf_server_dispose(
|
||||||
struct wf_server * server);
|
struct wf_server * server);
|
||||||
|
|
||||||
extern WF_API void wf_server_run(
|
extern WF_API void wf_server_service(
|
||||||
struct wf_server * server);
|
struct wf_server * server,
|
||||||
|
int timeout_ms);
|
||||||
extern WF_API void wf_server_shutdown(
|
|
||||||
struct wf_server * server);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,9 @@ extern WFP_API void wfp_client_disconnect(
|
|||||||
extern WFP_API void wfp_client_dispose(
|
extern WFP_API void wfp_client_dispose(
|
||||||
struct wfp_client * client);
|
struct wfp_client * client);
|
||||||
|
|
||||||
extern WFP_API void wfp_client_run(
|
extern WFP_API void wfp_client_service(
|
||||||
struct wfp_client * client);
|
struct wfp_client * client,
|
||||||
|
int timeout_ms);
|
||||||
extern WFP_API void wfp_client_shutdown(
|
|
||||||
struct wfp_client * client);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,11 @@ void wf_server_dispose(
|
|||||||
wf_impl_server_dispose(server);
|
wf_impl_server_dispose(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_server_run(
|
void wf_server_service(
|
||||||
struct wf_server * server)
|
struct wf_server * server,
|
||||||
|
int timeout_ms)
|
||||||
{
|
{
|
||||||
wf_impl_server_run(server);
|
wf_impl_server_service(server, timeout_ms);
|
||||||
}
|
|
||||||
|
|
||||||
void wf_server_shutdown(
|
|
||||||
struct wf_server * server)
|
|
||||||
{
|
|
||||||
wf_impl_server_shutdown(server);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// server protocol
|
// server protocol
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#define WF_DISABLE_LWS_LOG 0
|
#define WF_DISABLE_LWS_LOG 0
|
||||||
#define WF_SERVER_PROTOCOL_COUNT 3
|
#define WF_SERVER_PROTOCOL_COUNT 3
|
||||||
#define WF_SERVER_TIMEOUT (1 * 1000)
|
|
||||||
|
|
||||||
struct wf_server
|
struct wf_server
|
||||||
{
|
{
|
||||||
@ -21,7 +20,6 @@ struct wf_server
|
|||||||
struct wf_server_protocol protocol;
|
struct wf_server_protocol protocol;
|
||||||
struct lws_protocols ws_protocols[WF_SERVER_PROTOCOL_COUNT];
|
struct lws_protocols ws_protocols[WF_SERVER_PROTOCOL_COUNT];
|
||||||
struct lws_context * context;
|
struct lws_context * context;
|
||||||
volatile bool shutdown_requested;
|
|
||||||
struct lws_http_mount mount;
|
struct lws_http_mount mount;
|
||||||
struct lws_context_creation_info info;
|
struct lws_context_creation_info info;
|
||||||
};
|
};
|
||||||
@ -109,7 +107,6 @@ struct wf_server * wf_impl_server_create(
|
|||||||
if (NULL != server)
|
if (NULL != server)
|
||||||
{
|
{
|
||||||
wf_impl_server_protocol_init(&server->protocol, config->mount_point);
|
wf_impl_server_protocol_init(&server->protocol, config->mount_point);
|
||||||
server->shutdown_requested = false;
|
|
||||||
wf_impl_server_config_clone(config, &server->config);
|
wf_impl_server_config_clone(config, &server->config);
|
||||||
wf_impl_authenticators_move(&server->config.authenticators, &server->protocol.authenticators);
|
wf_impl_authenticators_move(&server->config.authenticators, &server->protocol.authenticators);
|
||||||
server->context = wf_impl_server_context_create(server);
|
server->context = wf_impl_server_context_create(server);
|
||||||
@ -128,19 +125,9 @@ void wf_impl_server_dispose(
|
|||||||
free(server);
|
free(server);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_impl_server_run(
|
void wf_impl_server_service(
|
||||||
struct wf_server * server)
|
struct wf_server * server,
|
||||||
|
int timeout_ms)
|
||||||
{
|
{
|
||||||
int n = 0;
|
lws_service(server->context, timeout_ms);
|
||||||
while ((0 <= n) && (!server->shutdown_requested))
|
|
||||||
{
|
|
||||||
n = lws_service(server->context, WF_SERVER_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wf_impl_server_shutdown(
|
|
||||||
struct wf_server * server)
|
|
||||||
{
|
|
||||||
server->shutdown_requested = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -15,11 +15,9 @@ extern struct wf_server * wf_impl_server_create(
|
|||||||
extern void wf_impl_server_dispose(
|
extern void wf_impl_server_dispose(
|
||||||
struct wf_server * server);
|
struct wf_server * server);
|
||||||
|
|
||||||
extern void wf_impl_server_run(
|
extern void wf_impl_server_service(
|
||||||
struct wf_server * server);
|
struct wf_server * server,
|
||||||
|
int timeout_ms);
|
||||||
extern void wf_impl_server_shutdown(
|
|
||||||
struct wf_server * server);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -206,16 +206,11 @@ void wfp_client_dispose(
|
|||||||
wfp_impl_client_dispose(client);
|
wfp_impl_client_dispose(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfp_client_run(
|
void wfp_client_service(
|
||||||
struct wfp_client * client)
|
struct wfp_client * client,
|
||||||
|
int timeout_ms)
|
||||||
{
|
{
|
||||||
wfp_impl_client_run(client);
|
wfp_impl_client_service(client, timeout_ms);
|
||||||
}
|
|
||||||
|
|
||||||
void wfp_client_shutdown(
|
|
||||||
struct wfp_client * client)
|
|
||||||
{
|
|
||||||
wfp_impl_client_shutdown(client);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dirbuffer
|
// dirbuffer
|
||||||
|
@ -14,11 +14,9 @@
|
|||||||
#define WFP_PROTOCOL ("fs")
|
#define WFP_PROTOCOL ("fs")
|
||||||
#define WFP_DISABLE_LWS_LOG 0
|
#define WFP_DISABLE_LWS_LOG 0
|
||||||
#define WFP_CLIENT_PROTOCOL_COUNT 2
|
#define WFP_CLIENT_PROTOCOL_COUNT 2
|
||||||
#define WFP_CLIENT_TIMEOUT (1 * 1000)
|
|
||||||
|
|
||||||
struct wfp_client
|
struct wfp_client
|
||||||
{
|
{
|
||||||
volatile bool is_running;
|
|
||||||
struct wfp_client_protocol protocol;
|
struct wfp_client_protocol protocol;
|
||||||
struct lws_context_creation_info info;
|
struct lws_context_creation_info info;
|
||||||
struct lws_protocols protocols[WFP_CLIENT_PROTOCOL_COUNT];
|
struct lws_protocols protocols[WFP_CLIENT_PROTOCOL_COUNT];
|
||||||
@ -36,7 +34,6 @@ struct wfp_client * wfp_impl_client_create(
|
|||||||
struct wfp_client * client = malloc(sizeof(struct wfp_client));
|
struct wfp_client * client = malloc(sizeof(struct wfp_client));
|
||||||
if (NULL != client)
|
if (NULL != client)
|
||||||
{
|
{
|
||||||
client->is_running = true;
|
|
||||||
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);
|
wfp_impl_client_protocol_init(&client->protocol, &config->provider, config->user_data);
|
||||||
|
|
||||||
memset(client->protocols, 0, sizeof(struct lws_protocols) * WFP_CLIENT_PROTOCOL_COUNT);
|
memset(client->protocols, 0, sizeof(struct lws_protocols) * WFP_CLIENT_PROTOCOL_COUNT);
|
||||||
@ -102,18 +99,10 @@ void wfp_impl_client_disconnect(
|
|||||||
// ToDo: implement me
|
// ToDo: implement me
|
||||||
}
|
}
|
||||||
|
|
||||||
void wfp_impl_client_run(
|
void wfp_impl_client_service(
|
||||||
struct wfp_client * client)
|
struct wfp_client * client,
|
||||||
|
int timeout_ms)
|
||||||
{
|
{
|
||||||
while (client->is_running)
|
lws_service(client->context, timeout_ms);
|
||||||
{
|
|
||||||
lws_service(client->context, WFP_CLIENT_TIMEOUT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void wfp_impl_client_shutdown(
|
|
||||||
struct wfp_client * client)
|
|
||||||
{
|
|
||||||
client->is_running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,12 +34,9 @@ extern void wfp_impl_client_settimeout(
|
|||||||
extern void wfp_impl_client_dispose(
|
extern void wfp_impl_client_dispose(
|
||||||
struct wfp_client * client);
|
struct wfp_client * client);
|
||||||
|
|
||||||
extern void wfp_impl_client_run(
|
extern void wfp_impl_client_service(
|
||||||
struct wfp_client * client);
|
struct wfp_client * client,
|
||||||
|
int timeout_ms);
|
||||||
extern void wfp_impl_client_shutdown(
|
|
||||||
struct wfp_client * client);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user