All pastes #823818 Raw Edit

Untitled

public c v1 · immutable
·published 2007-12-19 16:36 UTC
rendered paste body
static PyObject *pyepoll_internal_ctl(int epfd, int op, int fd, unsigned int events){	struct epoll_event ev;	int result;	if (epfd < 0)		return pyepoll_err_closed();	if (events != 0) {		ev.events = events;		ev.data.fd = fd;		Py_BEGIN_ALLOW_THREADS		result = epoll_ctl(epfd, op, fd, &ev);		Py_END_ALLOW_THREADS	}	else {		Py_BEGIN_ALLOW_THREADS		result = epoll_ctl(epfd, op, fd, NULL);		Py_END_ALLOW_THREADS	}	if (result < 0) {		PyErr_SetFromErrno(PyExc_IOError);		return NULL;	}	Py_RETURN_NONE;}static PyObject *pyepoll_register(PyEpoll_Object *self, PyObject *args, PyObject *kwds){	int fd;	unsigned int events = EPOLLIN | EPOLLOUT | EPOLLPRI;	static char *kwlist[] = {"fd", "eventmask", NULL};	if (!PyArg_ParseTupleAndKeywords(args, kwds, "i|I:control", kwlist,	     &fd, &events))		return NULL;	return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_ADD, fd, events);}static PyObject *pyepoll_modify(PyEpoll_Object *self, PyObject *args, PyObject *kwds){	int fd;	unsigned int events;	static char *kwlist[] = {"fd", "eventmask", NULL};	if (!PyArg_ParseTupleAndKeywords(args, kwds, "iI:control", kwlist,	     &fd, &events))		return NULL;	return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_MOD, fd, events);}static PyObject *pyepoll_unregister(PyEpoll_Object *self, PyObject *args, PyObject *kwds){	int fd;	static char *kwlist[] = {"fd", NULL};	if (!PyArg_ParseTupleAndKeywords(args, kwds, "i:control", kwlist,	     &fd))		return NULL;	return pyepoll_internal_ctl(self->epfd, EPOLL_CTL_DEL, fd, 0);}