bakaid commented on a change in pull request #610: MINIFICPP-814 - Fixed
ListenHTTP and HTTPClient bugs, created tests f…
URL: https://github.com/apache/nifi-minifi-cpp/pull/610#discussion_r303800802
##########
File path: extensions/civetweb/processors/ListenHTTP.h
##########
@@ -163,10 +166,47 @@ class ListenHTTP : public core::Processor {
const struct mg_request_info *req_info_;
};
+ static int log_message(const struct mg_connection *conn, const char
*message) {
+ try {
+ struct mg_context* ctx = mg_get_context(conn);
+ /* CivetServer stores 'this' as the userdata when calling mg_start */
+ CivetServer* server = static_cast<CivetServer*>(mg_get_user_data(ctx));
+ if (server == nullptr) {
+ return 0;
+ }
+ std::shared_ptr<logging::Logger>* logger =
static_cast<std::shared_ptr<logging::Logger>*>(const_cast<void*>(server->getUserContext()));
+ if (logger == nullptr) {
+ return 0;
+ }
+ logging::LOG_ERROR((*logger)) << "CivetWeb error: " << message;
+ } catch (...) {
Review comment:
This is just best practice for C callbacks. Even if the logger currently
does not throw, it might do so in the future, and then we have a nice crash on
our hands. I think it is better to be defensive here.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services