Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
{"schema":"libjg2-1", "vpath":"/git/", "avatar":"/git/avatar/", "alang":"", "gen_ut":1713569122, "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":"e2f1f817853f938b4fe5719bfb494bbc", "commit": {"type":"commit", "time": 1525406756, "time_ofs": 480, "oid_tree": { "oid": "b163c9754260788ec457fd033c81eb39776b94ac", "alias": []}, "oid":{ "oid": "c99a99e9b47bc21c54910d1e4519e12f5eeeeef6", "alias": []}, "msg": "LRS_DOING_TRANSACTION", "sig_commit": { "git_time": { "time": 1525406756, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }, "sig_author": { "git_time": { "time": 1525406756, "offset": 480 }, "name": "Andy Green", "email": "andy@warmcat.com", "md5": "c50933ca2aa61e0fe2c43d46bb6b59cb" }}, "body": "LRS_DOING_TRANSACTION" , "diff": "diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c\nindex 8afd626..d3b16f4 100644\n--- a/lib/roles/h1/ops-h1.c\n+++ b/lib/roles/h1/ops-h1.c\n@@ -308,9 +308,9 @@ lws_h1_server_socket_service(struct lws *wsi, struct lws_pollfd *pollfd)\n \t lwsi_state(wsi) \u003d\u003d LRS_ISSUING_FILE ||\n \t lwsi_state(wsi) \u003d\u003d LRS_HEADERS ||\n \t lwsi_state(wsi) \u003d\u003d LRS_BODY)) {\n-\t\tif (!wsi-\u003ehttp.ah \u0026\u0026\n-\t\t lws_header_table_attach(wsi, 0)) {\n-\t\t\tlwsl_info(\u0022wsi %p: ah get fail\u005cn\u0022, wsi);\n+\n+\t\tif (!wsi-\u003ehttp.ah \u0026\u0026 lws_header_table_attach(wsi, 0)) {\n+\t\t\tlwsl_info(\u0022%s: wsi %p: ah not available\u005cn\u0022, __func__, wsi);\n \t\t\tgoto try_pollout;\n \t\t}\n \n@@ -319,6 +319,9 @@ lws_h1_server_socket_service(struct lws *wsi, struct lws_pollfd *pollfd)\n \t\t * regardless of our buflist state, we need to get it,\n \t\t * and either use it, or append to the buflist and use\n \t\t * buflist head material.\n+\t\t *\n+\t\t * We will not notice a connection close until the buflist is\n+\t\t * exhausted and we tried to do a read of some kind.\n \t\t */\n \n \t\tbuffered \u003d lws_buflist_aware_read(pt, wsi, \u0026ebuf);\n@@ -327,8 +330,20 @@ lws_h1_server_socket_service(struct lws *wsi, struct lws_pollfd *pollfd)\n \t\t\tlwsl_info(\u0022%s: read 0 len a\u005cn\u0022, __func__);\n \t\t\twsi-\u003eseen_zero_length_recv \u003d 1;\n \t\t\tlws_change_pollfd(wsi, LWS_POLLIN, 0);\n-\t\t\tgoto try_pollout;\n-\t\t\t//goto fail;\n+#if !defined(LWS_WITHOUT_EXTENSIONS)\n+\t\t\t/*\n+\t\t\t * autobahn requires us to win the race between close\n+\t\t\t * and draining the extensions\n+\t\t\t */\n+\t\t\tif (wsi-\u003ews \u0026\u0026\n+\t\t\t (wsi-\u003ews-\u003erx_draining_ext || wsi-\u003ews-\u003etx_draining_ext))\n+\t\t\t\tgoto try_pollout;\n+#endif\n+\t\t\t/*\n+\t\t\t * normally, we respond to close with logically closing\n+\t\t\t * our side immediately\n+\t\t\t */\n+\t\t\tgoto fail;\n \n \t\tcase LWS_SSL_CAPABLE_ERROR:\n \t\t\tgoto fail;\n@@ -469,7 +484,8 @@ try_pollout:\n \n \n fail:\n-\tlws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS, \u0022server socket svc fail\u0022);\n+\tlws_close_free_wsi(wsi, LWS_CLOSE_STATUS_NOSTATUS,\n+\t\t\t \u0022server socket svc fail\u0022);\n \n \treturn LWS_HPI_RET_WSI_ALREADY_DIED;\n }\ndiff --git a/lib/roles/http/server/parsers.c b/lib/roles/http/server/parsers.c\nindex 5754f90..054a839 100644\n--- a/lib/roles/http/server/parsers.c\n+++ b/lib/roles/http/server/parsers.c\n@@ -81,6 +81,8 @@ _lws_header_table_reset(struct allocated_headers *ah)\n \tah-\u003enfrag \u003d 0;\n \tah-\u003epos \u003d 0;\n \tah-\u003ehttp_response \u003d 0;\n+\tah-\u003eparser_state \u003d WSI_TOKEN_NAME_PART;\n+\tah-\u003elextable_pos \u003d 0;\n }\n \n // doesn't scrub the ah rxbuffer by default, parent must do if needed\n@@ -99,9 +101,6 @@ __lws_header_table_reset(struct lws *wsi, int autoservice)\n \n \t_lws_header_table_reset(ah);\n \n-\tah-\u003eparser_state \u003d WSI_TOKEN_NAME_PART;\n-\tah-\u003elextable_pos \u003d 0;\n-\n \t/* since we will restart the ah, our new headers are not completed */\n \twsi-\u003ehdr_parsing_completed \u003d 0;\n \n@@ -353,7 +352,7 @@ int __lws_header_table_detach(struct lws *wsi, int autoservice)\n \tif (!wsi) /* everybody waiting already has too many ah... */\n \t\tgoto nobody_usable_waiting;\n \n-\tlwsl_info(\u0022%s: last eligible wsi in wait list %p\u005cn\u0022, __func__, wsi);\n+\tlwsl_info(\u0022%s: transferring ah to last eligible wsi in wait list %p (wsistate 0x%x)\u005cn\u0022, __func__, wsi, wsi-\u003ewsistate);\n \n \twsi-\u003ehttp.ah \u003d ah;\n \tah-\u003ewsi \u003d wsi; /* new owner */\ndiff --git a/lib/roles/http/server/server.c b/lib/roles/http/server/server.c\nindex a308683..f55a137 100644\n--- a/lib/roles/http/server/server.c\n+++ b/lib/roles/http/server/server.c\n@@ -330,8 +330,8 @@ lws_select_vhost(struct lws_context *context, int port, const char *servername)\n \tvhost \u003d context-\u003evhost_list;\n \twhile (vhost) {\n \t\tif (port \u003d\u003d vhost-\u003elisten_port) {\n-\t\t\tlwsl_info(\u0022vhost match to %s based on port %d\u005cn\u0022,\n-\t\t\t\t\tvhost-\u003ename, port);\n+\t\t\tlwsl_info(\u0022%s: vhost match to %s based on port %d\u005cn\u0022,\n+\t\t\t\t\t__func__, vhost-\u003ename, port);\n \t\t\treturn vhost;\n \t\t}\n \t\tvhost \u003d vhost-\u003evhost_next;\n@@ -991,6 +991,8 @@ lws_http_action(struct lws *wsi)\n \t\tif (lws_bind_protocol(wsi, \u0026wsi-\u003evhost-\u003eprotocols[0]))\n \t\t\treturn 1;\n \n+\t\tlwsi_set_state(wsi, LRS_DOING_TRANSACTION);\n+\n \t\tn \u003d wsi-\u003eprotocol-\u003ecallback(wsi, LWS_CALLBACK_HTTP,\n \t\t\t\t wsi-\u003euser_space, uri_ptr, uri_len);\n \n@@ -1547,7 +1549,7 @@ raw_transition:\n \n \t\t/* no upgrade ack... he remained as HTTP */\n \n-\t\tlwsl_info(\u0022No upgrade\u005cn\u0022);\n+\t\tlwsl_info(\u0022%s: %p: No upgrade\u005cn\u0022, __func__, wsi);\n \n \t\tlwsi_set_state(wsi, LRS_ESTABLISHED);\n \t\twsi-\u003ehttp.fop_fd \u003d NULL;\n@@ -1742,7 +1744,8 @@ lws_http_transaction_completed(struct lws *wsi)\n \t * until we can verify POLLOUT. The part of this that confirms POLLOUT\n \t * with no partials is in lws_server_socket_service() below.\n \t */\n-\tlwsl_debug(\u0022%s: setting DEF_ACT from 0x%x\u005cn\u0022, __func__, wsi-\u003ewsistate);\n+\tlwsl_debug(\u0022%s: %p: setting DEF_ACT from 0x%x\u005cn\u0022, __func__,\n+\t\t wsi, wsi-\u003ewsistate);\n \tlwsi_set_state(wsi, LRS_DEFERRING_ACTION);\n \twsi-\u003ehttp.tx_content_length \u003d 0;\n \twsi-\u003ehttp.tx_content_remain \u003d 0;\n@@ -1770,7 +1773,8 @@ lws_http_transaction_completed(struct lws *wsi)\n \tif (wsi-\u003ehttp.ah) {\n \t\t// lws_buflist_describe(\u0026wsi-\u003ebuflist, wsi);\n \t\tif (!lws_buflist_next_segment_len(\u0026wsi-\u003ebuflist, NULL)) {\n-\t\t\tlwsl_debug(\u0022%s: nothing in buflist so detaching ah\u005cn\u0022, __func__);\n+\t\t\tlwsl_info(\u0022%s: %p: nothing in buflist so detaching ah\u005cn\u0022,\n+\t\t\t\t __func__, wsi);\n \t\t\tlws_header_table_detach(wsi, 1);\n #ifdef LWS_WITH_TLS\n \t\t\t/*\n@@ -1789,8 +1793,8 @@ lws_http_transaction_completed(struct lws *wsi)\n \t\t\t}\n #endif\n \t\t} else {\n-\t\t\tlwsl_debug(\u0022%s: resetting and keeping ah as pipeline\u005cn\u0022,\n-\t\t\t\t __func__);\n+\t\t\tlwsl_info(\u0022%s: %p: resetting and keeping ah as pipeline\u005cn\u0022,\n+\t\t\t\t __func__, wsi);\n \t\t\tlws_header_table_reset(wsi, 0);\n \t\t\t/*\n \t\t\t * If we kept the ah, we should restrict the amount\ndiff --git a/lib/roles/private.h b/lib/roles/private.h\nindex 4e0b312..ae4278b 100644\n--- a/lib/roles/private.h\n+++ b/lib/roles/private.h\n@@ -122,18 +122,27 @@ enum lwsi_state {\n \tLRS_HEADERS\t\t\t\t\u003d 21,\n \tLRS_BODY\t\t\t\t\u003d 22,\n \tLRS_ESTABLISHED\t\t\t\t\u003d LWSIFS_POCB | 23,\n+\t/* we are established, but we have embarked on serving a single\n+\t * transaction. Other transaction input may be pending, but we will\n+\t * not service it while we are busy dealing with the current\n+\t * transaction.\n+\t *\n+\t * When we complete the current transaction, we would reset our state\n+\t * back to ESTABLISHED and start to process the next transaction.\n+\t */\n+\tLRS_DOING_TRANSACTION\t\t\t\u003d LWSIFS_POCB | 24,\n \n \t/* Phase 6: finishing */\n \n-\tLRS_WAITING_TO_SEND_CLOSE\t\t\u003d LWSIFS_POCB | 24,\n-\tLRS_RETURNED_CLOSE\t\t\t\u003d LWSIFS_POCB | 25,\n-\tLRS_AWAITING_CLOSE_ACK\t\t\t\u003d LWSIFS_POCB | 26,\n-\tLRS_FLUSHING_BEFORE_CLOSE\t\t\u003d LWSIFS_POCB | 27,\n-\tLRS_SHUTDOWN\t\t\t\t\u003d 28,\n+\tLRS_WAITING_TO_SEND_CLOSE\t\t\u003d LWSIFS_POCB | 25,\n+\tLRS_RETURNED_CLOSE\t\t\t\u003d LWSIFS_POCB | 26,\n+\tLRS_AWAITING_CLOSE_ACK\t\t\t\u003d LWSIFS_POCB | 27,\n+\tLRS_FLUSHING_BEFORE_CLOSE\t\t\u003d LWSIFS_POCB | 28,\n+\tLRS_SHUTDOWN\t\t\t\t\u003d 29,\n \n \t/* Phase 7: dead */\n \n-\tLRS_DEAD_SOCKET\t\t\t\t\u003d 29,\n+\tLRS_DEAD_SOCKET\t\t\t\t\u003d 30,\n \n \tLRS_MASK\t\t\t\t\u003d 0xffff\n };\ndiff --git a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c\nindex 2b7fa4c..b7bdaac 100644\n--- a/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c\n+++ b/minimal-examples/http-server/minimal-http-server-dynamic/minimal-http-server-dynamic.c\n@@ -177,6 +177,10 @@ int main(int argc, const char **argv)\n \tinfo.protocols \u003d protocols;\n \tinfo.mounts \u003d \u0026mount;\n \n+\t/* for testing ah queue, not useful in real world */\n+\tif (lws_cmdline_option(argc, argv, \u0022--ah1\u0022))\n+\t\tinfo.max_http_header_pool \u003d 1;\n+\n \tcontext \u003d lws_create_context(\u0026info);\n \tif (!context) {\n \t\tlwsl_err(\u0022lws init failed\u005cn\u0022);\ndiff --git a/minimal-examples/raw/minimal-raw-netcat/minimal-raw-netcat.c b/minimal-examples/raw/minimal-raw-netcat/minimal-raw-netcat.c\nindex faffaa5..5bdf1be 100644\n--- a/minimal-examples/raw/minimal-raw-netcat/minimal-raw-netcat.c\n+++ b/minimal-examples/raw/minimal-raw-netcat/minimal-raw-netcat.c\n@@ -31,6 +31,7 @@ static struct lws *raw_wsi, *stdin_wsi;\n static uint8_t buf[LWS_PRE + 4096];\n static int waiting, interrupted;\n static struct lws_context *context;\n+static int us_wait_after_input_close \u003d LWS_USEC_PER_SEC / 10;\n \n static int\n callback_raw_test(struct lws *wsi, enum lws_callback_reasons reason,\n@@ -50,7 +51,7 @@ callback_raw_test(struct lws *wsi, enum lws_callback_reasons reason,\n \t\t/* stdin close, wait 1s then close the raw skt */\n \t\tstdin_wsi \u003d NULL; /* invalid now we close */\n \t\tif (raw_wsi)\n-\t\t\tlws_set_timer_usecs(raw_wsi, LWS_USEC_PER_SEC / 10);\n+\t\t\tlws_set_timer_usecs(raw_wsi, us_wait_after_input_close);\n \t\telse {\n \t\t\tinterrupted \u003d 1;\n \t\t\tlws_cancel_service(context);\n@@ -153,7 +154,7 @@ int main(int argc, const char **argv)\n \t\tlogs \u003d atoi(p);\n \n \tlws_set_log_level(logs, NULL);\n-\tlwsl_user(\u0022LWS minimal raw netcat [--server ip] [--port port]\u005cn\u0022);\n+\tlwsl_user(\u0022LWS minimal raw netcat [--server ip] [--port port] [-w ms]\u005cn\u0022);\n \n \tmemset(\u0026info, 0, sizeof info); /* otherwise uninitialized garbage */\n \tinfo.options \u003d LWS_SERVER_OPTION_EXPLICIT_VHOSTS;\n@@ -193,6 +194,9 @@ int main(int argc, const char **argv)\n \tif ((p \u003d lws_cmdline_option(argc, argv, \u0022--server\u0022)))\n \t\tserver \u003d p;\n \n+\tif ((p \u003d lws_cmdline_option(argc, argv, \u0022-w\u0022)))\n+\t\tus_wait_after_input_close \u003d 1000 * atoi(p);\n+\n \tn \u003d getaddrinfo(server, port, \u0026h, \u0026r);\n \tif (n) {\n \t\tlwsl_err(\u0022%s: problem resolving %s: %s\u005cn\u0022, __func__, \n","s":{"c":1713569122,"u": 8284}} ],"g": 9938,"chitpc": 0,"ehitpc": 0,"indexed":0 , "ab": 0, "si": 0, "db":0, "di":0, "sat":0, "lfc": "0000"}