mirror of
https://github.com/falk-werner/webfuse
synced 2024-10-27 20:34:10 +00:00
make timeout configurable
This commit is contained in:
parent
8a68ecd0b7
commit
b3bc3144bf
@ -17,6 +17,7 @@ filesystem via fuse and exposes it's API via websockets.
|
|||||||
| --wf-key | path | - | Optional. Specify the file path of the server's private key |
|
| --wf-key | path | - | Optional. Specify the file path of the server's private key |
|
||||||
| --wf- authenticator | path | - | Optional. Specify the file path of the authenticator executable |
|
| --wf- authenticator | path | - | Optional. Specify the file path of the authenticator executable |
|
||||||
| --wf-auth-header | name | - | Optional. Specify the name of the HTTP header used for authentication |
|
| --wf-auth-header | name | - | Optional. Specify the name of the HTTP header used for authentication |
|
||||||
|
| --wf-timeout | timeout | 10 | Optional. Specify the communication timeout. |
|
||||||
|
|
||||||
## Fuse options
|
## Fuse options
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ WEBFUSE options:
|
|||||||
--wf-key PATH path of the server's private key (optional)
|
--wf-key PATH path of the server's private key (optional)
|
||||||
--wf-authenticator PATH path of authenticatior app (optional)
|
--wf-authenticator PATH path of authenticatior app (optional)
|
||||||
--wf-auth-header NAME name of the authentication header (optional)
|
--wf-auth-header NAME name of the authentication header (optional)
|
||||||
|
--wf-timeout TIMEOUT communication timeout in seconds (default: 10)
|
||||||
)";
|
)";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -10,6 +10,7 @@ namespace
|
|||||||
|
|
||||||
constexpr int const default_port = 8081;
|
constexpr int const default_port = 8081;
|
||||||
constexpr char const default_vhost_name[] = "localhost";
|
constexpr char const default_vhost_name[] = "localhost";
|
||||||
|
constexpr uint64_t const default_timeout_secs = 10;
|
||||||
|
|
||||||
void verify(webfuse::ws_config & config)
|
void verify(webfuse::ws_config & config)
|
||||||
{
|
{
|
||||||
@ -46,6 +47,7 @@ bool get_arg(webfuse::ws_config & config, webfuse::commandline_reader& reader, s
|
|||||||
namespace webfuse
|
namespace webfuse
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE
|
||||||
ws_config::ws_config(int argc, char * argv[])
|
ws_config::ws_config(int argc, char * argv[])
|
||||||
: exit_code(EXIT_SUCCESS)
|
: exit_code(EXIT_SUCCESS)
|
||||||
, args(argv[0], argc)
|
, args(argv[0], argc)
|
||||||
@ -53,6 +55,7 @@ ws_config::ws_config(int argc, char * argv[])
|
|||||||
, port(default_port)
|
, port(default_port)
|
||||||
, vhost_name(default_vhost_name)
|
, vhost_name(default_vhost_name)
|
||||||
, use_tls(false)
|
, use_tls(false)
|
||||||
|
, timeout_secs(default_timeout_secs)
|
||||||
{
|
{
|
||||||
commandline_reader reader(argc, argv);
|
commandline_reader reader(argc, argv);
|
||||||
|
|
||||||
@ -101,6 +104,14 @@ ws_config::ws_config(int argc, char * argv[])
|
|||||||
[](auto c) {return std::tolower(c); });
|
[](auto c) {return std::tolower(c); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (arg == "--wf-timeout")
|
||||||
|
{
|
||||||
|
std::string timeout_str;
|
||||||
|
if (get_arg(*this, reader, timeout_str, "missing TIMEOUT"))
|
||||||
|
{
|
||||||
|
timeout_secs = static_cast<uint64_t>(std::stoi(timeout_str));
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
args.push(arg.c_str());
|
args.push(arg.c_str());
|
||||||
|
@ -33,6 +33,8 @@ public:
|
|||||||
|
|
||||||
std::string authenticator;
|
std::string authenticator;
|
||||||
std::string auth_header;
|
std::string auth_header;
|
||||||
|
|
||||||
|
uint64_t timeout_secs;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,6 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
constexpr int64_t const timeout_secs = 10;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -79,6 +72,7 @@ public:
|
|||||||
detail(ws_config const & config)
|
detail(ws_config const & config)
|
||||||
: shutdown_requested(false)
|
: shutdown_requested(false)
|
||||||
, data(config.authenticator, config.auth_header)
|
, data(config.authenticator, config.auth_header)
|
||||||
|
, timeout_secs(config.timeout_secs)
|
||||||
{
|
{
|
||||||
lws_set_log_level(0, nullptr);
|
lws_set_log_level(0, nullptr);
|
||||||
|
|
||||||
@ -131,6 +125,7 @@ public:
|
|||||||
lws_context_creation_info info;
|
lws_context_creation_info info;
|
||||||
lws_context * context;
|
lws_context * context;
|
||||||
server_handler data;
|
server_handler data;
|
||||||
|
uint64_t timeout_secs;
|
||||||
};
|
};
|
||||||
|
|
||||||
ws_server::ws_server(ws_config const & config)
|
ws_server::ws_server(ws_config const & config)
|
||||||
@ -167,7 +162,7 @@ messagereader ws_server::perform(messagewriter writer)
|
|||||||
auto result = d->data.perform(std::move(writer));
|
auto result = d->data.perform(std::move(writer));
|
||||||
|
|
||||||
lws_cancel_service(d->context);
|
lws_cancel_service(d->context);
|
||||||
if(std::future_status::timeout == result.wait_for(std::chrono::seconds(timeout_secs)))
|
if(std::future_status::timeout == result.wait_for(std::chrono::seconds(d->timeout_secs)))
|
||||||
{
|
{
|
||||||
throw std::runtime_error("timeout");
|
throw std::runtime_error("timeout");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user