mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
without-server: adapt loops to not touch listen_list
https://github.com/warmcat/libwebsockets/issues/3203
This commit is contained in:
parent
6112189aac
commit
11b99188f8
6 changed files with 24 additions and 1 deletions
|
@ -379,6 +379,12 @@ if (LWS_WITHOUT_SERVER)
|
||||||
set(LWS_WITH_SERVER)
|
set(LWS_WITH_SERVER)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (LWS_WITH_SERVER)
|
||||||
|
else()
|
||||||
|
set(LWS_WITH_CGI 0)
|
||||||
|
set(LWS_ROLE_CGI 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (LWS_WITH_UPNG)
|
if (LWS_WITH_UPNG)
|
||||||
set(LWS_WITH_GZINFLATE 1)
|
set(LWS_WITH_GZINFLATE 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -139,6 +139,7 @@ lws_ev_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents)
|
||||||
static int
|
static int
|
||||||
elops_listen_init_ev(struct lws_dll2 *d, void *user)
|
elops_listen_init_ev(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_context *context = (struct lws_context *)user;
|
struct lws_context *context = (struct lws_context *)user;
|
||||||
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
||||||
|
@ -153,6 +154,7 @@ elops_listen_init_ev(struct lws_dll2 *d, void *user)
|
||||||
ev_io_init(&vh_to_priv_ev(vh)->w_accept.watcher,
|
ev_io_init(&vh_to_priv_ev(vh)->w_accept.watcher,
|
||||||
lws_accept_cb, wsi->desc.sockfd, EV_READ);
|
lws_accept_cb, wsi->desc.sockfd, EV_READ);
|
||||||
ev_io_start(ptpr->io_loop, &vh_to_priv_ev(vh)->w_accept.watcher);
|
ev_io_start(ptpr->io_loop, &vh_to_priv_ev(vh)->w_accept.watcher);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -243,6 +245,7 @@ elops_init_pt_ev(struct lws_context *context, void *_loop, int tsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_destroy_ev(struct lws_dll2 *d, void *user)
|
elops_listen_destroy_ev(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_context *context = (struct lws_context *)user;
|
struct lws_context *context = (struct lws_context *)user;
|
||||||
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
||||||
|
@ -250,7 +253,7 @@ elops_listen_destroy_ev(struct lws_dll2 *d, void *user)
|
||||||
struct lws_vhost *vh = wsi->a.vhost;
|
struct lws_vhost *vh = wsi->a.vhost;
|
||||||
|
|
||||||
ev_io_stop(ptpr->io_loop, &vh_to_priv_ev(vh)->w_accept.watcher);
|
ev_io_stop(ptpr->io_loop, &vh_to_priv_ev(vh)->w_accept.watcher);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,7 @@ lws_event_sigint_cb(evutil_socket_t sock_fd, short revents, void *ctx)
|
||||||
static int
|
static int
|
||||||
elops_listen_init_event(struct lws_dll2 *d, void *user)
|
elops_listen_init_event(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_context *context = (struct lws_context *)user;
|
struct lws_context *context = (struct lws_context *)user;
|
||||||
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi];
|
||||||
|
@ -188,6 +189,7 @@ elops_listen_init_event(struct lws_dll2 *d, void *user)
|
||||||
(EV_READ | EV_PERSIST), lws_event_cb, w_read);
|
(EV_READ | EV_PERSIST), lws_event_cb, w_read);
|
||||||
event_add(w_read->watcher, NULL);
|
event_add(w_read->watcher, NULL);
|
||||||
w_read->set = 1;
|
w_read->set = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -334,6 +336,7 @@ elops_run_pt_event(struct lws_context *context, int tsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_destroy_event(struct lws_dll2 *d, void *user)
|
elops_listen_destroy_event(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_wsi_eventlibs_libevent *w = wsi_to_priv_event(wsi);
|
struct lws_wsi_eventlibs_libevent *w = wsi_to_priv_event(wsi);
|
||||||
|
|
||||||
|
@ -341,6 +344,7 @@ elops_listen_destroy_event(struct lws_dll2 *d, void *user)
|
||||||
w->w_read.watcher = NULL;
|
w->w_read.watcher = NULL;
|
||||||
event_free(w->w_write.watcher);
|
event_free(w->w_write.watcher);
|
||||||
w->w_write.watcher = NULL;
|
w->w_write.watcher = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,10 +698,12 @@ elops_destroy_pt_uv(struct lws_context *context, int tsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_init_uv(struct lws_dll2 *d, void *user)
|
elops_listen_init_uv(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
|
|
||||||
if (elops_init_vhost_listen_wsi_uv(wsi) == -1)
|
if (elops_init_vhost_listen_wsi_uv(wsi) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,10 +234,12 @@ init_vhost_listen_wsi_sd(struct lws *wsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_init_sdevent(struct lws_dll2 *d, void *user)
|
elops_listen_init_sdevent(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
|
|
||||||
if (init_vhost_listen_wsi_sd(wsi) == -1)
|
if (init_vhost_listen_wsi_sd(wsi) == -1)
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -368,9 +370,11 @@ run_pt_sd(struct lws_context *context, int tsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_destroy_sdevent(struct lws_dll2 *d, void *user)
|
elops_listen_destroy_sdevent(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
|
|
||||||
wsi_logical_close_sd(wsi);
|
wsi_logical_close_sd(wsi);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,7 @@ lws_uloop_cb(struct uloop_fd *ufd, unsigned int revents)
|
||||||
static int
|
static int
|
||||||
elops_listen_init_uloop(struct lws_dll2 *d, void *user)
|
elops_listen_init_uloop(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_wsi_eventlibs_uloop *wu = wsi_to_priv_uloop(wsi);
|
struct lws_wsi_eventlibs_uloop *wu = wsi_to_priv_uloop(wsi);
|
||||||
|
|
||||||
|
@ -143,6 +144,7 @@ elops_listen_init_uloop(struct lws_dll2 *d, void *user)
|
||||||
wu->fd.cb = lws_uloop_cb;
|
wu->fd.cb = lws_uloop_cb;
|
||||||
uloop_fd_add(&wu->fd, ULOOP_READ);
|
uloop_fd_add(&wu->fd, ULOOP_READ);
|
||||||
wu->actual_events = ULOOP_READ;
|
wu->actual_events = ULOOP_READ;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -217,10 +219,12 @@ elops_run_pt_uloop(struct lws_context *context, int tsi)
|
||||||
static int
|
static int
|
||||||
elops_listen_destroy_uloop(struct lws_dll2 *d, void *user)
|
elops_listen_destroy_uloop(struct lws_dll2 *d, void *user)
|
||||||
{
|
{
|
||||||
|
#if defined(LWS_WITH_SERVER)
|
||||||
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
struct lws *wsi = lws_container_of(d, struct lws, listen_list);
|
||||||
struct lws_wsi_eventlibs_uloop *wu = wsi_to_priv_uloop(wsi);
|
struct lws_wsi_eventlibs_uloop *wu = wsi_to_priv_uloop(wsi);
|
||||||
|
|
||||||
uloop_fd_delete(&wu->fd);
|
uloop_fd_delete(&wu->fd);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue