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

server vfs: close: cleanup also at just_kill_connection

... and at transaction completion
This commit is contained in:
Andy Green 2019-11-16 08:20:48 +00:00
parent 25a2ce56e2
commit f04d18b5da
3 changed files with 16 additions and 1 deletions

View file

@ -201,7 +201,10 @@ lws_vfs_file_open(const struct lws_plat_file_ops *fops, const char *vfs_path,
static LWS_INLINE int
lws_vfs_file_close(lws_fop_fd_t *fop_fd)
{
return (*fop_fd)->fops->LWS_FOP_CLOSE(fop_fd);
if (*fop_fd && (*fop_fd)->fops)
return (*fop_fd)->fops->LWS_FOP_CLOSE(fop_fd);
return 0;
}
/**

View file

@ -345,6 +345,12 @@ __lws_close_free_wsi(struct lws *wsi, enum lws_close_status reason,
just_kill_connection:
#if defined(LWS_WITH_FILE_OPS) && (defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2))
if (lwsi_role_http(wsi) && lwsi_role_server(wsi) &&
wsi->http.fop_fd != NULL)
lws_vfs_file_close(&wsi->http.fop_fd);
#endif
#if defined(LWS_WITH_HTTP_PROXY)
if (wsi->http.buflist_post_body)
lws_buflist_destroy_all_segments(&wsi->http.buflist_post_body);

View file

@ -2224,6 +2224,12 @@ lws_http_transaction_completed(struct lws *wsi)
wsi->http.access_log.sent = 0;
#endif
#if defined(LWS_WITH_FILE_OPS) && (defined(LWS_ROLE_H1) || defined(LWS_ROLE_H2))
if (lwsi_role_http(wsi) && lwsi_role_server(wsi) &&
wsi->http.fop_fd != NULL)
lws_vfs_file_close(&wsi->http.fop_fd);
#endif
if (wsi->vhost->keepalive_timeout)
n = PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE;
lws_set_timeout(wsi, n, wsi->vhost->keepalive_timeout);