X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=python%2Fovs%2Fpoller.py;h=7d15f3edb6a8b9cb3cde7b531898fdfc3925f627;hb=bb1c9a6518807ac131a3a7ce77453004e05262e4;hp=c04c9b36f2738c5d22af8674aa587be4c3b16873;hpb=568e23fc2772235204dcabb61e1425b312070da2;p=openvswitch diff --git a/python/ovs/poller.py b/python/ovs/poller.py index c04c9b36..7d15f3ed 100644 --- a/python/ovs/poller.py +++ b/python/ovs/poller.py @@ -20,6 +20,11 @@ import socket vlog = ovs.vlog.Vlog("poller") +POLLIN = 0x001 +POLLOUT = 0x004 +POLLERR = 0x008 +POLLHUP = 0x010 +POLLNVAL = 0x020 # eventlet/gevent doesn't support select.poll. If select.poll is used, # python interpreter is blocked as a whole instead of switching from the @@ -39,12 +44,12 @@ class _SelectSelect(object): if isinstance(fd, socket.socket): fd = fd.fileno() assert isinstance(fd, int) - if events & select.POLLIN: + if events & POLLIN: self.rlist.append(fd) - events &= ~select.POLLIN - if events & select.POLLOUT: + events &= ~POLLIN + if events & POLLOUT: self.wlist.append(fd) - events &= ~select.POLLOUT + events &= ~POLLOUT if events: self.xlist.append(fd) @@ -63,13 +68,13 @@ class _SelectSelect(object): # events_dict[fd] |= event events_dict = {} for fd in rlist: - events_dict[fd] = events_dict.get(fd, 0) | select.POLLIN + events_dict[fd] = events_dict.get(fd, 0) | POLLIN for fd in wlist: - events_dict[fd] = events_dict.get(fd, 0) | select.POLLOUT + events_dict[fd] = events_dict.get(fd, 0) | POLLOUT for fd in xlist: - events_dict[fd] = events_dict.get(fd, 0) | (select.POLLERR | - select.POLLHUP | - select.POLLNVAL) + events_dict[fd] = events_dict.get(fd, 0) | (POLLERR | + POLLHUP | + POLLNVAL) return events_dict.items() @@ -168,15 +173,15 @@ class Poller(object): for fd, revents in events: if revents != 0: s = "" - if revents & select.POLLIN: + if revents & POLLIN: s += "[POLLIN]" - if revents & select.POLLOUT: + if revents & POLLOUT: s += "[POLLOUT]" - if revents & select.POLLERR: + if revents & POLLERR: s += "[POLLERR]" - if revents & select.POLLHUP: + if revents & POLLHUP: s += "[POLLHUP]" - if revents & select.POLLNVAL: + if revents & POLLNVAL: s += "[POLLNVAL]" vlog.dbg("%s on fd %d" % (s, fd))