mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
Added libwebsocket_sigint_cfg for libev builds to provide
runtime configuration of sigint behavior.
This commit is contained in:
parent
89f5eec5ac
commit
a8f47c9844
3 changed files with 31 additions and 2 deletions
23
lib/libev.c
23
lib/libev.c
|
@ -57,6 +57,21 @@ libwebsocket_sigint_cb(struct ev_loop *loop,
|
|||
ev_break(loop, EVBREAK_ALL);
|
||||
}
|
||||
|
||||
LWS_VISIBLE int libwebsocket_sigint_cfg(
|
||||
struct libwebsocket_context *context,
|
||||
int use_ev_sigint,
|
||||
lws_ev_signal_cb* cb)
|
||||
{
|
||||
context->use_ev_sigint = use_ev_sigint;
|
||||
if( cb ) {
|
||||
context->lws_ev_sigint_cb = cb;
|
||||
}
|
||||
else {
|
||||
context->lws_ev_sigint_cb = &libwebsocket_sigint_cb;
|
||||
};
|
||||
return 0;
|
||||
};
|
||||
|
||||
LWS_VISIBLE int
|
||||
libwebsocket_initloop(
|
||||
struct libwebsocket_context *context,
|
||||
|
@ -80,8 +95,12 @@ libwebsocket_initloop(
|
|||
ev_io_init(w_accept, libwebsocket_accept_cb,
|
||||
context->listen_service_fd, EV_READ);
|
||||
ev_io_start(context->io_loop,w_accept);
|
||||
ev_signal_init(w_sigint, libwebsocket_sigint_cb, SIGINT);
|
||||
ev_signal_start(context->io_loop,w_sigint);
|
||||
|
||||
/* Register the signal watcher unless the user has indicated otherwise: */
|
||||
if( context->use_ev_sigint ) {
|
||||
ev_signal_init(w_sigint, context->lws_ev_sigint_cb, SIGINT);
|
||||
ev_signal_start(context->io_loop,w_sigint);
|
||||
};
|
||||
backend = ev_backend(loop);
|
||||
|
||||
switch (backend) {
|
||||
|
|
|
@ -1143,6 +1143,14 @@ lws_add_http_header_status(struct libwebsocket_context *context,
|
|||
LWS_EXTERN int lws_http_transaction_completed(struct libwebsocket *wsi);
|
||||
|
||||
#ifdef LWS_USE_LIBEV
|
||||
typedef void (lws_ev_signal_cb)(EV_P_ struct ev_signal *w, int revents);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
libwebsocket_sigint_cfg(
|
||||
struct libwebsocket_context *context,
|
||||
int use_ev_sigint,
|
||||
lws_ev_signal_cb* cb);
|
||||
|
||||
LWS_VISIBLE LWS_EXTERN int
|
||||
libwebsocket_initloop(
|
||||
struct libwebsocket_context *context, struct ev_loop *loop);
|
||||
|
|
|
@ -438,6 +438,8 @@ struct libwebsocket_context {
|
|||
struct ev_loop* io_loop;
|
||||
struct lws_io_watcher w_accept;
|
||||
struct lws_signal_watcher w_sigint;
|
||||
lws_ev_signal_cb* lws_ev_sigint_cb;
|
||||
int use_ev_sigint;
|
||||
#endif /* LWS_USE_LIBEV */
|
||||
int max_fds;
|
||||
int listen_port;
|
||||
|
|
Loading…
Add table
Reference in a new issue