libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-eventlib-exports.h
Go to the documentation of this file.
1/*
2 * libwebsockets - small server side websockets and web server implementation
3 *
4 * Copyright (C) 2010 - 2021 Andy Green <andy@warmcat.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 * IN THE SOFTWARE.
23 *
24 * These are exports needed by event lib plugins.
25 */
26
31
32enum {
33 LWS_EV_READ = (1 << 0),
34 LWS_EV_WRITE = (1 << 1),
35 LWS_EV_START = (1 << 2),
36 LWS_EV_STOP = (1 << 3),
37};
38
40 const char *name;
41 /* event loop-specific context init during context creation */
42 int (*init_context)(struct lws_context *context,
43 const struct lws_context_creation_info *info);
44 /* called during lws_destroy_context */
45 int (*destroy_context1)(struct lws_context *context);
46 /* called during lws_destroy_context2 */
47 int (*destroy_context2)(struct lws_context *context);
48 /* init vhost listening wsi */
49 int (*init_vhost_listen_wsi)(struct lws *wsi);
50 /* init the event loop for a pt */
51 int (*init_pt)(struct lws_context *context, void *_loop, int tsi);
52 /* called at end of first phase of close_free_wsi() */
53 int (*wsi_logical_close)(struct lws *wsi);
54 /* return nonzero if client connect not allowed */
55 int (*check_client_connect_ok)(struct lws *wsi);
56 /* close handle manually */
57 void (*close_handle_manually)(struct lws *wsi);
58 /* event loop accept processing */
59 int (*sock_accept)(struct lws *wsi);
60 /* control wsi active events */
61 void (*io)(struct lws *wsi, unsigned int flags);
62 /* run the event loop for a pt */
63 void (*run_pt)(struct lws_context *context, int tsi);
64 /* called before pt is destroyed */
65 void (*destroy_pt)(struct lws_context *context, int tsi);
66 /* called just before wsi is freed */
67 void (*destroy_wsi)(struct lws *wsi);
68 /* return nonzero if caller thread is not loop service thread */
69 int (*foreign_thread)(struct lws_context *context, int tsi);
70 /* optional: custom implementation for faking POLLIN for buffered.
71 * return nonzero if any wsi faked */
72 int (*fake_POLLIN_override)(struct lws_context *context, int tsi);
73 /* init a racing parallel connect handle */
74 int (*sock_accept_parallel)(struct lws *wsi, lws_sockfd_type fd, int pidx);
75 /* control racing wsi active events */
76 void (*io_parallel)(struct lws *wsi, int pidx, unsigned int flags);
77 /* close racing handle manually */
78 void (*close_handle_manually_parallel)(struct lws *wsi, int pidx);
79 /* promote parallel handle to primary */
80 int (*promote_parallel)(struct lws *wsi, int pidx);
81
83
88};
89
92
94lws_evlib_tsi_to_evlib_pt(struct lws_context *ctx, int tsi);
95
96 /*
97 * You should consider these opaque for normal user code.
98 */
99
101lws_realloc(void *ptr, size_t size, const char *reason);
102
104lws_vhost_destroy1(struct lws_vhost *vh);
105
107lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
108 const char *caller);
109
111lws_vhost_foreach_listen_wsi(struct lws_context *cx, void *arg,
113
114struct lws_context_per_thread;
116lws_service_do_ripe_rxflow(struct lws_context_per_thread *pt);
117
118#if !defined(wsi_from_fd) && !defined(WIN32) && !defined(_WIN32)
119struct lws_context;
120LWS_VISIBLE LWS_EXTERN struct lws *
121wsi_from_fd(const struct lws_context *context, int fd);
122#endif
123
125_lws_plat_service_forced_tsi(struct lws_context *context, int tsi);
126
128lws_context_destroy2(struct lws_context *context);
129
131lws_destroy_event_pipe(struct lws *wsi);
132
135
136#if LWS_MAX_SMP > 1
137
138struct lws_mutex_refcount {
139 pthread_mutex_t lock;
140 pthread_t lock_owner;
141 const char *last_lock_reason;
142 char lock_depth;
143 char metadata;
144};
145
147lws_mutex_refcount_assert_held(struct lws_mutex_refcount *mr);
148
150lws_mutex_refcount_init(struct lws_mutex_refcount *mr);
151
153lws_mutex_refcount_destroy(struct lws_mutex_refcount *mr);
154
156lws_mutex_refcount_lock(struct lws_mutex_refcount *mr, const char *reason);
157
159lws_mutex_refcount_unlock(struct lws_mutex_refcount *mr);
160
161#endif
int(* lws_dll2_foreach_cb_t)(struct lws_dll2 *d, void *user)
Definition lws-dll2.h:260
lws_close_status
unsigned short uint16_t
#define LWS_EXTERN
unsigned char uint8_t
int lws_sockfd_type
#define LWS_VISIBLE
LWS_VISIBLE LWS_EXTERN void * lws_realloc(void *ptr, size_t size, const char *reason)
LWS_VISIBLE LWS_EXTERN void __lws_close_free_wsi_final(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN struct lws * wsi_from_fd(const struct lws_context *context, int fd)
LWS_VISIBLE LWS_EXTERN void lws_vhost_destroy1(struct lws_vhost *vh)
LWS_VISIBLE LWS_EXTERN int _lws_plat_service_forced_tsi(struct lws_context *context, int tsi)
LWS_VISIBLE LWS_EXTERN void lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason, const char *caller)
lws_event_lib_ops_flags
@ LELOF_ISPOLL
@ LELOF_DESTROY_FINAL
LWS_VISIBLE LWS_EXTERN void lws_destroy_event_pipe(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN void lws_context_destroy2(struct lws_context *context)
LWS_VISIBLE LWS_EXTERN int lws_vhost_foreach_listen_wsi(struct lws_context *cx, void *arg, lws_dll2_foreach_cb_t cb)
@ LWS_EV_READ
@ LWS_EV_START
@ LWS_EV_WRITE
@ LWS_EV_STOP
LWS_VISIBLE LWS_EXTERN void * lws_evlib_wsi_to_evlib_pt(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN void * lws_evlib_tsi_to_evlib_pt(struct lws_context *ctx, int tsi)
LWS_VISIBLE LWS_EXTERN void lws_service_do_ripe_rxflow(struct lws_context_per_thread *pt)
void(* destroy_pt)(struct lws_context *context, int tsi)
int(* check_client_connect_ok)(struct lws *wsi)
int(* destroy_context1)(struct lws_context *context)
void(* io)(struct lws *wsi, unsigned int flags)
void(* close_handle_manually_parallel)(struct lws *wsi, int pidx)
int(* promote_parallel)(struct lws *wsi, int pidx)
void(* run_pt)(struct lws_context *context, int tsi)
int(* destroy_context2)(struct lws_context *context)
void(* close_handle_manually)(struct lws *wsi)
void(* io_parallel)(struct lws *wsi, int pidx, unsigned int flags)
void(* destroy_wsi)(struct lws *wsi)
int(* fake_POLLIN_override)(struct lws_context *context, int tsi)
int(* wsi_logical_close)(struct lws *wsi)
int(* foreign_thread)(struct lws_context *context, int tsi)
int(* sock_accept)(struct lws *wsi)
int(* init_vhost_listen_wsi)(struct lws *wsi)
int(* init_context)(struct lws_context *context, const struct lws_context_creation_info *info)
int(* init_pt)(struct lws_context *context, void *_loop, int tsi)
int(* sock_accept_parallel)(struct lws *wsi, lws_sockfd_type fd, int pidx)