Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
kpschoedel committed Jun 22, 2021
1 parent 0689964 commit 3087153
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/platform/Linux/MdnsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,18 @@ AvahiWatch * Poller::WatchNew(int fd, AvahiWatchEvent event, AvahiWatchCallback
{
VerifyOrDie(callback != nullptr && fd >= 0);

AvahiWatch * const watch = new AvahiWatch;
auto watch = std::make_unique<AvahiWatch>();
watch->mSocket.Init(*mWatchableEvents)
.Attach(fd)
.SetCallback(AvahiWatchCallbackTrampoline, reinterpret_cast<intptr_t>(watch))
.SetCallback(AvahiWatchCallbackTrampoline, reinterpret_cast<intptr_t>(watch.get()))
.RequestCallbackOnPendingRead(event & AVAHI_WATCH_IN)
.RequestCallbackOnPendingWrite(event & AVAHI_WATCH_OUT);
watch->mCallback = callback;
watch->mContext = context;
watch->mPoller = this;
mWatches.emplace_back(watch);
mWatches.emplace_back(std::move(watch));

return watch;
return mWatches.back().get();
}

void Poller::WatchUpdate(AvahiWatch * watch, AvahiWatchEvent event)
Expand Down
6 changes: 0 additions & 6 deletions src/platform/Linux/MdnsImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,7 @@

struct AvahiWatch
{
#if 1
chip::System::WatchableSocket mSocket;
#else
int mFd; ///< The file descriptor to watch.
AvahiWatchEvent mWatchEvents; ///< The interested events.
int mHappenedEvents; ///< The events happened.
#endif
AvahiWatchCallback mCallback; ///< The function to be called when interested events happened on mFd.
void * mContext; ///< A pointer to application-specific context.
void * mPoller; ///< The poller created this watch.
Expand Down

0 comments on commit 3087153

Please sign in to comment.