Lines Matching refs:fd
43 FI_HILOGE("Close epoll fd failed, error:%{public}s, epollFd_:%{public}d", strerror(errno), epollFd_);
63 int32_t StreamServer::GetClientPid(int32_t fd) const
65 auto it = sessionss_.find(fd);
72 bool StreamServer::SendMsg(int32_t fd, NetPacket &pkt)
74 if (fd < 0) {
75 FI_HILOGE("The fd is less than 0");
78 auto ses = GetSession(fd);
80 FI_HILOGE("The fd:%{public}d not found, The message was discarded, errCode:%{public}d",
81 fd, SESSION_NOT_FOUND);
168 FI_HILOGE("Close server fd failed, error:%{public}s, serverFd:%{public}d", strerror(errno), serverFd);
172 FI_HILOGE("Close fd failed, error:%{public}s, toReturnClientFd:%{public}d", strerror(errno), toReturnClientFd);
183 void StreamServer::ReleaseSession(int32_t fd, epoll_event &ev)
185 auto secPtr = GetSession(fd);
188 DelSession(fd);
194 if (auto it = circleBufs_.find(fd); it != circleBufs_.end()) {
198 DeviceStatusService->DelEpoll(EPOLL_EVENT_SOCKET, fd);
199 if (close(fd) < 0) {
200 FI_HILOGE("Close fd failed, error:%{public}s, fd:%{public}d", strerror(errno), fd);
204 void StreamServer::OnPacket(int32_t fd, NetPacket &pkt)
206 auto sess = GetSession(fd);
211 void StreamServer::OnEpollRecv(int32_t fd, epoll_event &ev)
213 if (fd < 0) {
214 FI_HILOGE("Invalid fd:%{public}d", fd);
217 auto& buf = circleBufs_[fd];
220 ssize_t size = recv(fd, szBuf, MAX_PACKET_BUF_SIZE, MSG_DONTWAIT | MSG_NOSIGNAL);
225 OnReadPackets(buf, [this, fd](NetPacket &pkt) { this->OnPacket(fd, pkt); });
236 ReleaseSession(fd, ev);
248 int32_t fd = *static_cast<int32_t*>(ev.data.ptr);
249 if (fd < 0) {
250 FI_HILOGE("The fd less than 0, errCode:%{public}d", PARAM_INPUT_INVALID);
254 FI_HILOGI("EPOLLERR or EPOLLHUP, fd:%{public}d, ev.events:0x%{public}x", fd, ev.events);
255 ReleaseSession(fd, ev);
257 OnEpollRecv(fd, ev);
271 SessionPtr StreamServer::GetSession(int32_t fd) const
273 auto it = sessionss_.find(fd);
275 FI_HILOGE("Session not found, fd:%{public}d", fd);
284 int32_t fd = GetClientFd(pid);
285 if (fd <= 0) {
289 return GetSession(fd);
295 FI_HILOGI("pid:%{public}d, fd:%{public}d", ses->GetPid(), ses->GetFd());
296 int32_t fd = ses->GetFd();
297 if (fd < 0) {
298 FI_HILOGE("The fd is less than 0");
312 idxPids_[pid] = fd;
313 sessionss_[fd] = ses;
318 void StreamServer::DelSession(int32_t fd)
321 FI_HILOGI("fd:%{public}d", fd);
322 if (fd < 0) {
323 FI_HILOGE("The fd less than 0, errCode:%{public}d", PARAM_INPUT_INVALID);
326 int32_t pid = GetClientPid(fd);
330 auto it = sessionss_.find(fd);