libwebsockets
Lightweight C library for HTML5 websockets
lws-service.h
1 /*
2  * libwebsockets - small server side websockets and web server implementation
3  *
4  * Copyright (C) 2010 - 2019 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 
33 
51 LWS_VISIBLE LWS_EXTERN int
52 lws_service(struct lws_context *context, int timeout_ms);
53 
64 LWS_VISIBLE LWS_EXTERN int
65 lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi);
66 
75 LWS_VISIBLE LWS_EXTERN void
76 lws_cancel_service_pt(struct lws *wsi);
77 
90 LWS_VISIBLE LWS_EXTERN void
91 lws_cancel_service(struct lws_context *context);
92 
119 LWS_VISIBLE LWS_EXTERN int
120 lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd);
121 
131 LWS_VISIBLE LWS_EXTERN int
132 lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
133  int tsi);
134 
152 LWS_VISIBLE LWS_EXTERN int
153 lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi);
154 
155 /* Backwards compatibility */
156 #define lws_plat_service_tsi lws_service_tsi
157 
158 LWS_VISIBLE LWS_EXTERN int
159 lws_handle_POLLOUT_event(struct lws *wsi, struct lws_pollfd *pollfd);
160 
162 
170 #if defined(LWS_WITH_LIBUV) && defined(UV_ERRNO_MAP)
171 
172 /*
173  * Any direct libuv allocations in lws protocol handlers must participate in the
174  * lws reference counting scheme. Two apis are provided:
175  *
176  * - lws_libuv_static_refcount_add(handle, context, tsi) to mark the handle with
177  * a pointer to the context and increment the global uv object counter
178  *
179  * - lws_libuv_static_refcount_del() which should be used as the close callback
180  * for your own libuv objects declared in the protocol scope.
181  *
182  * Using the apis allows lws to detach itself from a libuv loop completely
183  * cleanly and at the moment all of its libuv objects have completed close.
184  */
185 
186 LWS_VISIBLE LWS_EXTERN uv_loop_t *
187 lws_uv_getloop(struct lws_context *context, int tsi);
188 
189 LWS_VISIBLE LWS_EXTERN void
190 lws_libuv_static_refcount_add(uv_handle_t *, struct lws_context *context,
191  int tsi);
192 
193 LWS_VISIBLE LWS_EXTERN void
194 lws_libuv_static_refcount_del(uv_handle_t *);
195 
196 #endif /* LWS_WITH_LIBUV */
197 
198 #if defined(LWS_PLAT_FREERTOS)
199 #define lws_libuv_static_refcount_add(_a, _b, _c)
200 #define lws_libuv_static_refcount_del NULL
201 #endif
LWS_VISIBLE LWS_EXTERN void lws_cancel_service_pt(struct lws *wsi)
LWS_VISIBLE LWS_EXTERN int lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi)
LWS_VISIBLE LWS_EXTERN void lws_cancel_service(struct lws_context *context)
LWS_VISIBLE LWS_EXTERN int lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
LWS_VISIBLE LWS_EXTERN int lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd)
LWS_VISIBLE LWS_EXTERN int lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, int tsi)
LWS_VISIBLE LWS_EXTERN int lws_service(struct lws_context *context, int timeout_ms)