clean libev.c style

Signed-off-by: Andy Green <andy.green@linaro.org>
This commit is contained in:
Andy Green 2016-01-09 08:13:55 +08:00
parent 5783b1a169
commit 58ad3d6e09

View file

@ -32,10 +32,10 @@ void lws_feature_status_libev(struct lws_context_creation_info *info)
static void
lws_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
struct lws_pollfd eventfd;
struct lws_io_watcher *lws_io = container_of(watcher,
struct lws_io_watcher, watcher);
struct lws_context *context = lws_io->context;
struct lws_pollfd eventfd;
if (revents & EV_ERROR)
return;
@ -60,31 +60,27 @@ lws_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents)
ev_break(loop, EVBREAK_ALL);
}
LWS_VISIBLE int lws_sigint_cfg(
struct lws_context *context,
int use_ev_sigint,
lws_ev_signal_cb* cb)
LWS_VISIBLE int
lws_sigint_cfg(struct lws_context *context, int use_ev_sigint,
lws_ev_signal_cb* cb)
{
context->use_ev_sigint = use_ev_sigint;
if( cb ) {
if (cb)
context->lws_ev_sigint_cb = cb;
}
else {
else
context->lws_ev_sigint_cb = &lws_sigint_cb;
};
return 0;
};
}
LWS_VISIBLE int
lws_initloop(
struct lws_context *context,
struct ev_loop *loop)
lws_initloop(struct lws_context *context, struct ev_loop *loop)
{
struct ev_signal *w_sigint = &context->w_sigint.watcher;
struct ev_io *w_accept = &context->w_accept.watcher;
const char * backend_name;
int status = 0;
int backend;
const char * backend_name;
struct ev_io *w_accept = &context->w_accept.watcher;
struct ev_signal *w_sigint = &context->w_sigint.watcher;
if (!loop)
loop = ev_default_loop(0);
@ -93,17 +89,16 @@ lws_initloop(
/*
* Initialize the accept w_accept with the listening socket
* and register a callback for read operations:
* and register a callback for read operations
*/
ev_io_init(w_accept, lws_accept_cb,
context->lserv_fd, EV_READ);
ev_io_init(w_accept, lws_accept_cb, context->lserv_fd, EV_READ);
ev_io_start(context->io_loop,w_accept);
/* Register the signal watcher unless the user has indicated otherwise: */
if( context->use_ev_sigint ) {
/* Register the signal watcher unless the user says not to */
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) {
@ -128,7 +123,7 @@ lws_initloop(
default:
backend_name = "Unknown libev backend";
break;
};
}
lwsl_notice(" libev backend: %s\n", backend_name);
@ -163,7 +158,7 @@ lws_libev_io(struct lws *wsi, int flags)
return;
assert((flags & (LWS_EV_START | LWS_EV_STOP)) &&
(flags & (LWS_EV_READ | LWS_EV_WRITE)));
(flags & (LWS_EV_READ | LWS_EV_WRITE)));
if (flags & LWS_EV_START) {
if (flags & LWS_EV_WRITE)