Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1753412888, "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", "oid":{ "oid": "e3aec587600a57d571e103614f06245b61a5c976", "alias": [ "refs/heads/main"]},"tree": [ { "name": "async-dns","mode": "16384", "size":0}, { "name": "dhcpclient","mode": "16384", "size":0}, { "name": "fault-injection","mode": "16384", "size":0}, { "name": "metrics","mode": "16384", "size":0}, { "name": "ntpclient","mode": "16384", "size":0}, { "name": "ota","mode": "16384", "size":0}, { "name": "smd","mode": "16384", "size":0}, { "name": "CMakeLists.txt","mode": "33188", "size":2268}, { "name": "README.md","mode": "33188", "size":2410}, { "name": "system.c","mode": "33188", "size":5790}],"s":{"c":1753412888,"u": 373}} ,{"schema":"libjg2-1", "cid":"68c47d1eb21828fcac3caff2ed986020", "oid":{ "oid": "e3aec587600a57d571e103614f06245b61a5c976", "alias": [ "refs/heads/main"]},"blobname": "lib/system/README.md", "blob": "# LWS System Helpers\n\nLws now has a little collection of helper utilities for common network-based\nfunctions necessary for normal device operation, eg, async DNS, ntpclient\n(necessary for tls validation), and DHCP client.\n\n## Conventions\n\nIf any system helper is enabled for build, lws creates an additional vhost\n\u0022system\u0022 at Context Creation time. Wsi that are created for the system\nfeatures are bound to this. In the context object, this is available as\n`.vhost_system`.\n\n# Attaching to an existing context from other threads\n\nTo simplify the case different pieces of code want to attach to a single\nlws_context at runtime, from different thread contexts, lws_system has an api\nvia an lws_system operation function pointer where the other threads can use\nplatform-specific locking to request callbacks to their own code from the\nlws event loop thread context safely.\n\nFor convenience, the callback can be delayed until the system has entered or\npassed a specified system state, eg, LWS_SYSTATE_OPERATIONAL so the code will\nonly get called back after the network, ntpclient and auth have been done.\nAdditionally an opaque pointer can be passed to the callback when it is called\nfrom the lws event loop context.\n\n## Implementing the system-specific locking\n\n`lws_system_ops_t` struct has a member `.attach`\n\n```\n\tint (*attach)(struct lws_context *context, int tsi, lws_attach_cb_t *cb,\n\t\t lws_system_states_t state, void *opaque,\n\t\t struct lws_attach_item **get);\n```\n\nThis should be defined in user code as setting locking, then passing the\narguments through to a non-threadsafe helper\n\n```\nint\n__lws_system_attach(struct lws_context *context, int tsi, lws_attach_cb_t *cb,\n\t\t lws_system_states_t state, void *opaque,\n\t\t struct lws_attach_item **get);\n```\n\nthat does the actual attach work. When it returns, the locking should be\nunlocked and the return passed back.\n\n## Attaching the callback request\n\nUser code should call the lws_system_ops_t `.attach` function like\n\n```\n\tlws_system_get_ops(context)-\u003eattach(...);\n```\n\nThe callback function which will be called from the lws event loop context\nshould look like this\n\n```\nvoid my_callback(struct lws_context *context, int tsi, void *opaque);\n```\n\nwith the callback function name passed into the (*attach)() call above. When\nthe callback happens, the opaque user pointer set at the (*attach)() call is\npassed back to it as an argument.\n","s":{"c":1753412888,"u": 211}} ],"g": 2190,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 1, "si": 0, "db":0, "di":1, "sat":0, "lfc": "0000"}