Skip to content

Commit

Permalink
fix memory leak in Waker move assignment (#42)
Browse files Browse the repository at this point in the history
* fix memory leak in Waker move assignment

* add a debug codesign for MacOS Instruments
  • Loading branch information
Congyuwang authored Jul 28, 2023
1 parent eb48c86 commit 8059bb1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/echo_server/debug.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict><key>com.apple.security.get-task-allow</key><true/></dict></plist>
1 change: 1 addition & 0 deletions examples/echo_server/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ build:
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
cmake --build build --parallel 4 --config Release --verbose
codesign -s - -v -f --entitlements debug.plist ./build/echo_server

run:
SOCKET_LOG=info ./build/echo_server
3 changes: 3 additions & 0 deletions socket_manager/waker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ namespace socket_manager {
}

Waker &Waker::operator=(Waker &&other) noexcept {
if (waker.Data != nullptr && waker.Vtable != nullptr) {
socket_manager_waker_free(waker);
}
waker = other.waker;
other.waker.Data = nullptr;
other.waker.Vtable = nullptr;
Expand Down

0 comments on commit 8059bb1

Please sign in to comment.