Epoll::Epoll(int p_size) : m_size(p_size), m_epollFd(::epoll_create(m_size)) { if (m_epollFd < 0) { throw std::runtime_error("Epoll create failed"); } int pipeResult = pipe(m_selfStopPipes); if (pipeResult < 0) { ::close(m_epollFd); throw std::runtime_error("Pipe create failed"); } int readPipeFlags = fcntl(m_selfStopPipes[0], F_GETFL, 0); fcntl(m_selfStopPipes[1], F_SETFL, readPipeFlags | O_NONBLOCK); EventTypes eventTypesReadPipe; eventTypesReadPipe.insert(Epoll::EventType::In); try { epollCtl(EPOLL_CTL_ADD, m_selfStopPipes[0], eventTypesReadPipe); } catch (const std::runtime_error& e) { ::close(m_selfStopPipes[0]); ::close(m_selfStopPipes[1]); ::close(m_epollFd); throw e; } }
static jint netty_epoll_native_epollCtlMod0(JNIEnv* env, jclass clazz, jint efd, jint fd, jint flags) { int res = epollCtl(env, efd, EPOLL_CTL_MOD, fd, flags); if (res < 0) { return -errno; } return res; }
JNIEXPORT jint JNICALL Java_io_netty_channel_epoll_Native_epollCtlMod0(JNIEnv* env, jclass clazz, jint efd, jint fd, jint flags) { int res = epollCtl(env, efd, EPOLL_CTL_MOD, fd, flags); if (res < 0) { return -errno; } return res; }
void Epoll::modify(Socket::Ptr p_socket, const EventTypes& p_ets) const { int option = EPOLL_CTL_MOD; epollCtl(option, p_socket->getDescriptor(), p_ets); }
JNIEXPORT void JNICALL Java_io_netty_channel_epoll_Native_epollCtlMod(JNIEnv * env, jclass clazz, jint efd, jint fd, jint flags, jint id) { if (epollCtl(env, efd, EPOLL_CTL_MOD, fd, flags, id) < 0) { int err = errno; throwRuntimeException(env, exceptionMessage("Error during calling epoll_ctl(...): ", err)); } }