Lines Matching refs:uipc_main
63 #define UIPC_LOCK() /*BTIF_TRACE_EVENT(" %s lock", __FUNCTION__);*/ pthread_mutex_lock(&uipc_main.m…
64 …C_UNLOCK() /*BTIF_TRACE_EVENT("%s unlock", __FUNCTION__);*/ pthread_mutex_unlock(&uipc_main.mutex);
107 static tUIPC_MAIN uipc_main; variable
223 pthread_mutex_init(&uipc_main.mutex, &attr); in uipc_main_init()
228 if (socketpair(AF_UNIX, SOCK_STREAM, 0, uipc_main.signal_fds) < 0) in uipc_main_init()
233 FD_SET(uipc_main.signal_fds[0], &uipc_main.active_set); in uipc_main_init()
234 uipc_main.max_fd = MAX(uipc_main.max_fd, uipc_main.signal_fds[0]); in uipc_main_init()
238 tUIPC_CHAN *p = &uipc_main.ch[i]; in uipc_main_init()
256 close(uipc_main.signal_fds[0]); in uipc_main_cleanup()
257 close(uipc_main.signal_fds[1]); in uipc_main_cleanup()
274 if (uipc_main.ch[i].task_evt_flags & UIPC_TASK_FLAG_DISCONNECT_CHAN) in uipc_check_task_flags_locked()
276 uipc_main.ch[i].task_evt_flags &= ~UIPC_TASK_FLAG_DISCONNECT_CHAN; in uipc_check_task_flags_locked()
293 if (SAFE_FD_ISSET(uipc_main.ch[ch_id].srvfd, &uipc_main.read_set)) in uipc_check_fd_locked()
297 uipc_main.ch[ch_id].fd = accept_server_socket(uipc_main.ch[ch_id].srvfd); in uipc_check_fd_locked()
299 BTIF_TRACE_EVENT("NEW FD %d", uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
301 if ((uipc_main.ch[ch_id].fd > 0) && uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
305 BTIF_TRACE_EVENT("ADD FD %d TO ACTIVE SET", uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
306 FD_SET(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in uipc_check_fd_locked()
307 uipc_main.max_fd = MAX(uipc_main.max_fd, uipc_main.ch[ch_id].fd); in uipc_check_fd_locked()
310 if (uipc_main.ch[ch_id].fd < 0) in uipc_check_fd_locked()
316 if (uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
317 uipc_main.ch[ch_id].cback(ch_id, UIPC_OPEN_EVT); in uipc_check_fd_locked()
322 if (SAFE_FD_ISSET(uipc_main.ch[ch_id].fd, &uipc_main.read_set)) in uipc_check_fd_locked()
326 if (uipc_main.ch[ch_id].cback) in uipc_check_fd_locked()
327 uipc_main.ch[ch_id].cback(ch_id, UIPC_RX_DATA_READY_EVT); in uipc_check_fd_locked()
334 if (SAFE_FD_ISSET(uipc_main.signal_fds[0], &uipc_main.read_set)) in uipc_check_interrupt_locked()
337 OSI_NO_INTR(recv(uipc_main.signal_fds[0], &sig_recv, sizeof(sig_recv), in uipc_check_interrupt_locked()
347 OSI_NO_INTR(send(uipc_main.signal_fds[1], &sig_on, sizeof(sig_on), 0)); in uipc_wakeup_locked()
371 FD_SET(fd, &uipc_main.active_set); in uipc_setup_server_locked()
372 uipc_main.max_fd = MAX(uipc_main.max_fd, fd); in uipc_setup_server_locked()
374 uipc_main.ch[ch_id].srvfd = fd; in uipc_setup_server_locked()
375 uipc_main.ch[ch_id].cback = cback; in uipc_setup_server_locked()
376 uipc_main.ch[ch_id].read_poll_tmo_ms = DEFAULT_READ_POLL_TMO_MS; in uipc_setup_server_locked()
392 pfd.fd = uipc_main.ch[ch_id].fd; in uipc_flush_ch_locked()
394 if (uipc_main.ch[ch_id].fd == UIPC_DISCONNECTED) in uipc_flush_ch_locked()
456 if (uipc_main.ch[ch_id].srvfd != UIPC_DISCONNECTED) in uipc_close_ch_locked()
458 BTIF_TRACE_EVENT("CLOSE SERVER (FD %d)", uipc_main.ch[ch_id].srvfd); in uipc_close_ch_locked()
459 close(uipc_main.ch[ch_id].srvfd); in uipc_close_ch_locked()
460 FD_CLR(uipc_main.ch[ch_id].srvfd, &uipc_main.active_set); in uipc_close_ch_locked()
461 uipc_main.ch[ch_id].srvfd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
465 if (uipc_main.ch[ch_id].fd != UIPC_DISCONNECTED) in uipc_close_ch_locked()
467 BTIF_TRACE_EVENT("CLOSE CONNECTION (FD %d)", uipc_main.ch[ch_id].fd); in uipc_close_ch_locked()
468 close(uipc_main.ch[ch_id].fd); in uipc_close_ch_locked()
469 FD_CLR(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in uipc_close_ch_locked()
470 uipc_main.ch[ch_id].fd = UIPC_DISCONNECTED; in uipc_close_ch_locked()
475 if (uipc_main.ch[ch_id].cback) in uipc_close_ch_locked()
476 uipc_main.ch[ch_id].cback(ch_id, UIPC_CLOSE_EVT); in uipc_close_ch_locked()
488 if (uipc_main.ch[ch_id].srvfd == UIPC_DISCONNECTED) in uipc_close_locked()
495 uipc_main.ch[ch_id].task_evt_flags |= UIPC_TASK_FLAG_DISCONNECT_CHAN; in uipc_close_locked()
510 while (uipc_main.running) in uipc_read_task()
512 uipc_main.read_set = uipc_main.active_set; in uipc_read_task()
514 result = select(uipc_main.max_fd+1, &uipc_main.read_set, NULL, NULL, NULL); in uipc_read_task()
551 uipc_main.tid = 0; in uipc_read_task()
559 uipc_main.running = 1; in uipc_start_main_server_thread()
561 …if (pthread_create(&uipc_main.tid, (const pthread_attr_t *) NULL, (void*)uipc_read_task, NULL) < 0) in uipc_start_main_server_thread()
575 uipc_main.running = 0; in uipc_stop_main_server_thread()
583 if (uipc_main.tid) in uipc_stop_main_server_thread()
584 pthread_join(uipc_main.tid, NULL); in uipc_stop_main_server_thread()
603 memset(&uipc_main, 0, sizeof(tUIPC_MAIN)); in UIPC_Init()
631 if (uipc_main.ch[ch_id].srvfd != UIPC_DISCONNECTED) in UIPC_Open()
702 OSI_NO_INTR(ret = write(uipc_main.ch[ch_id].fd, p_buf, msglen)); in UIPC_Send()
725 int fd = uipc_main.ch[ch_id].fd; in UIPC_Read()
754 uipc_main.ch[ch_id].read_poll_tmo_ms)); in UIPC_Read()
757 BTIF_TRACE_WARNING("poll timeout (%d ms)", uipc_main.ch[ch_id].read_poll_tmo_ms); in UIPC_Read()
828 uipc_main.ch[ch_id].cback = (tUIPC_RCV_CBACK*)param; in UIPC_Ioctl()
834 if (uipc_main.ch[ch_id].fd != UIPC_DISCONNECTED) in UIPC_Ioctl()
837 FD_CLR(uipc_main.ch[ch_id].fd, &uipc_main.active_set); in UIPC_Ioctl()
845 uipc_main.ch[ch_id].read_poll_tmo_ms = (intptr_t)param; in UIPC_Ioctl()
846 …BTIF_TRACE_EVENT("UIPC_SET_READ_POLL_TMO : CH %d, TMO %d ms", ch_id, uipc_main.ch[ch_id].read_poll… in UIPC_Ioctl()