Commit f12e9996 authored by Aurel's avatar Aurel

do not use method specific to sockets implementation in event part


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@240 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 343b4648
...@@ -43,6 +43,9 @@ class BaseConnection(object): ...@@ -43,6 +43,9 @@ class BaseConnection(object):
def getSocket(self): def getSocket(self):
return self.s return self.s
def getDescriptor(self):
return self.s.fileno()
def setSocket(self, s): def setSocket(self, s):
if self.s is not None: if self.s is not None:
raise RuntimeError, 'cannot overwrite a socket in a connection' raise RuntimeError, 'cannot overwrite a socket in a connection'
......
...@@ -172,12 +172,12 @@ class EpollEventManager(object): ...@@ -172,12 +172,12 @@ class EpollEventManager(object):
return self.connection_dict.values() return self.connection_dict.values()
def register(self, conn): def register(self, conn):
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
self.connection_dict[fd] = conn self.connection_dict[fd] = conn
self.epoll.register(fd) self.epoll.register(fd)
def unregister(self, conn): def unregister(self, conn):
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
self.epoll.unregister(fd) self.epoll.unregister(fd)
del self.connection_dict[fd] del self.connection_dict[fd]
...@@ -235,7 +235,7 @@ class EpollEventManager(object): ...@@ -235,7 +235,7 @@ class EpollEventManager(object):
def addReader(self, conn): def addReader(self, conn):
try: try:
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
if fd not in self.reader_set: if fd not in self.reader_set:
self.reader_set.add(fd) self.reader_set.add(fd)
self.epoll.modify(fd, 1, fd in self.writer_set) self.epoll.modify(fd, 1, fd in self.writer_set)
...@@ -244,7 +244,7 @@ class EpollEventManager(object): ...@@ -244,7 +244,7 @@ class EpollEventManager(object):
def removeReader(self, conn): def removeReader(self, conn):
try: try:
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
if fd in self.reader_set: if fd in self.reader_set:
self.reader_set.remove(fd) self.reader_set.remove(fd)
self.epoll.modify(fd, 0, fd in self.writer_set) self.epoll.modify(fd, 0, fd in self.writer_set)
...@@ -253,7 +253,7 @@ class EpollEventManager(object): ...@@ -253,7 +253,7 @@ class EpollEventManager(object):
def addWriter(self, conn): def addWriter(self, conn):
try: try:
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
if fd not in self.writer_set: if fd not in self.writer_set:
self.writer_set.add(fd) self.writer_set.add(fd)
self.epoll.modify(fd, fd in self.reader_set, 1) self.epoll.modify(fd, fd in self.reader_set, 1)
...@@ -262,7 +262,7 @@ class EpollEventManager(object): ...@@ -262,7 +262,7 @@ class EpollEventManager(object):
def removeWriter(self, conn): def removeWriter(self, conn):
try: try:
fd = conn.getSocket().fileno() fd = conn.getDescriptor()
if fd in self.writer_set: if fd in self.writer_set:
self.writer_set.remove(fd) self.writer_set.remove(fd)
self.epoll.modify(fd, fd in self.reader_set, 0) self.epoll.modify(fd, fd in self.reader_set, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment