From 27964ddaf2463794c46a12fe597533d27639f2f2 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Thu, 8 Oct 2020 14:06:43 +0100 Subject: [PATCH] ws: reporting PONG with pmd enabled Add a return code NOTHING_WE_SHOULD_DO indicating that the extension determined by ext-specific means its operation was disabled on this frame. https://github.com/warmcat/libwebsockets/issues/2076 --- lib/core-net/private-lib-core-net.h | 1 + lib/roles/ws/client-parser-ws.c | 1 + lib/roles/ws/ext/extension-permessage-deflate.c | 14 ++++++++++++-- lib/roles/ws/ops-ws.c | 4 +++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/core-net/private-lib-core-net.h b/lib/core-net/private-lib-core-net.h index cdbc1ba24..044b69803 100644 --- a/lib/core-net/private-lib-core-net.h +++ b/lib/core-net/private-lib-core-net.h @@ -174,6 +174,7 @@ enum pmd_return { PMDR_HAS_PENDING, PMDR_EMPTY_NONFINAL, PMDR_EMPTY_FINAL, + PMDR_NOTHING_WE_SHOULD_DO, PMDR_FAILED = -1 }; diff --git a/lib/roles/ws/client-parser-ws.c b/lib/roles/ws/client-parser-ws.c index cacadd298..688e1ebda 100644 --- a/lib/roles/ws/client-parser-ws.c +++ b/lib/roles/ws/client-parser-ws.c @@ -554,6 +554,7 @@ drain_extension: return -1; } if (n == PMDR_DID_NOTHING) + /* ie, not PMDR_NOTHING_WE_SHOULD_DO */ break; #endif lwsl_ext("%s: post inflate ebuf in len %d / out len %d\n", diff --git a/lib/roles/ws/ext/extension-permessage-deflate.c b/lib/roles/ws/ext/extension-permessage-deflate.c index 58fc7fa7a..de7fc1d41 100644 --- a/lib/roles/ws/ext/extension-permessage-deflate.c +++ b/lib/roles/ws/ext/extension-permessage-deflate.c @@ -192,10 +192,20 @@ lws_extension_callback_pm_deflate(struct lws_context *context, lwsl_ext(" %s: LWS_EXT_CB_PAYLOAD_RX: in %d, existing in %d\n", __func__, pmdrx->eb_in.len, priv->rx.avail_in); - /* if this frame is not marked as compressed, we ignore it */ + /* + * If this frame is not marked as compressed, + * there is nothing we should do with it + */ if (!(wsi->ws->rsv_first_msg & 0x40) || (wsi->ws->opcode & 8)) - return PMDR_DID_NOTHING; + /* + * This is a bit different than DID_NOTHING... we have + * identified using ext-private bits in the packet, or + * by it being a control fragment that we SHOULD not do + * anything to it, parent should continue as if we + * processed it + */ + return PMDR_NOTHING_WE_SHOULD_DO; /* * we shouldn't come back in here if we already applied the diff --git a/lib/roles/ws/ops-ws.c b/lib/roles/ws/ops-ws.c index 71fb1c72f..de6d098b9 100644 --- a/lib/roles/ws/ops-ws.c +++ b/lib/roles/ws/ops-ws.c @@ -633,6 +633,7 @@ drain_extension: return -1; } if (n == PMDR_DID_NOTHING) + /* ie, not PMDR_NOTHING_WE_SHOULD_DO */ break; #endif lwsl_debug("%s: post ext ret %d, ebuf in %d / out %d\n", @@ -693,7 +694,8 @@ utf8_fail: if (n == PMDR_DID_NOTHING #if !defined(LWS_WITHOUT_EXTENSIONS) - || + || + n == PMDR_NOTHING_WE_SHOULD_DO || n == PMDR_UNKNOWN #endif )