Commit 8e980f1a authored by Michael Burkat's avatar Michael Burkat

potential fixes to memory leak

parent b60e1433
...@@ -75,6 +75,8 @@ public: ...@@ -75,6 +75,8 @@ public:
Message(Message&& other) = default; Message(Message&& other) = default;
Message& operator=(Message&& other) = default; Message& operator=(Message&& other) = default;
virtual ~Message() {}
protected: protected:
Version version_; Version version_;
Code code_; Code code_;
...@@ -150,12 +152,14 @@ private: ...@@ -150,12 +152,14 @@ private:
Request(); Request();
#ifdef LIBSTDCPP_SMARTPTR_LOCK_FIXME #ifdef LIBSTDCPP_SMARTPTR_LOCK_FIXME
public:
void associatePeer(const std::shared_ptr<Tcp::Peer>& peer) { void associatePeer(const std::shared_ptr<Tcp::Peer>& peer) {
if (peer_.use_count() > 0) if (peer_.use_count() > 0)
throw std::runtime_error("A peer was already associated to the response"); throw std::runtime_error("A peer was already associated to the response");
peer_ = peer; peer_ = peer;
} }
private:
#endif #endif
Method method_; Method method_;
...@@ -576,6 +580,7 @@ namespace Private { ...@@ -576,6 +580,7 @@ namespace Private {
Step(Message* request) Step(Message* request)
: message(request) : message(request)
{ } { }
virtual ~Step() {}
virtual State apply(StreamCursor& cursor) = 0; virtual State apply(StreamCursor& cursor) = 0;
...@@ -663,6 +668,8 @@ namespace Private { ...@@ -663,6 +668,8 @@ namespace Private {
ParserBase(const ParserBase& other) = delete; ParserBase(const ParserBase& other) = delete;
ParserBase(ParserBase&& other) = default; ParserBase(ParserBase&& other) = default;
virtual ~ParserBase() {}
bool feed(const char* data, size_t len); bool feed(const char* data, size_t len);
virtual void reset(); virtual void reset();
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
/* In a sense, a Prototype is just a class that provides a clone() method */ /* In a sense, a Prototype is just a class that provides a clone() method */
template<typename Class> template<typename Class>
struct Prototype { struct Prototype {
virtual ~Prototype() {}
virtual std::shared_ptr<Class> clone() const = 0; virtual std::shared_ptr<Class> clone() const = 0;
}; };
......
...@@ -417,6 +417,12 @@ Accept::parseRaw(const char *str, size_t len) { ...@@ -417,6 +417,12 @@ Accept::parseRaw(const char *str, size_t len) {
void void
Accept::write(std::ostream& os) const { Accept::write(std::ostream& os) const {
for (size_t i = 0; i < mediaRange_.size(); i++) {
os << mediaRange_[i].toString();
if (i != mediaRange_.size() - 1) {
os << ",";
}
}
} }
void void
......
...@@ -77,7 +77,6 @@ Registry::isRegistered(const std::string& name) { ...@@ -77,7 +77,6 @@ Registry::isRegistered(const std::string& name) {
Collection& Collection&
Collection::add(const std::shared_ptr<Header>& header) { Collection::add(const std::shared_ptr<Header>& header) {
headers.insert(std::make_pair(header->name(), header)); headers.insert(std::make_pair(header->name(), header));
return *this; return *this;
} }
......
...@@ -210,7 +210,7 @@ Listener::run() { ...@@ -210,7 +210,7 @@ Listener::run() {
int ready_fds = poller.poll(events, 128, std::chrono::milliseconds(-1)); int ready_fds = poller.poll(events, 128, std::chrono::milliseconds(-1));
if (ready_fds == -1) { if (ready_fds == -1) {
if (errno == EINTR && g_listen_fd == -1) return; if (errno == EINTR) continue;
throw Error::system("Polling"); throw Error::system("Polling");
} }
else if (ready_fds > 0) { else if (ready_fds > 0) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment