mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
libev: move accept into vh
This commit is contained in:
parent
640620dbdc
commit
73b0147b40
4 changed files with 20 additions and 17 deletions
|
@ -1547,6 +1547,8 @@ if (NOT LWS_WITHOUT_TESTAPPS)
|
|||
"")
|
||||
# libev generates a big mess of warnings with gcc, maintainers blame gcc
|
||||
set_source_files_properties( test-apps/test-server-libev.c PROPERTIES COMPILE_FLAGS "-Wno-error" )
|
||||
set_source_files_properties( lib/event-libs/libev.c PROPERTIES COMPILE_FLAGS "-Wno-error" )
|
||||
|
||||
endif()
|
||||
if (NOT ((CMAKE_C_COMPILER_ID MATCHES "Clang") OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
|
||||
AND LWS_WITH_LIBUV)
|
||||
|
|
|
@ -79,7 +79,6 @@ LWS_VISIBLE int
|
|||
lws_ev_initloop(struct lws_context *context, struct ev_loop *loop, int tsi)
|
||||
{
|
||||
struct ev_signal *w_sigint = &context->pt[tsi].w_sigint.ev_watcher;
|
||||
struct ev_io *w_accept = &context->pt[tsi].w_accept.ev_watcher;
|
||||
struct lws_vhost *vh = context->vhost_list;
|
||||
const char *backend_name;
|
||||
int status = 0;
|
||||
|
@ -102,20 +101,23 @@ lws_ev_initloop(struct lws_context *context, struct ev_loop *loop, int tsi)
|
|||
while (vh) {
|
||||
if (vh->lserv_wsi) {
|
||||
vh->lserv_wsi->w_read.context = context;
|
||||
ev_io_init(w_accept, lws_accept_cb,
|
||||
vh->w_accept.context = context;
|
||||
|
||||
ev_io_init(&vh->w_accept.ev_watcher, lws_accept_cb,
|
||||
vh->lserv_wsi->desc.sockfd, EV_READ);
|
||||
ev_io_start(loop, &vh->w_accept.ev_watcher);
|
||||
|
||||
}
|
||||
vh = vh->vhost_next;
|
||||
}
|
||||
ev_io_start(context->pt[tsi].io_loop_ev, w_accept);
|
||||
|
||||
/* 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->pt[tsi].io_loop_ev, w_sigint);
|
||||
ev_signal_start(loop, w_sigint);
|
||||
}
|
||||
backend = ev_backend(loop);
|
||||
|
||||
backend = ev_backend(loop);
|
||||
switch (backend) {
|
||||
case EVBACKEND_SELECT:
|
||||
backend_name = "select";
|
||||
|
@ -150,6 +152,7 @@ void
|
|||
lws_libev_destroyloop(struct lws_context *context, int tsi)
|
||||
{
|
||||
struct lws_context_per_thread *pt = &context->pt[tsi];
|
||||
struct lws_vhost *vh = context->vhost_list;
|
||||
|
||||
if (!lws_check_opt(context->options, LWS_SERVER_OPTION_LIBEV))
|
||||
return;
|
||||
|
@ -157,7 +160,11 @@ lws_libev_destroyloop(struct lws_context *context, int tsi)
|
|||
if (!pt->io_loop_ev)
|
||||
return;
|
||||
|
||||
ev_io_stop(pt->io_loop_ev, &pt->w_accept.ev_watcher);
|
||||
while (vh) {
|
||||
if (vh->lserv_wsi)
|
||||
ev_io_stop(pt->io_loop_ev, &vh->w_accept.ev_watcher);
|
||||
vh = vh->vhost_next;
|
||||
}
|
||||
if (context->use_ev_sigint)
|
||||
ev_signal_stop(pt->io_loop_ev,
|
||||
&pt->w_sigint.ev_watcher);
|
||||
|
@ -223,10 +230,8 @@ lws_libev_init_fd_table(struct lws_context *context)
|
|||
if (!LWS_LIBEV_ENABLED(context))
|
||||
return 0;
|
||||
|
||||
for (n = 0; n < context->count_threads; n++) {
|
||||
context->pt[n].w_accept.context = context;
|
||||
for (n = 0; n < context->count_threads; n++)
|
||||
context->pt[n].w_sigint.context = context;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -842,9 +842,6 @@ struct lws_context_per_thread {
|
|||
#if defined(LWS_WITH_LIBEVENT)
|
||||
struct event_base *io_loop_event_base;
|
||||
#endif
|
||||
#if defined(LWS_WITH_LIBEV)
|
||||
struct lws_io_watcher w_accept;
|
||||
#endif
|
||||
#if defined(LWS_WITH_LIBEV) || defined(LWS_WITH_LIBUV) || defined(LWS_WITH_LIBEVENT)
|
||||
struct lws_signal_watcher w_sigint;
|
||||
unsigned char ev_loop_foreign:1;
|
||||
|
@ -938,6 +935,9 @@ struct lws_vhost {
|
|||
char socks_proxy_address[128];
|
||||
char socks_user[96];
|
||||
char socks_password[96];
|
||||
#endif
|
||||
#if defined(LWS_WITH_LIBEV)
|
||||
struct lws_io_watcher w_accept;
|
||||
#endif
|
||||
struct lws_conn_stats conn_stats;
|
||||
struct lws_context *context;
|
||||
|
|
|
@ -163,7 +163,6 @@ static struct option options[] = {
|
|||
{ "allow-non-ssl", no_argument, NULL, 'a' },
|
||||
{ "interface", required_argument, NULL, 'i' },
|
||||
{ "closetest", no_argument, NULL, 'c' },
|
||||
{ "libev", no_argument, NULL, 'e' },
|
||||
#ifndef LWS_NO_DAEMONIZE
|
||||
{ "daemonize", no_argument, NULL, 'D' },
|
||||
#endif
|
||||
|
@ -200,13 +199,10 @@ int main(int argc, char **argv)
|
|||
info.port = 7681;
|
||||
|
||||
while (n >= 0) {
|
||||
n = getopt_long(argc, argv, "eci:hsap:d:Dr:", options, NULL);
|
||||
n = getopt_long(argc, argv, "ci:hsap:d:Dr:", options, NULL);
|
||||
if (n < 0)
|
||||
continue;
|
||||
switch (n) {
|
||||
case 'e':
|
||||
opts |= LWS_SERVER_OPTION_LIBEV;
|
||||
break;
|
||||
#ifndef LWS_NO_DAEMONIZE
|
||||
case 'D':
|
||||
daemonize = 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue