Lines Matching refs:fd
66 #define SAFE_FD_ISSET(fd, set) (((fd) == -1) ? false : FD_ISSET((fd), (set))) argument
138 int fd; in accept_server_socket() local
144 pfd.fd = sfd; in accept_server_socket()
154 OSI_NO_INTR(fd = accept(sfd, (struct sockaddr*)&remote, &len)); in accept_server_socket()
155 if (fd == -1) { in accept_server_socket()
163 setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&size, (int)sizeof(size)); in accept_server_socket()
168 return fd; in accept_server_socket()
201 p->fd = UIPC_DISCONNECTED; in uipc_main_init()
242 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in uipc_check_fd_locked()
243 log::debug("CLOSE CONNECTION (FD {})", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
244 close(uipc.ch[ch_id].fd); in uipc_check_fd_locked()
245 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_check_fd_locked()
246 uipc.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_check_fd_locked()
249 uipc.ch[ch_id].fd = accept_server_socket(uipc.ch[ch_id].srvfd); in uipc_check_fd_locked()
251 log::debug("NEW FD {}", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
253 if ((uipc.ch[ch_id].fd >= 0) && uipc.ch[ch_id].cback) { in uipc_check_fd_locked()
256 log::debug("ADD FD {} TO ACTIVE SET", uipc.ch[ch_id].fd); in uipc_check_fd_locked()
257 FD_SET(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_check_fd_locked()
258 uipc.max_fd = MAX(uipc.max_fd, uipc.ch[ch_id].fd); in uipc_check_fd_locked()
261 if (uipc.ch[ch_id].fd < 0) { in uipc_check_fd_locked()
269 if (SAFE_FD_ISSET(uipc.ch[ch_id].fd, &uipc.read_set)) { in uipc_check_fd_locked()
294 int fd; in uipc_setup_server_locked() local
302 fd = create_server_socket(name); in uipc_setup_server_locked()
304 if (fd < 0) { in uipc_setup_server_locked()
309 log::debug("ADD SERVER FD TO ACTIVE SET {}", fd); in uipc_setup_server_locked()
310 FD_SET(fd, &uipc.active_set); in uipc_setup_server_locked()
311 uipc.max_fd = MAX(uipc.max_fd, fd); in uipc_setup_server_locked()
313 uipc.ch[ch_id].srvfd = fd; in uipc_setup_server_locked()
328 pfd.fd = uipc.ch[ch_id].fd; in uipc_flush_ch_locked()
330 if (uipc.ch[ch_id].fd == UIPC_DISCONNECTED) { in uipc_flush_ch_locked()
347 log::verbose("polling fd {}, revents: 0x{:x}, ret {}", pfd.fd, pfd.revents, in uipc_flush_ch_locked()
356 (void)read(pfd.fd, &buf, UIPC_FLUSH_BUFFER_SIZE); in uipc_flush_ch_locked()
389 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in uipc_close_ch_locked()
390 log::debug("CLOSE CONNECTION (FD {})", uipc.ch[ch_id].fd); in uipc_close_ch_locked()
391 close(uipc.ch[ch_id].fd); in uipc_close_ch_locked()
392 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in uipc_close_ch_locked()
393 uipc.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
588 OSI_NO_INTR(ret = write(uipc.ch[ch_id].fd, p_buf, msglen)); in UIPC_Send()
615 int fd = uipc.ch[ch_id].fd; in UIPC_Read() local
618 if (fd == UIPC_DISCONNECTED) { in UIPC_Read()
624 pfd.fd = fd; in UIPC_Read()
650 OSI_NO_INTR(n = recv(fd, p_buf + n_read, len - n_read, 0)); in UIPC_Read()
692 if (uipc.ch[ch_id].fd != UIPC_DISCONNECTED) { in UIPC_Ioctl()
694 FD_CLR(uipc.ch[ch_id].fd, &uipc.active_set); in UIPC_Ioctl()