gro_mgr::gro_mgr(uint32_t flow_max, uint32_t buf_max) : m_n_flow_max(flow_max), m_n_buf_max(buf_max), m_n_flow_count(0) { m_p_rfs_arr = new rfs_uc_tcp_gro*[flow_max]; BULLSEYE_EXCLUDE_BLOCK_START if (!m_p_rfs_arr) { __log_panic("could not allocate memory"); } BULLSEYE_EXCLUDE_BLOCK_END }
bool select_call::wait(const timeval &elapsed) { timeval timeout, *pto = NULL; timespec to_pselect, *pto_pselect = NULL; BULLSEYE_EXCLUDE_BLOCK_START if (m_n_all_ready_fds > 0) { __log_panic("wait() called when there are ready fd's!!!"); // YossiE TODO make this and some more checks as debug assertions // In all functions } BULLSEYE_EXCLUDE_BLOCK_END // Restore original sets if (m_b_run_prepare_to_poll) { if (m_readfds) FD_COPY(m_readfds, &m_os_rfds, m_nfds); if (m_writefds) FD_COPY(m_writefds, &m_os_wfds, m_nfds); if (m_exceptfds)FD_COPY(m_exceptfds, &m_orig_exceptfds, m_nfds); } // Call OS select() on original sets + CQ epfd in read set if (m_readfds) FD_SET(m_cqepfd, m_readfds); if (m_timeout) { tv_sub(m_timeout, &elapsed, &timeout); if (timeout.tv_sec < 0 || timeout.tv_usec < 0) { // Already reached timeout return false; } pto = &timeout; } __log_func("going to wait on select CQ+OS nfds=%d cqfd=%d pto=%p!!!", m_nfds_with_cq, m_cqepfd, pto); // ACTUAL CALL TO SELECT if (m_sigmask) { if (pto) { to_pselect.tv_sec = pto->tv_sec; to_pselect.tv_nsec = pto->tv_usec * 1000; pto_pselect = &to_pselect; } m_n_all_ready_fds = orig_os_api.pselect(m_nfds, m_readfds, m_writefds, m_exceptfds, pto_pselect, m_sigmask); } else { m_n_all_ready_fds = orig_os_api.select(m_nfds_with_cq, m_readfds, m_writefds, m_exceptfds, pto); } __log_func("done select CQ+OS nfds=%d cqfd=%d pto=%p ready=%d!!!", m_nfds_with_cq, m_cqepfd, pto, m_n_all_ready_fds); if (m_n_all_ready_fds < 0) { vma_throw_object(io_mux_call::io_error); } // Clear CQ from the set and don't count it if (m_readfds) { if (FD_ISSET(m_cqepfd, m_readfds)) { FD_CLR(m_cqepfd, m_readfds); // Not needed if m_readfds is NULL --m_n_all_ready_fds; return true; } } return false; }