gboolean Proxy::OnSocketDisconnected(GIOChannel *gio, GIOCondition cond,
gpointer data) {
Proxy* proxy = static_cast<Proxy*>(data);
+ IEventListener* listener = proxy->listener_;
LOGW("Socket was disconnected");
- proxy->listener_->OnDisconnected(proxy->target_appid_);
+ proxy->listener_ = nullptr;
proxy->disconn_src_ = 0;
-
+ listener->OnDisconnected(proxy->target_appid_);
return FALSE;
}
if (recv(fd, buffer, sizeof(buffer), MSG_PEEK | MSG_DONTWAIT) == 0) {
LOGW("Socket was disconnected by stub");
- proxy->listener_->OnDisconnected(proxy->target_appid_);
+ IEventListener* listener = proxy->listener_;
+ proxy->listener_ = nullptr;
proxy->src_ = 0;
+ listener->OnDisconnected(proxy->target_appid_);
return FALSE;
}
void Proxy::OnPortRejected(const std::string& appid) {
if (listener_ == nullptr)
return;
- listener_->OnRejected(appid);
+
+ IEventListener* listener = listener_;
listener_ = nullptr;
+ listener->OnRejected(appid);
}
void Proxy::OnPortAppeared(const std::string& appid,
int fd = fd_broker_.Send(appid, port_name);
if (fd <= 0) {
- listener_->OnRejected(appid);
+ IEventListener* listener = listener_;
listener_ = nullptr;
+ listener->OnRejected(appid);
return;
}