client http: extra read notification after close

https://github.com/warmcat/libwebsockets/issues/620
This commit is contained in:
Andy Green 2016-09-06 15:36:51 +08:00
parent 64dd359192
commit 723b3f16fa
3 changed files with 8 additions and 2 deletions

View file

@ -211,6 +211,7 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason)
wsi->u.http.fd = LWS_INVALID_FILE;
wsi->vhost->protocols->callback(wsi,
LWS_CALLBACK_CLOSED_HTTP, wsi->user_space, NULL, 0);
wsi->told_user_closed = 1;
}
if (wsi->socket_is_permanently_unusable ||
reason == LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY ||
@ -255,10 +256,13 @@ lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason)
wsi->user_space, NULL, 0);
wsi->vhost->protocols->callback(wsi, LWS_CALLBACK_CLOSED_HTTP,
wsi->user_space, NULL, 0);
wsi->told_user_closed = 1;
}
if (wsi->mode & LWSCM_FLAG_IMPLIES_CALLBACK_CLOSED_CLIENT_HTTP )
if (wsi->mode & LWSCM_FLAG_IMPLIES_CALLBACK_CLOSED_CLIENT_HTTP) {
wsi->vhost->protocols[0].callback(wsi, LWS_CALLBACK_CLOSED_CLIENT_HTTP,
wsi->user_space, NULL, 0);
wsi->told_user_closed = 1;
}
/*
* are his extensions okay with him closing? Eg he might be a mux

View file

@ -1383,6 +1383,7 @@ struct lws {
unsigned int favoured_pollin:1;
unsigned int sending_chunked:1;
unsigned int already_did_cce:1;
unsigned int told_user_closed:1;
#if defined(LWS_WITH_ESP8266)
unsigned int pending_send_completion:3;
unsigned int close_is_pending_send_completion:1;

View file

@ -968,7 +968,8 @@ read:
drain:
#ifndef LWS_NO_CLIENT
if (wsi->mode == LWSCM_HTTP_CLIENT_ACCEPTED) {
if (wsi->mode == LWSCM_HTTP_CLIENT_ACCEPTED &&
!wsi->told_user_closed) {
/*
* simply mark ourselves as having readable data