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

Merge pull request #56 from falk-werner/interrupt

added function to interrupt _service calls
This commit is contained in:
Falk Werner 2020-03-07 18:32:16 +01:00 committed by GitHub
commit 8a24694f8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 82 additions and 16 deletions

View File

@ -46,13 +46,29 @@ extern WF_API void wf_server_dispose(
/// This function must be invoked in a loop while the server is running. It
/// makes the server wait for the next event and processes it.
///
/// \note timeout_ms is no longer used
///
/// \param server pointer to server
/// \param timeout_ms timeout in milliseconds.
/// \param timeout_ms unused; set to 0; used for backward compatibility
///
/// \see wf_server_interrupt
//------------------------------------------------------------------------------
extern WF_API void wf_server_service(
struct wf_server * server,
int timeout_ms);
//------------------------------------------------------------------------------
/// \brief Interrupts wf_server_service
///
/// This function can be used from another thread.
///
/// \param server pointer to server
///
/// \see wf_server_service
//------------------------------------------------------------------------------
extern WF_API void wf_server_interrupt(
struct wf_server * server);
#ifdef __cplusplus
}
#endif

View File

@ -78,13 +78,29 @@ extern WFP_API void wfp_client_dispose(
/// This function must be invoked in a loop while the client is running. It
/// makes the server wait for the next event and processes it.
///
/// \note timeout is ignored
///
/// \param client pointer to client
/// \param timeout_ms timeout in milliseconds.
/// \param timeout_ms unused; set to 0; for backward compatibilty
///
/// \see wfp_client_interrupt
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_service(
struct wfp_client * client,
int timeout_ms);
//------------------------------------------------------------------------------
/// \brief interrupt wfp_client_service
///
/// This function can be called from another thread.
///
/// \param client pointer to client
///
/// \see wfp_client_service
//------------------------------------------------------------------------------
extern WFP_API void wfp_client_interrupt(
struct wfp_client * client);
#ifdef __cplusplus
}
#endif

View File

@ -6,6 +6,8 @@
#include "webfuse/adapter/impl/credentials.h"
#include "webfuse/adapter/impl/mountpoint.h"
#include "webfuse/core/util.h"
// server
struct wf_server * wf_server_create(
@ -22,11 +24,18 @@ void wf_server_dispose(
void wf_server_service(
struct wf_server * server,
int timeout_ms)
int WF_UNUSED_PARAM(imeout_ms))
{
wf_impl_server_service(server, timeout_ms);
wf_impl_server_service(server);
}
void wf_server_interrupt(
struct wf_server * server)
{
wf_impl_server_interrupt(server);
}
// server protocol
struct wf_server_protocol * wf_server_protocol_create(

View File

@ -111,8 +111,14 @@ bool wf_impl_server_is_operational(
}
void wf_impl_server_service(
struct wf_server * server,
int timeout_ms)
struct wf_server * server)
{
lws_service(server->context, timeout_ms);
lws_service(server->context, 0);
}
void wf_impl_server_interrupt(
struct wf_server * server)
{
lws_cancel_service(server->context);
}

View File

@ -23,8 +23,10 @@ extern bool wf_impl_server_is_operational(
struct wf_server * server);
extern void wf_impl_server_service(
struct wf_server * server,
int timeout_ms);
struct wf_server * server);
extern void wf_impl_server_interrupt(
struct wf_server * server);
#ifdef __cplusplus
}

View File

@ -13,6 +13,8 @@
#include "webfuse/provider/impl/dirbuffer.h"
#include "webfuse/provider/impl/credentials.h"
#include "webfuse/core/util.h"
// respond
void wfp_respond_error(
@ -223,11 +225,18 @@ void wfp_client_dispose(
void wfp_client_service(
struct wfp_client * client,
int timeout_ms)
int WF_UNUSED_PARAM(timeout_ms))
{
wfp_impl_client_service(client, timeout_ms);
wfp_impl_client_service(client);
}
void wfp_client_interrupt(
struct wfp_client * client)
{
wfp_impl_client_interrupt(client);
}
// dirbuffer
struct wfp_dirbuffer * wfp_dirbuffer_create(void)

View File

@ -84,9 +84,13 @@ bool wfp_impl_client_is_connected(
}
void wfp_impl_client_service(
struct wfp_client * client,
int timeout_ms)
struct wfp_client * client)
{
lws_service(client->context, timeout_ms);
lws_service(client->context, 0);
}
void wfp_impl_client_interrupt(
struct wfp_client * client)
{
lws_cancel_service(client->context);
}

View File

@ -38,8 +38,10 @@ extern bool wfp_impl_client_is_connected(
struct wfp_client * client);
extern void wfp_impl_client_service(
struct wfp_client * client,
int timeout_ms);
struct wfp_client * client);
extern void wfp_impl_client_interrupt(
struct wfp_client * client);
#ifdef __cplusplus
}

View File

@ -55,6 +55,7 @@ private:
{
std::lock_guard<std::mutex> lock(shutdown_lock);
is_shutdown_requested = true;
wfp_client_interrupt(client);
}
static void Run(Provider::Private * context)

View File

@ -61,6 +61,7 @@ private:
{
std::lock_guard<std::mutex> lock(shutdown_lock);
is_shutdown_requested = true;
wf_server_interrupt(server);
}
static void Run(Server::Private * context)