MINIFICPP-1263 - Fix for segfault#818
Conversation
|
|
||
| assert(LogTestController::getInstance().contains("HTTP operation timed out, with absolute timeout 3000ms")); | ||
|
|
||
| delete server; |
There was a problem hiding this comment.
Could you explain why does leaking it cause segfault?
Btw I think unique_ptr would be a nicer solution.
There was a problem hiding this comment.
it was just a temporary check, in no way did I intend it to be the solution
the segfault was (probably) caused by the CivetServer creating a load of threads and we just exited main like there is no tomorrow
| } | ||
| } | ||
| ~CivetLibrary() { | ||
| if (--getCounter() == 0) { |
There was a problem hiding this comment.
What's the motivation behind using a getter on our own private member?
There was a problem hiding this comment.
will make the getCounter static, we do not access a member though this getter, but a static library initialization counter
|
|
||
| return server; | ||
| void addHandler(const std::string& uri, CivetHandler* handler) { | ||
| handlers_.emplace_back(handler); |
There was a problem hiding this comment.
It's only fancy, but I prefer not to use emplace when inserting already existing objects as emplace calls explicit ctors as well and it's very easy to point the gun against ourselves.
There was a problem hiding this comment.
good advice, done
| stop_signal_.wait_for(lock, time, [&] {return terminate_.load();}); | ||
| } | ||
|
|
||
| bool isServerRunning() { |
|
|
||
| } | ||
| TestServer(std::string &port, std::string &rooturi, CivetHandler *handler) { | ||
| const char *options[] = {"document_root", ".", "listening_ports", port.c_str(), 0}; |
There was a problem hiding this comment.
I know this is old code, but as far as I see we could simply pass and std::vectorstd::string to Civetweb's ctor, so this could be something like:
std::vector<std::string> options = {"document_root", ".", "listening_ports", port};
server_ = utils::make_unique<CivetServer>(options);
The same applies to the above.
66d9d0c to
e856acd
Compare
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
For all changes:
Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
Has your PR been rebased against the latest commit within the target branch (typically master)?
Is your initial contribution a single, squashed commit?
For code changes:
For documentation related changes:
Note:
Please ensure that once the PR is submitted, you check travis-ci for build issues and submit an update to your PR as soon as possible.