Proxy::~Proxy() {
LOGD("Proxy::~Proxy");
+ if (conn_timer_) {
+ g_source_remove(conn_timer_);
+ conn_timer_ = 0;
+ }
}
gboolean Proxy::OnSocketDisconnected(GIOChannel *gio, GIOCondition cond,
void Proxy::OnPortAppeared(const std::string& appid,
const std::string& port_name) {
LOGD("endpoint(%s), port_name(%s)", appid.c_str(), port_name.c_str());
+ if (conn_timer_) {
+ g_source_remove(conn_timer_);
+ conn_timer_ = 0;
+ }
if (listener_ == nullptr)
return;
return RPC_PORT_ERROR_IO_ERROR;
}
+ if (conn_timer_)
+ g_source_remove(conn_timer_);
+ conn_timer_ = g_timeout_add(10 * 1000, DbusNameTimeout, this);
+
return RPC_PORT_ERROR_NONE;
}
+gboolean Proxy::DbusNameTimeout(gpointer user_data) {
+ Proxy* obj = static_cast<Proxy*>(user_data);
+
+ LOGW("[__DbusNameTimeout__] endpoint(%s)", obj->target_appid_.c_str());
+ if (obj->listener_)
+ obj->listener_->OnRejected(obj->target_appid_);
+
+ obj->conn_timer_ = 0;
+ return G_SOURCE_REMOVE;
+}
+
Proxy::ProxyPort::ProxyPort(Proxy* parent, int fd, const std::string& id,
bool receive) : Port(fd, id), parent_(parent) {
Watch(receive);
gpointer data);
static gboolean OnDataReceived(GIOChannel *gio, GIOCondition cond,
gpointer data);
+ static gboolean DbusNameTimeout(gpointer user_data);
void OnPortAppeared(const std::string& appid,
const std::string& port_name) override;
void OnPortVanished(const std::string& appid,
FdBroker fd_broker_;
std::string target_appid_;
int fds_[2];
+ guint conn_timer_ = 0;
};
} // namespace internal