Skip to content

Conversation

The-EDev
Copy link
Member

@The-EDev The-EDev commented Dec 2, 2021

This PR moves the file sending logic to the connection class and adds the necessary checks for errors or the need to close the connection and delete the object.

closes #291

@crow-clang-format
Copy link

crow-clang-format bot commented Dec 2, 2021

--- include/crow/http_response.h	(before formatting)
+++ include/crow/http_response.h	(after formatting)
@@ -246,6 +246,5 @@
         std::function<void()> complete_request_handler_;
         std::function<bool()> is_alive_helper_;
         static_file_info file_info;
-
     };
 } // namespace crow

@The-EDev The-EDev marked this pull request as ready for review December 2, 2021 17:38
Copy link
Collaborator

@luca-schlecker luca-schlecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good and functions as expected. 👍

@The-EDev The-EDev merged commit e07b966 into master Dec 4, 2021
@The-EDev The-EDev deleted the file_leak branch December 4, 2021 01:16
@The-EDev The-EDev mentioned this pull request Jan 11, 2022
The-EDev added a commit that referenced this pull request Jan 12, 2022
@The-EDev The-EDev mentioned this pull request Feb 8, 2022
@alexeimenshikh
Copy link

Clang 13 with Libc++.
I still see memory leaks when sending static files and when sending responses larger than 1Mb. Adding one line:

            res.end();
            is_writing = false;  // <---- this line
            res.clear();
            buffers_.clear();

at the end of functions do_write_static() and do_write_general() solves the problem.

@The-EDev
Copy link
Member Author

@alexeimenshikh Thanks for pointing this out, it's already been implemented in #332

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Streaming a response keeps not needed memory for longer than necessary
3 participants