1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

nossl recv: always respond to 0 length read as shutdown

This commit is contained in:
Andy Green 2019-03-21 06:47:54 +08:00
parent 462847bb6f
commit b227d10187
2 changed files with 13 additions and 1 deletions

View file

@ -250,6 +250,7 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
lws_stats_atomic_bump(context, pt, LWSSTATS_C_API_READ, 1);
errno = 0;
if (lws_wsi_is_udp(wsi)) {
#if !defined(LWS_WITH_ESP32) && !defined(LWS_PLAT_OPTEE)
wsi->udp->salen = sizeof(wsi->udp->sa);
@ -264,6 +265,13 @@ lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len)
if (!n && wsi->unix_skt)
return LWS_SSL_CAPABLE_ERROR;
/*
* See https://libwebsockets.org/
* pipermail/libwebsockets/2019-March/007857.html
*/
if (!n)
return LWS_SSL_CAPABLE_ERROR;
if (wsi->vhost)
wsi->vhost->conn_stats.rx += n;
lws_stats_atomic_bump(context, pt, LWSSTATS_B_READ, n);

View file

@ -146,7 +146,8 @@ int main(int argc, const char **argv)
memset(&i, 0, sizeof i); /* otherwise uninitialized garbage */
i.context = context;
i.ssl_connection = LCCSCF_USE_SSL;
if (!lws_cmdline_option(argc, argv, "-n"))
i.ssl_connection = LCCSCF_USE_SSL;
if (lws_cmdline_option(argc, argv, "-l")) {
i.port = 7681;
@ -160,6 +161,9 @@ int main(int argc, const char **argv)
if (lws_cmdline_option(argc, argv, "--h1"))
i.alpn = "http/1.1";
if ((p = lws_cmdline_option(argc, argv, "-p")))
i.port = atoi(p);
i.path = "/";
i.host = i.address;
i.origin = i.address;