Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1594123453, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://libwebsockets.org/repo/libwebsockets", "f":3, "items": [ {"schema":"libjg2-1", "cid":"f5e01d5a2264fa2b1ef6efb11a0bf028", "oid":{ "oid": "bfea9fdf7b0421147b9d9c4c882fab009bfe18d3", "alias": [ "refs/heads/master"]},"blobname": "include/libwebsockets/lws-timeout-timer.h", "blob": "/*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \u0022Software\u0022), to\n * deal in the Software without restriction, including without limitation the\n * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n * sell copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \u0022AS IS\u0022, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\n * IN THE SOFTWARE.\n */\n\n/*! \u005cdefgroup timeout Connection timeouts\n\n APIs related to setting connection timeouts\n*/\n//@{\n\n/*\n * NOTE: These public enums are part of the abi. If you want to add one,\n * add it at where specified so existing users are unaffected.\n */\nenum pending_timeout {\n\tNO_PENDING_TIMEOUT\t\t\t\t\t\u003d 0,\n\tPENDING_TIMEOUT_AWAITING_PROXY_RESPONSE\t\t\t\u003d 1,\n\tPENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE\t\t\u003d 2,\n\tPENDING_TIMEOUT_ESTABLISH_WITH_SERVER\t\t\t\u003d 3,\n\tPENDING_TIMEOUT_AWAITING_SERVER_RESPONSE\t\t\u003d 4,\n\tPENDING_TIMEOUT_AWAITING_PING\t\t\t\t\u003d 5,\n\tPENDING_TIMEOUT_CLOSE_ACK\t\t\t\t\u003d 6,\n\tPENDING_TIMEOUT_UNUSED1\t\t\t\t\t\u003d 7,\n\tPENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE\t\t\t\u003d 8,\n\tPENDING_TIMEOUT_SSL_ACCEPT\t\t\t\t\u003d 9,\n\tPENDING_TIMEOUT_HTTP_CONTENT\t\t\t\t\u003d 10,\n\tPENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND\t\t\t\u003d 11,\n\tPENDING_FLUSH_STORED_SEND_BEFORE_CLOSE\t\t\t\u003d 12,\n\tPENDING_TIMEOUT_SHUTDOWN_FLUSH\t\t\t\t\u003d 13,\n\tPENDING_TIMEOUT_CGI\t\t\t\t\t\u003d 14,\n\tPENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE\t\t\t\u003d 15,\n\tPENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING\t\t\t\u003d 16,\n\tPENDING_TIMEOUT_WS_PONG_CHECK_GET_PONG\t\t\t\u003d 17,\n\tPENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD\t\t\t\u003d 18,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_GREETING_REPLY\t \u003d 19,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_CONNECT_REPLY\t\t\u003d 20,\n\tPENDING_TIMEOUT_AWAITING_SOCKS_AUTH_REPLY\t\t\u003d 21,\n\tPENDING_TIMEOUT_KILLED_BY_SSL_INFO\t\t\t\u003d 22,\n\tPENDING_TIMEOUT_KILLED_BY_PARENT\t\t\t\u003d 23,\n\tPENDING_TIMEOUT_CLOSE_SEND\t\t\t\t\u003d 24,\n\tPENDING_TIMEOUT_HOLDING_AH\t\t\t\t\u003d 25,\n\tPENDING_TIMEOUT_UDP_IDLE\t\t\t\t\u003d 26,\n\tPENDING_TIMEOUT_CLIENT_CONN_IDLE\t\t\t\u003d 27,\n\tPENDING_TIMEOUT_LAGGING\t\t\t\t\t\u003d 28,\n\tPENDING_TIMEOUT_THREADPOOL\t\t\t\t\u003d 29,\n\tPENDING_TIMEOUT_THREADPOOL_TASK\t\t\t\t\u003d 30,\n\tPENDING_TIMEOUT_KILLED_BY_PROXY_CLIENT_CLOSE\t\t\u003d 31,\n\tPENDING_TIMEOUT_USER_OK\t\t\t\t\t\u003d 32,\n\n\t/****** add new things just above ---^ ******/\n\n\tPENDING_TIMEOUT_USER_REASON_BASE\t\t\t\u003d 1000\n};\n\n#define lws_time_in_microseconds lws_now_usecs\n\n#define LWS_TO_KILL_ASYNC -1\n/**\u003c If LWS_TO_KILL_ASYNC is given as the timeout sec in a lws_set_timeout()\n * call, then the connection is marked to be killed at the next timeout\n * check. This is how you should force-close the wsi being serviced if\n * you are doing it outside the callback (where you should close by nonzero\n * return).\n */\n#define LWS_TO_KILL_SYNC -2\n/**\u003c If LWS_TO_KILL_SYNC is given as the timeout sec in a lws_set_timeout()\n * call, then the connection is closed before returning (which may delete\n * the wsi). This should only be used where the wsi being closed is not the\n * wsi currently being serviced.\n */\n/**\n * lws_set_timeout() - marks the wsi as subject to a timeout some seconds hence\n *\n * \u005cparam wsi:\tWebsocket connection instance\n * \u005cparam reason:\ttimeout reason\n * \u005cparam secs:\thow many seconds. You may set to LWS_TO_KILL_ASYNC to\n *\t\tforce the connection to timeout at the next opportunity, or\n *\t\tLWS_TO_KILL_SYNC to close it synchronously if you know the\n *\t\twsi is not the one currently being serviced.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs);\n\n/**\n * lws_set_timeout_us() - marks the wsi as subject to a timeout some us hence\n *\n * \u005cparam wsi:\tWebsocket connection instance\n * \u005cparam reason:\ttimeout reason\n * \u005cparam us:\t0 removes the timeout, otherwise number of us to wait\n *\n * Higher-resolution version of lws_set_timeout(). Actual resolution depends\n * on platform and load, usually ms.\n */\nvoid\nlws_set_timeout_us(struct lws *wsi, enum pending_timeout reason, lws_usec_t us);\n\n#define LWS_SET_TIMER_USEC_CANCEL ((lws_usec_t)-1ll)\n#define LWS_USEC_PER_SEC ((lws_usec_t)1000000)\n\n/**\n * lws_set_timer_usecs() - schedules a callback on the wsi in the future\n *\n * \u005cparam wsi:\tWebsocket connection instance\n * \u005cparam usecs: LWS_SET_TIMER_USEC_CANCEL removes any existing scheduled\n *\t\t callback, otherwise number of microseconds in the future\n *\t\t the callback will occur at.\n *\n * NOTE: event loop support for this:\n *\n * default poll() loop: yes\n * libuv event loop: yes\n * libev: not implemented (patch welcome)\n * libevent: not implemented (patch welcome)\n *\n * After the deadline expires, the wsi will get a callback of type\n * LWS_CALLBACK_TIMER and the timer is exhausted. The deadline may be\n * continuously deferred by further calls to lws_set_timer_usecs() with a later\n * deadline, or cancelled by lws_set_timer_usecs(wsi, -1).\n *\n * If the timer should repeat, lws_set_timer_usecs() must be called again from\n * LWS_CALLBACK_TIMER.\n *\n * Accuracy depends on the platform and the load on the event loop or system...\n * all that's guaranteed is the callback will come after the requested wait\n * period.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_set_timer_usecs(struct lws *wsi, lws_usec_t usecs);\n\n#if defined(LWS_WITH_DEPRECATED_THINGS)\n\n/*\n * lws_timed_callback_vh_protocol() - calls back a protocol on a vhost after\n * \t\t\t\t\tthe specified delay in seconds\n *\n * \u005cparam vh:\t the vhost to call back\n * \u005cparam protocol: the protocol to call back\n * \u005cparam reason: callback reason\n * \u005cparam secs:\thow many seconds in the future to do the callback.\n *\n * DEPRECATED since v4.1\n *\n * Callback the specified protocol with a fake wsi pointing to the specified\n * vhost and protocol, with the specified reason, at the specified time in the\n * future.\n *\n * Returns 0 if OK or 1 on OOM.\n *\n * In the multithreaded service case, the callback will occur in the same\n * service thread context as the call to this api that requested it. If it is\n * called from a non-service thread, tsi 0 will handle it.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_timed_callback_vh_protocol(struct lws_vhost *vh,\n\t\t\t const struct lws_protocols *prot,\n\t\t\t int reason, int secs)\nLWS_WARN_DEPRECATED;\n\n/*\n * lws_timed_callback_vh_protocol_us() - calls back a protocol on a vhost after\n * \t\t\t\t\t the specified delay in us\n *\n * \u005cparam vh:\t the vhost to call back\n * \u005cparam protocol: the protocol to call back\n * \u005cparam reason: callback reason\n * \u005cparam us:\thow many us in the future to do the callback.\n *\n * DEPRECATED since v4.1\n *\n * Callback the specified protocol with a fake wsi pointing to the specified\n * vhost and protocol, with the specified reason, at the specified time in the\n * future.\n *\n * Returns 0 if OK or 1 on OOM.\n *\n * In the multithreaded service case, the callback will occur in the same\n * service thread context as the call to this api that requested it. If it is\n * called from a non-service thread, tsi 0 will handle it.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_timed_callback_vh_protocol_us(struct lws_vhost *vh,\n\t\t\t\t const struct lws_protocols *prot, int reason,\n\t\t\t\t lws_usec_t us)\nLWS_WARN_DEPRECATED;\n\n#endif\n\nstruct lws_sorted_usec_list;\n\ntypedef void (*sul_cb_t)(struct lws_sorted_usec_list *sul);\n\ntypedef struct lws_sorted_usec_list {\n\tstruct lws_dll2 list;\t/* simplify the code by keeping this at start */\n\tlws_usec_t\tus;\n\tsul_cb_t\tcb;\n\tuint32_t\tlatency_us;\t/* us it may safely be delayed */\n} lws_sorted_usec_list_t;\n\n/*\n * There are multiple sul owners to allow accounting for, a) events that must\n * wake from suspend, and b) events that can be missued due to suspend\n */\n#define LWS_COUNT_PT_SUL_OWNERS\t\t\t2\n\n#define LWSSULLI_MISS_IF_SUSPENDED\t\t0\n#define LWSSULLI_WAKE_IF_SUSPENDED\t\t1\n\n/*\n * lws_sul2_schedule() - schedule a callback\n *\n * \u005cparam context: the lws_context\n * \u005cparam tsi: the thread service index (usually 0)\n * \u005cparam flags: LWSSULLI_...\n * \u005cparam sul: pointer to the sul element\n *\n * Generic callback-at-a-later time function. The callback happens on the\n * event loop thread context.\n *\n * Although the api has us resultion, the actual resolution depends on the\n * platform and may be, eg, 1ms.\n *\n * This doesn't allocate and doesn't fail.\n *\n * If flags contains LWSSULLI_WAKE_IF_SUSPENDED, the scheduled event is placed\n * on a sul owner list that, if the system has entered low power suspend mode,\n * tries to arrange that the system should wake from platform suspend just\n * before the event is due. Scheduled events without this flag will be missed\n * in the case the system is in suspend and nothing else happens to have woken\n * it.\n *\n * You can call it again with another us value to change the delay or move the\n * event to a different owner (ie, wake or miss on suspend).\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_sul2_schedule(struct lws_context *context, int tsi, int flags,\n\t\t lws_sorted_usec_list_t *sul);\n\n/*\n * lws_sul_cancel() - cancel scheduled callback\n *\n * \u005cparam sul: pointer to the sul element\n *\n * If it's scheduled, remove the sul from its owning sorted list.\n * If not scheduled, it's a NOP.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_sul_cancel(lws_sorted_usec_list_t *sul);\n\n/*\n * lws_sul_earliest_wakeable_event() - get earliest wake-from-suspend event\n *\n * \u005cparam ctx: the lws context\n * \u005cparam pearliest: pointer to lws_usec_t to take the result\n *\n * Either returns 1 if no pending event, or 0 and sets *pearliest to the\n * MONOTONIC time of the current earliest next expected event.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_sul_earliest_wakeable_event(struct lws_context *ctx, lws_usec_t *pearliest);\n\n/*\n * For backwards compatibility\n *\n * If us is LWS_SET_TIMER_USEC_CANCEL, the sul is removed from the scheduler.\n * New code can use lws_sul_cancel()\n */\n\n#define lws_sul_schedule(ctx, tsi, sul, _cb, _us) {\u005c\n\tif ((lws_usec_t)_us \u003d\u003d (lws_usec_t)LWS_SET_TIMER_USEC_CANCEL) \u005c\n\t\tlws_sul_cancel(sul); \u005c\n\telse { \u005c\n\t\t(sul)-\u003ecb \u003d _cb; \u005c\n\t\t(sul)-\u003eus \u003d lws_now_usecs() + _us; \u005c\n\t\tlws_sul2_schedule(ctx, tsi, LWSSULLI_MISS_IF_SUSPENDED, sul); \u005c\n\t}}\n\n#define lws_sul_schedule_wakesuspend(ctx, tsi, sul, _cb, _us) {\u005c\n\tif ((lws_usec_t)_us \u003d\u003d (lws_usec_t)LWS_SET_TIMER_USEC_CANCEL) \u005c\n\t\tlws_sul_cancel(sul); \u005c\n\telse { \u005c\n\t\t(sul)-\u003ecb \u003d _cb; \u005c\n\t\t(sul)-\u003eus \u003d lws_now_usecs() + _us; \u005c\n\t\tlws_sul2_schedule(ctx, tsi, LWSSULLI_WAKE_IF_SUSPENDED, sul); \u005c\n\t}}\n\n\n/*\n * lws_validity_confirmed() - reset the validity timer for a network connection\n *\n * \u005cparam wsi: the connection that saw traffic proving the connection valid\n *\n * Network connections are subject to intervals defined by the context, the\n * vhost if server connections, or the client connect info if a client\n * connection. If the connection goes longer than the specified time since\n * last observing traffic that can only happen if traffic is passing in both\n * directions, then lws will try to create a PING transaction on the network\n * connection.\n *\n * If the connection reaches the specified `.secs_since_valid_hangup` time\n * still without any proof of validity, the connection will be closed.\n *\n * If the PONG comes, or user code observes traffic that satisfies the proof\n * that both directions are passing traffic to the peer and calls this api,\n * the connection validity timer is reset and the scheme repeats.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_validity_confirmed(struct lws *wsi);\n\n/*\n * These are not normally needed, they're exported for the case there's code\n * using lws_sul for which lws is an optional link dependency.\n */\n\nLWS_VISIBLE LWS_EXTERN int\n__lws_sul_insert(lws_dll2_owner_t *own, lws_sorted_usec_list_t *sul);\n\nLWS_VISIBLE LWS_EXTERN lws_usec_t\n__lws_sul_service_ripe(lws_dll2_owner_t *own, int own_len, lws_usec_t usnow);\n\n///@}\n","s":{"c":1594123453,"u": 288}} ],"g": 2852,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}