{"schema":"libjg2-1",
"vpath":"/git/",
"avatar":"/git/avatar/",
"alang":"",
"gen_ut":1745556788,
"reponame":"sai",
"desc":"Sai lightweight distributed CI",
"owner": { "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },"url":"https://warmcat.com/repo/sai",
"f":3,
"items": [
{"schema":"libjg2-1",
"cid":"d6f831676d575c6a18f650819a08328f",
"commit": {"type":"commit",
"time": 1579117961,
"time_ofs": 0,
"oid_tree": { "oid": "adc9a2d6271c58009c4402e58905b02abec82cee", "alias": []},
"oid":{ "oid": "09ba5c67893a9871fb07a2cf222e9753992855fe", "alias": []},
"msg": "freertos: lws_cancel_service udp as pipe",
"sig_commit": { "git_time": { "time": 1579117961, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" },
"sig_author": { "git_time": { "time": 1579077088, "offset": 0 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }},
"body": "freertos: lws_cancel_service udp as pipe\n\nFreertos + lwip doesn't support pipe2() or pipe()... implement a \u0022pipe\u0022\nbased on two UDP sockets, one listening on 127.0.0.1:54321 and the other\ndoing a sendto() there of a single byte to interrupt the event loop wait.\n\nRe-use the arrangements for actual pipe fds and pipe role to deliver\nlws_cancel_service() functionality using this."
,
"diff": "diff --git a/lib/core-net/vhost.c b/lib/core-net/vhost.c\nindex ede8e0e..ce417df 100644\n--- a/lib/core-net/vhost.c\n+++ b/lib/core-net/vhost.c\n@@ -881,9 +881,14 @@ lws_create_event_pipes(struct lws_context *context)\n \t * not bound to a vhost or protocol (both are NULL)\n \t */\n \n+#if LWS_MAX_SMP \u003e 1\n \tfor (n \u003d 0; n \u003c context-\u003ecount_threads; n++) {\n+#else\n+\tn \u003d 0;\n+\t{\n+#endif\n \t\tif (context-\u003ept[n].pipe_wsi)\n-\t\t\tcontinue;\n+\t\t\treturn 0;\n \n \t\twsi \u003d lws_zalloc(sizeof(*wsi), \u0022event pipe wsi\u0022);\n \t\tif (!wsi) {\n@@ -900,7 +905,7 @@ lws_create_event_pipes(struct lws_context *context)\n \t\tcontext-\u003ept[n].pipe_wsi \u003d wsi;\n \t\tcontext-\u003ecount_wsi_allocated++;\n \n-\t\tif (lws_plat_pipe_create(wsi))\n+\t\tif (!lws_plat_pipe_create(wsi)) {\n \t\t\t/*\n \t\t\t * platform code returns 0 if it actually created pipes\n \t\t\t * and initialized pt-\u003edummy_pipe_fds[]. If it used\n@@ -909,17 +914,17 @@ lws_create_event_pipes(struct lws_context *context)\n \t\t\t * related to dummy_pipe_fds[], adding it to the fds,\n \t\t\t * etc.\n \t\t\t */\n-\t\t\tcontinue;\n \n-\t\twsi-\u003edesc.sockfd \u003d context-\u003ept[n].dummy_pipe_fds[0];\n-\t\tlwsl_debug(\u0022event pipe fd %d\u005cn\u0022, wsi-\u003edesc.sockfd);\n+\t\t\twsi-\u003edesc.sockfd \u003d context-\u003ept[n].dummy_pipe_fds[0];\n+\t\t\tlwsl_debug(\u0022event pipe fd %d\u005cn\u0022, wsi-\u003edesc.sockfd);\n \n-\t\tif (context-\u003eevent_loop_ops-\u003esock_accept)\n-\t\t\tif (context-\u003eevent_loop_ops-\u003esock_accept(wsi))\n-\t\t\t\treturn 1;\n+\t\t\tif (context-\u003eevent_loop_ops-\u003esock_accept)\n+\t\t\t\tif (context-\u003eevent_loop_ops-\u003esock_accept(wsi))\n+\t\t\t\t\treturn 1;\n \n-\t\tif (__insert_wsi_socket_into_fds(context, wsi))\n-\t\t\treturn 1;\n+\t\t\tif (__insert_wsi_socket_into_fds(context, wsi))\n+\t\t\t\treturn 1;\n+\t\t}\n \t}\n \n \treturn 0;\ndiff --git a/lib/core/context.c b/lib/core/context.c\nindex 385d97e..ea926fd 100644\n--- a/lib/core/context.c\n+++ b/lib/core/context.c\n@@ -619,11 +619,9 @@ lws_create_context(const struct lws_context_creation_info *info)\n \t\t\t\tgoto bail;\n \t\t}\n \n-#if !defined(LWS_AMAZON_RTOS)\n \tif (lws_create_event_pipes(context))\n \t\tgoto bail;\n #endif\n-#endif\n \n \tlws_context_init_ssl_library(info);\n \ndiff --git a/lib/core/private-lib-core.h b/lib/core/private-lib-core.h\nindex 702d15d..5366da9 100644\n--- a/lib/core/private-lib-core.h\n+++ b/lib/core/private-lib-core.h\n@@ -314,6 +314,10 @@ struct lws_context {\n \tlws_retry_bo_t\tdefault_retry;\n \tlws_sorted_usec_list_t sul_system_state;\n \n+#if defined(LWS_PLAT_FREERTOS)\n+\tstruct sockaddr_in frt_pipe_si;\n+#endif\n+\n #if defined(LWS_WITH_HTTP2)\n \tstruct http2_settings set;\n #endif\ndiff --git a/lib/plat/freertos/freertos-pipe.c b/lib/plat/freertos/freertos-pipe.c\nindex 92f99fb..6a98c56 100644\n--- a/lib/plat/freertos/freertos-pipe.c\n+++ b/lib/plat/freertos/freertos-pipe.c\n@@ -1,7 +1,7 @@\n /*\n * libwebsockets - small server side websockets and web server implementation\n *\n- * Copyright (C) 2010 - 2019 Andy Green \u003candy@warmcat.com\u003e\n+ * Copyright (C) 2010 - 2020 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@@ -27,16 +27,81 @@\n int\n lws_plat_pipe_create(struct lws *wsi)\n {\n+\tstruct lws_context_per_thread *pt \u003d \u0026wsi-\u003econtext-\u003ept[(int)wsi-\u003etsi];\n+\tstruct sockaddr_in *si \u003d \u0026wsi-\u003econtext-\u003efrt_pipe_si;\n+\tlws_sockfd_type *fd \u003d pt-\u003edummy_pipe_fds;\n+\n+\t/*\n+\t * There's no pipe abstraction on lwip / freertos... use a UDP socket\n+\t * listening on 127.0.0.1:54321 and send a byte to it from a second UDP\n+\t * socket to cancel the wait.\n+\t */\n+\n+\tfd[0] \u003d socket(AF_INET, SOCK_DGRAM, 0);\n+\tif (fd[0] \u003c 0)\n+\t\tgoto bail;\n+\n+\tfd[1] \u003d socket(AF_INET, SOCK_DGRAM, 0);\n+\tif (fd[1] \u003c 0)\n+\t\tgoto bail;\n+\n+\t/*\n+\t * No need for memset since it's in zalloc'd context... it's in the\n+\t * context so we can reuse the prepared sockaddr to send tp fd[0] whem\n+\t * we want to cancel the wait\n+\t */\n+\n+\tsi-\u003esin_family \u003d AF_INET;\n+\tsi-\u003esin_addr.s_addr \u003d htonl(INADDR_LOOPBACK);\n+\tsi-\u003esin_port \u003d htons(54321);\n+\n+\tif (bind(fd[0], (const struct sockaddr *)si, sizeof(*si)) \u003c 0)\n+\t\tgoto bail;\n+\n+\treturn 0;\n+\n+bail:\n+\tlwsl_err(\u0022%s: failed\u005cn\u0022, __func__);\n+\n \treturn 1;\n }\n \n int\n lws_plat_pipe_signal(struct lws *wsi)\n {\n-\treturn 1;\n+\tstruct lws_context_per_thread *pt \u003d \u0026wsi-\u003econtext-\u003ept[(int)wsi-\u003etsi];\n+\tstruct sockaddr_in *si \u003d \u0026wsi-\u003econtext-\u003efrt_pipe_si;\n+\tlws_sockfd_type *fd \u003d pt-\u003edummy_pipe_fds;\n+\tuint8_t u \u003d 0;\n+\tint n;\n+\n+\t/*\n+\t * Send a single UDP byte payload to the listening socket fd[0], forcing\n+\t * the event loop wait to wake. fd[1] and context-\u003efrt_pipe_si are\n+\t * set at context creation and are static, the UDP sendto is supposed to\n+\t * be threadsafe for lwip:\n+\t *\n+\t * https://lwip.fandom.com/wiki/LwIP_and_multithreading\n+\t *\n+\t * Sockets generally can't be used by more than one application thread\n+\t * (on udp/raw netconn, doing a sendto/recv is currently possible).\n+\t */\n+\n+\tn \u003d sendto(fd[1], \u0026u, 1, 0, (struct sockaddr *)si, sizeof(*si));\n+\n+\treturn n !\u003d 1;\n }\n \n void\n lws_plat_pipe_close(struct lws *wsi)\n {\n+\tstruct lws_context_per_thread *pt \u003d \u0026wsi-\u003econtext-\u003ept[(int)wsi-\u003etsi];\n+\tlws_sockfd_type *fd \u003d pt-\u003edummy_pipe_fds;\n+\n+\tif (fd[0] \u0026\u0026 fd[0] !\u003d -1)\n+\t\tclose(fd[0]);\n+\tif (fd[1] \u0026\u0026 fd[1] !\u003d -1)\n+\t\tclose(fd[1]);\n+\n+\tfd[0] \u003d fd[1] \u003d -1;\n }\n","s":{"c":1745556788,"u": 4795}}
],"g": 6028,"chitpc": 0,"ehitpc": 0,"indexed":0
,
"ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}