return RPC_PORT_ERROR_INVALID_PARAMETER;
std::lock_guard<std::recursive_mutex> lock(GetMutex());
- if (listener_ != nullptr) {
+ if (HasRequested()) {
_D("Already requested");
return RPC_PORT_ERROR_INVALID_PARAMETER;
}
main_port_.reset();
delegate_port_.reset();
+ Cancel();
UnsetConnTimer();
int ret = Aul::PrepareStub(real_appid_, port_name_,
rpc_port_get_target_uid());
if (listener == nullptr)
return RPC_PORT_ERROR_INVALID_PARAMETER;
- if (listener_ != nullptr) {
- _W("Already requested");
+ std::lock_guard<std::recursive_mutex> lock(GetMutex());
+ if (HasRequested()) {
+ _D("Already requested");
return RPC_PORT_ERROR_INVALID_PARAMETER;
}
- std::lock_guard<std::recursive_mutex> lock(GetMutex());
listener_ = listener;
target_appid_ = std::move(appid);
port_name_ = std::move(port_name);
delete ptr;
}
+bool Proxy::HasRequested() const {
+ return listener_ != nullptr &&
+ (!main_port_ || !delegate_port_ || main_port_->GetFd() > 0);
+}
+
} // namespace internal
} // namespace rpc_port
std::shared_ptr<Proxy> GetSharedPtr();
gpointer CreateWeakPtr();
static void DestroyWeakPtr(gpointer data);
+ bool HasRequested() const;
private:
std::string port_name_;