Python doesn't have select.POLL* constants on some architectures
(e.g. MacOSX). This code needs to define the constants for itself. It
uses select.POLL* constants only internally (doesn't pass them
outside). So there is no harm even if the definition would conflict
with Python's those.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Ben Pfaff <blp@nicira.com>
Ed Maste emaste at freebsd.org
Edward Tomasz Napierała trasz@freebsd.org
Ethan Jackson ethan@nicira.com
Ed Maste emaste at freebsd.org
Edward Tomasz Napierała trasz@freebsd.org
Ethan Jackson ethan@nicira.com
+FUJITA Tomonori fujita.tomonori@lab.ntt.co.jp
Gaetano Catalli gaetano.catalli@gmail.com
Giuseppe Lettieri g.lettieri@iet.unipi.it
Glen Gibb grg@stanford.edu
Gaetano Catalli gaetano.catalli@gmail.com
Giuseppe Lettieri g.lettieri@iet.unipi.it
Glen Gibb grg@stanford.edu
vlog = ovs.vlog.Vlog("poller")
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
# eventlet/gevent doesn't support select.poll. If select.poll is used,
# python interpreter is blocked as a whole instead of switching from the
if isinstance(fd, socket.socket):
fd = fd.fileno()
assert isinstance(fd, int)
if isinstance(fd, socket.socket):
fd = fd.fileno()
assert isinstance(fd, int)
- if events & select.POLLIN:
- events &= ~select.POLLIN
- if events & select.POLLOUT:
+ events &= ~POLLIN
+ if events & POLLOUT:
- events &= ~select.POLLOUT
if events:
self.xlist.append(fd)
if events:
self.xlist.append(fd)
# events_dict[fd] |= event
events_dict = {}
for fd in rlist:
# 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
- events_dict[fd] = events_dict.get(fd, 0) | select.POLLOUT
+ events_dict[fd] = events_dict.get(fd, 0) | POLLOUT
- 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()
return events_dict.items()
for fd, revents in events:
if revents != 0:
s = ""
for fd, revents in events:
if revents != 0:
s = ""
- if revents & select.POLLIN:
- if revents & select.POLLOUT:
- if revents & select.POLLERR:
- if revents & select.POLLHUP:
- if revents & select.POLLNVAL:
s += "[POLLNVAL]"
vlog.dbg("%s on fd %d" % (s, fd))
s += "[POLLNVAL]"
vlog.dbg("%s on fd %d" % (s, fd))
def check_connection_completion(sock):
p = ovs.poller.SelectPoll()
def check_connection_completion(sock):
p = ovs.poller.SelectPoll()
- p.register(sock, select.POLLOUT)
+ p.register(sock, ovs.poller.POLLOUT)
if len(p.poll(0)) == 1:
return get_socket_error(sock)
else:
if len(p.poll(0)) == 1:
return get_socket_error(sock)
else:
import socket
import ovs.poller
import socket
import ovs.poller
if self.state == Stream.__S_CONNECTING:
wait = Stream.W_CONNECT
if wait == Stream.W_RECV:
if self.state == Stream.__S_CONNECTING:
wait = Stream.W_CONNECT
if wait == Stream.W_RECV:
- poller.fd_wait(self.socket, select.POLLIN)
+ poller.fd_wait(self.socket, ovs.poller.POLLIN)
- poller.fd_wait(self.socket, select.POLLOUT)
+ poller.fd_wait(self.socket, ovs.poller.POLLOUT)
def connect_wait(self, poller):
self.wait(poller, Stream.W_CONNECT)
def connect_wait(self, poller):
self.wait(poller, Stream.W_CONNECT)
return error, None
def wait(self, poller):
return error, None
def wait(self, poller):
- poller.fd_wait(self.socket, select.POLLIN)
+ poller.fd_wait(self.socket, ovs.poller.POLLIN)
def __del__(self):
# Don't delete the file: we might have forked.
def __del__(self):
# Don't delete the file: we might have forked.