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":1571531822, "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":"9f2b8fe2d02dacc15c78d81cbac2d631", "oid":{ "oid": "b7a04a67d15efd0f17bf795b8d3648425b604581", "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 (1000000ll)\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/*\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 * 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);\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 * 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);\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\tsul_cb_t\tcb;\n\tlws_usec_t\tus;\n} lws_sorted_usec_list_t;\n\n\n/*\n * lws_sul_schedule() - schedule a callback\n *\n * \u005cparam context: the lws_context\n * \u005cparam tsi: the thread service index (usually 0)\n * \u005cparam sul: pointer to the sul element\n * \u005cparam cb: the scheduled callback\n * \u005cparam us: the delay before the callback arrives, or\n *\t\tLWS_SET_TIMER_USEC_CANCEL to cancel it.\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 is commonly 1ms.\n *\n * This doesn't allocate and doesn't fail.\n *\n * You can call it again with another us value to change the delay.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_sul_schedule(struct lws_context *context, int tsi,\n\t lws_sorted_usec_list_t *sul, sul_cb_t cb, lws_usec_t us);\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","s":{"c":1571531822,"u": 405}} ],"g": 1641,"chitpc": 0,"ehitpc": 0, "indexed":0 }