Project homepage Mailing List  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"en-US,en;q\u003d0.5", "gen_ut":1591076841, "reponame":"libwebsockets", "desc":"libwebsockets lightweight C networking library", "owner": { "name": "Andy Green", "email": "", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"", "f":3, "items": [ {"schema":"libjg2-1", "cid":"9040b0f91f46f28715cf9438859474f8", "oid":{ "oid": "1abb4943ba8092aab5d716e906011150083b10fb", "alias": [ "refs/heads/master"]},"blobname": "include/libwebsockets/lws-sequencer.h", "blob": " /*\n * libwebsockets - small server side websockets and web server implementation\n *\n * Copyright (C) 2010 - 2019 Andy Green \\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 * lws_sequencer is intended to help implement sequences that:\n *\n * - outlive a single connection lifetime,\n * - are not associated with a particular protocol,\n * - are not associated with a particular vhost,\n * - must receive and issue events inside the event loop\n *\n * lws_sequencer-s are bound to a pt (per-thread) which for the default case of\n * one service thread is the same as binding to an lws_context.\n */\n/*\n * retry backoff table... retry n happens after .retry_ms_table[n] ms, with\n * the last entry used if n is greater than the number of entries.\n *\n * The first .conceal_count retries are concealed, but after that the failures\n * are reported.\n */\n\ntypedef enum {\n\tLWSSEQ_CREATED,\t\t/* sequencer created */\n\tLWSSEQ_DESTROYED,\t/* sequencer destroyed */\n\tLWSSEQ_TIMED_OUT,\t/* sequencer timeout */\n\tLWSSEQ_HEARTBEAT,\t/* 1Hz callback */\n\n\tLWSSEQ_WSI_CONNECTED,\t/* wsi we bound to us has connected */\n\tLWSSEQ_WSI_CONN_FAIL,\t/* wsi we bound to us has failed to connect */\n\tLWSSEQ_WSI_CONN_CLOSE,\t/* wsi we bound to us has closed */\n\n\n\tLWSSEQ_SS_STATE_BASE,\t/* secure streams owned by a sequencer provide\n\t\t\t\t * automatic messages about state changes on\n\t\t\t\t * the sequencer, passing the oridinal in the\n\t\t\t\t * event argument field. The message index is\n\t\t\t\t * LWSSEQ_SS_STATE_BASE + the enum from\n\t\t\t\t * lws_ss_constate_t */\n\n\tLWSSEQ_USER_BASE \u003d 100\t/* define your events from here */\n} lws_seq_events_t;\n\ntypedef enum lws_seq_cb_return {\n\tLWSSEQ_RET_CONTINUE,\n\tLWSSEQ_RET_DESTROY\n} lws_seq_cb_return_t;\n\n/*\n * handler for this sequencer. Return 0 if OK else nonzero to destroy the\n * sequencer. LWSSEQ_DESTROYED will be called back to the handler so it can\n * close / destroy any private assets associated with the sequence.\n *\n * The callback may return either LWSSEQ_RET_CONTINUE for the sequencer to\n * resume or LWSSEQ_RET_DESTROY to indicate the sequence is finished.\n *\n * Event indexes consist of some generic ones but mainly user-defined ones\n * starting from LWSSEQ_USER_BASE.\n */\ntypedef lws_seq_cb_return_t (*lws_seq_event_cb)(struct lws_sequencer *seq,\n\t\t\t void *user, int event, void *data, void *aux);\n\ntypedef struct lws_seq_info {\n\tstruct lws_context\t\t*context; /* lws_context for seq */\n\tint\t\t\t\ttsi;\t /* thread service idx */\n\tsize_t\t\t\t\tuser_size; /* size of user alloc */\n\tvoid\t\t\t\t**puser; /* place ptr to user */\n\tlws_seq_event_cb\t\tcb;\t /* seq callback */\n\tconst char\t\t\t*name;\t /* seq name */\n\tconst lws_retry_bo_t\t\t*retry;\t /* retry policy */\n\tuint8_t\t\t\t\twakesuspend:1; /* important enough to\n\t\t\t\t\t\t * wake system */\n} lws_seq_info_t;\n\n/**\n * lws_seq_create() - create and bind sequencer to a pt\n *\n * \u005cparam info:\tinformation about sequencer to create\n *\n * This binds an abstract sequencer to a per-thread (by default, the single\n * event loop of an lws_context). After the event loop starts, the sequencer\n * will receive an LWSSEQ_CREATED event on its callback from the event loop\n * context, where it can begin its sequence flow.\n *\n * Lws itself will only call the callback subsequently with LWSSEQ_DESTROYED\n * when the sequencer is being destroyed.\n *\n * pt locking is used to protect the related data structures.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_sequencer *\nlws_seq_create(lws_seq_info_t *info);\n\n/**\n * lws_seq_destroy() - destroy the sequencer\n *\n * \u005cparam seq: pointer to the the opaque sequencer pointer returned by\n *\t lws_seq_create()\n *\n * This proceeds to destroy the sequencer, calling LWSSEQ_DESTROYED and then\n * freeing the sequencer object itself. The pointed-to seq pointer will be\n * set to NULL.\n */\nLWS_VISIBLE LWS_EXTERN void\nlws_seq_destroy(struct lws_sequencer **seq);\n\n/**\n * lws_seq_queue_event() - queue an event on the given sequencer\n *\n * \u005cparam seq: the opaque sequencer pointer returned by lws_seq_create()\n * \u005cparam e: the event index to queue\n * \u005cparam data: associated opaque (to lws) data to provide the callback\n * \u005cparam aux: second opaque data to provide the callback\n *\n * This queues the event on a given sequencer. Queued events are delivered one\n * per sequencer each subsequent time around the event loop, so the cb is called\n * from the event loop thread context.\n *\n * Notice that because the events are delivered in order from the event loop,\n * the scope of objects pointed to by \u005cp data or \u005cp aux may exceed the lifetime\n * of the thing containing the pointed-to data. So it's usually better to pass\n * values here.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_seq_queue_event(struct lws_sequencer *seq, lws_seq_events_t e, void *data,\n\t\t\t void *aux);\n\n/**\n * lws_seq_check_wsi() - check if wsi still extant\n *\n * \u005cparam seq: the sequencer interested in the wsi\n * \u005cparam wsi: the wsi we want to confirm hasn't closed yet\n *\n * Check if wsi still extant, by peeking in the message queue for a\n * LWSSEQ_WSI_CONN_CLOSE message about wsi. (Doesn't need to do the same for\n * CONN_FAIL since that will never have produced any messages prior to that).\n *\n * Use this to avoid trying to perform operations on wsi that have already\n * closed but we didn't get to that message yet.\n *\n * Returns 0 if not closed yet or 1 if it has closed but we didn't process the\n * close message yet.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_seq_check_wsi(struct lws_sequencer *seq, struct lws *wsi);\n\n#define LWSSEQTO_NONE 0\n\n/**\n * lws_seq_timeout_us() - set a timeout by which the sequence must have\n *\t\t\t\tcompleted by a different event or inform the\n *\t\t\t\tsequencer\n *\n * \u005cparam seq: The sequencer to set the timeout on\n * \u005cparam us: How many us in the future to fire the timeout\n *\t\tLWS_SET_TIMER_USEC_CANCEL \u003d cancel any existing timeout\n *\n * This api allows the sequencer to ask to be informed if it has not completed\n * or disabled its timeout after secs seconds. Lws will send a LWSSEQ_TIMED_OUT\n * event to the sequencer if the timeout expires.\n *\n * Typically the sequencer sets the timeout when starting a step, then waits to\n * hear a queued event informing it the step completed or failed. The timeout\n * provides a way to deal with the case the step neither completed nor failed\n * within the timeout period.\n *\n * Lws wsi timeouts are not really suitable for this since they are focused on\n * short-term protocol timeout protection and may be set and reset many times\n * in one transaction. Wsi timeouts also enforce closure of the wsi when they\n * trigger, sequencer timeouts have no side effect except to queue the\n * LWSSEQ_TIMED_OUT message and leave it to the sequencer to decide how to\n * react appropriately.\n */\nLWS_VISIBLE LWS_EXTERN int\nlws_seq_timeout_us(struct lws_sequencer *seq, lws_usec_t us);\n\n/**\n * lws_seq_from_user(): get the lws_seq_t pointer from the user ptr\n *\n * \u005cparam u: the sequencer user allocation returned by lws_seq_create() or\n *\t provided in the sequencer callback\n *\n * This gets the lws_seq_t * from the sequencer user allocation pointer.\n * Actually these are allocated at the same time in one step, with the user\n * allocation immediately after the lws_seq_t, so lws can compute where\n * the lws_seq_t is from having the user allocation pointer. Since the\n * size of the lws_seq_t is unknown to user code, this helper does it for\n * you.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_sequencer *\nlws_seq_from_user(void *u);\n\n/**\n * lws_seq_us_since_creation(): elapsed seconds since sequencer created\n *\n * \u005cparam seq: pointer to the lws_seq_t\n *\n * Returns the number of us elapsed since the lws_seq_t was\n * created. This is useful to calculate sequencer timeouts for the current\n * step considering a global sequencer lifetime limit.\n */\nLWS_VISIBLE LWS_EXTERN lws_usec_t\nlws_seq_us_since_creation(struct lws_sequencer *seq);\n\n/**\n * lws_seq_name(): get the name of this sequencer\n *\n * \u005cparam seq: pointer to the lws_seq_t\n *\n * Returns the name given when the sequencer was created. This is useful to\n * annotate logging when then are multiple sequencers in play.\n */\nLWS_VISIBLE LWS_EXTERN const char *\nlws_seq_name(struct lws_sequencer *seq);\n\n/**\n * lws_seq_get_context(): get the lws_context sequencer was created on\n *\n * \u005cparam seq: pointer to the lws_seq_t\n *\n * Returns the lws_context. Saves you having to store it if you have a seq\n * pointer handy.\n */\nLWS_VISIBLE LWS_EXTERN struct lws_context *\nlws_seq_get_context(struct lws_sequencer *seq);\n","s":{"c":1591076841,"u": 495}} ],"g": 3763,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}