Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/pistache/mailbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ class Queue {

virtual ~Queue() {
while (auto *e = pop()) delete e;
delete tail;
}

template<typename U>
Expand Down
1 change: 1 addition & 0 deletions src/server/listener.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ Listener::bind(const Address& address) {
TRY(::listen(fd, backlog_));
break;
}
freeaddrinfo(addrs);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works in the common case, but will still fail to clean up resources if the "::listen()" fails 2 lines above (the 'TRY' macro will throw a different exception).

I suggest that you encapsulate 'getaddrinfo' into a RAII class so that it will clean itself up no matter how the method exits.


make_non_blocking(fd);
poller.addFd(fd, Polling::NotifyOn::Read, Polling::Tag(fd));
Expand Down