On Sat, 3 Nov 2012 10:48:08 +0900 Isaku Yamahata <[email protected]> wrote:
> On Sat, Nov 03, 2012 at 09:34:32AM +0900, FUJITA Tomonori wrote: >> On Fri, 12 Oct 2012 15:19:40 +0900 >> Isaku Yamahata <[email protected]> wrote: >> >> > On Fri, Oct 12, 2012 at 03:07:57PM +0900, Isaku Yamahata wrote: >> >> Okay, I'll hard-code all of them. And let's see the result. >> > >> > I uploaded at >> > git://github.com/yamahata/ryu.git contrib-ovs-import-1 >> > ovs lib only >> >> This doesn't include the change for tcp sockets? > > Now the upstream includes all necessary patches. So I updated and uploaded > git://github.com/yamahata/ryu.git contrib-ovs-import-2 Thanks, seems to work. MacOS doesn't have POLL* constants (poll isn't supported by all OSes, I guess). From quick look, the code uses select() (supported by all) and POLL* constants are used only internally. The following works for me. diff --git a/ryu/contrib/ovs/poller.py b/ryu/contrib/ovs/poller.py index c04c9b3..03082d3 100644 --- a/ryu/contrib/ovs/poller.py +++ b/ryu/contrib/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() @@ -95,7 +100,7 @@ class Poller(object): def fd_wait(self, fd, events): """Registers 'fd' as waiting for the specified 'events' (which should - be select.POLLIN or select.POLLOUT or their bitwise-OR). The following + be POLLIN or POLLOUT or their bitwise-OR). The following call to self.block() will wake up when 'fd' becomes ready for one or more of the requested events. @@ -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)) diff --git a/ryu/contrib/ovs/socket_util.py b/ryu/contrib/ovs/socket_util.py index dd45fe4..1fc80fd 100644 --- a/ryu/contrib/ovs/socket_util.py +++ b/ryu/contrib/ovs/socket_util.py @@ -77,7 +77,7 @@ def make_unix_socket(style, nonblock, bind_path, connect_path): 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: diff --git a/ryu/contrib/ovs/stream.py b/ryu/contrib/ovs/stream.py index dad6848..c4d243d 100644 --- a/ryu/contrib/ovs/stream.py +++ b/ryu/contrib/ovs/stream.py @@ -14,7 +14,6 @@ import errno import os -import select import socket import ovs.poller @@ -236,9 +235,9 @@ class Stream(object): 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) else: - 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) @@ -324,7 +323,7 @@ class PassiveStream(object): 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. ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
