After this patch is applied, rpc-port closes the file descriptor when
Read() is failed.
Change-Id: I25c1a2878037a664c4bec8320f97bc1fafeef38b
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Port::~Port() {
ClearQueue();
- close(fd_);
+ Disconnect();
+}
+
+void Port::Disconnect() {
+ if (fd_ > 0) {
+ _W("Close fd(%d)", fd_);
+ close(fd_);
+ fd_ = -1;
+ }
}
int Port::SetPrivateSharing(const char* paths[], unsigned int size) {
Port(int fd, std::string id);
virtual ~Port();
+ void Disconnect();
int SetPrivateSharing(const char* paths[], unsigned int size);
int SetPrivateSharing(const char* path);
int UnsetPrivateSharing();
auto port = static_cast<Port*>(h);
uint32_t seq = 0;
int ret = port->Read(reinterpret_cast<uint32_t*>(&seq), sizeof(seq));
- if (ret < 0)
+ if (ret < 0) {
+ _E("IO Error");
+ port->Disconnect();
return ret;
+ }
ret = port->Read(buf, size);
- if (ret < 0)
+ if (ret < 0) {
+ _E("IO Error");
+ port->Disconnect();
return ret;
+ }
auto& debug_port = DebugPort::GetInst();
debug_port.Send(port->GetFd(), true, seq, buf, size);