/* Run event handler */ void wifi_event_loop(wifi_handle handle) { hal_info *info = getHalInfo(handle); if (info->in_event_loop) { return; } else { info->in_event_loop = true; } pollfd pfd; memset(&pfd, 0, sizeof(pfd)); pfd.fd = nl_socket_get_fd(info->event_sock); pfd.events = POLLIN; /* TODO: Add support for timeouts */ do { int timeout = -1; /* Infinite timeout */ pfd.revents = 0; //ALOGI("Polling socket"); int result = poll(&pfd, 1, -1); ALOGI("Poll result = %0x", result); if (result < 0) { ALOGE("Error polling socket"); } else if (pfd.revents & (POLLIN | POLLHUP | POLLERR)) { internal_event_handler(handle, pfd.revents); } } while (!info->clean_up); ALOGI("Cleaning up"); internal_cleaned_up_handler(handle); }
/* Run event handler */ void wifi_event_loop(wifi_handle handle) { hal_info *info = getHalInfo(handle); if (info->in_event_loop) { return; } else { info->in_event_loop = true; } pollfd pfd[3]; memset(&pfd, 0, 3*sizeof(pfd[0])); pfd[0].fd = nl_socket_get_fd(info->event_sock); pfd[0].events = POLLIN; pfd[1].fd = nl_socket_get_fd(info->user_sock); pfd[1].events = POLLIN; pfd[2].fd = info->exit_sockets[1]; pfd[2].events = POLLIN; /* TODO: Add support for timeouts */ do { pfd[0].revents = 0; pfd[1].revents = 0; pfd[2].revents = 0; //ALOGI("Polling sockets"); int result = poll(pfd, 3, -1); if (result < 0) { ALOGE("Error polling socket"); } else { if (pfd[0].revents & (POLLIN | POLLHUP | POLLERR)) { internal_event_handler(handle, pfd[0].revents, info->event_sock); } if (pfd[1].revents & (POLLIN | POLLHUP | POLLERR)) { internal_event_handler(handle, pfd[1].revents, info->user_sock); } } rb_timerhandler(info); } while (!info->clean_up); internal_cleaned_up_handler(handle); }