adamdebreceni commented on code in PR #1826:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1826#discussion_r1867953013
##########
extensions/civetweb/processors/ListenHTTP.h:
##########
@@ -165,28 +192,66 @@ class ListenHTTP : public core::Processor {
* Sets a static response body string to be used for a given URI, with a
number of seconds it will be kept in memory.
* @param response
*/
- void setResponseBody(const ResponseBody& response);
+ bool setResponseBody(const ResponseBody& response);
+
+ bool dequeueRequest(Request& req);
+
+ size_t requestCount() const {
+ return request_buffer_.size();
+ }
+
+ bool empty() const {
+ return request_buffer_.empty();
+ }
- bool dequeueRequest(FlowFileBufferPair &flow_file_buffer_pair);
+ void stop() {
+ request_buffer_.stop();
+ Request req;
+ while (dequeueRequest(req)) {
+ std::promise<void> req_done_promise;
+ auto req_done = req_done_promise.get_future();
+
req.set_value(nonstd::make_unexpected(FailureValue{Handler::FailureReason::PROCESSOR_SHUTDOWN,
std::move(req_done_promise)}));
+ req_done.wait();
+ }
+ }
private:
static void sendHttp500(struct mg_connection *conn);
static void sendHttp503(struct mg_connection *conn);
bool authRequest(mg_connection *conn, const mg_request_info *req_info)
const;
void setHeaderAttributes(const mg_request_info *req_info, core::FlowFile&
flow_file) const;
- void writeBody(mg_connection *conn, const mg_request_info *req_info, bool
include_payload = true);
- static std::unique_ptr<io::BufferStream> createContentBuffer(struct
mg_connection *conn, const struct mg_request_info *req_info);
- void enqueueRequest(mg_connection *conn, const mg_request_info *req_info,
std::unique_ptr<io::BufferStream>);
+ void writeBody(core::ProcessSession* payload_reader, mg_connection *conn,
const mg_request_info *req_info);
+ void enqueueRequest(mg_connection *conn, const mg_request_info *req_info,
bool write_body);
+
+ class RequestBuffer : public utils::ConcurrentQueue<Request> {
Review Comment:
removed the inheritance, unfortunately we have to employ a lock, as it can
happen that we check `running_` on new incoming connection, which is true, then
we call `notifyStop`, empty the queue, and only then enqueue the request,
leaving it hanging, the ConditionalConcurrentQueue variant sadly does not solve
this problem
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]