added function to interrupt _service calls

pull/56/head
Falk Werner 4 years ago
parent 627986e8b5
commit d2f078298e

@ -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

@ -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

@ -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);
}
void wf_server_interrupt(
struct wf_server * server)
{
wf_impl_server_service(server, timeout_ms);
wf_impl_server_interrupt(server);
}
// server protocol
struct wf_server_protocol * wf_server_protocol_create(

@ -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, 0);
}
void wf_impl_server_interrupt(
struct wf_server * server)
{
lws_service(server->context, timeout_ms);
lws_cancel_service(server->context);
}

@ -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
}

@ -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);
}
void wfp_client_interrupt(
struct wfp_client * client)
{
wfp_impl_client_service(client, timeout_ms);
wfp_impl_client_interrupt(client);
}
// dirbuffer
struct wfp_dirbuffer * wfp_dirbuffer_create(void)

@ -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);
}

@ -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
}

Loading…
Cancel
Save