Commit 00705a8c authored by Grégory Wisniewski's avatar Grégory Wisniewski

Remove the file descriptor accessor in Connection class because it must be used

only in the event manager, at the lowest level of the network system.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@870 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent ee3f9a1d
......@@ -77,9 +77,6 @@ class BaseConnection(object):
def getConnector(self):
return self.connector
def getDescriptor(self):
return self.connector.getDescriptor()
def setConnector(self, connector):
if self.connector is not None:
raise RuntimeError, 'cannot overwrite a connector in a connection'
......
......@@ -86,6 +86,8 @@ class SocketConnector:
return self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
def getDescriptor(self):
# this descriptor must only be used by the event manager, where it guarantee
# unicity only while the connector is opened and registered in epoll
return self.socket.fileno()
def getNewConnection(self):
......
......@@ -208,12 +208,12 @@ class EpollEventManager(object):
return None
def register(self, conn):
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
self.connection_dict[fd] = conn
self.epoll.register(fd)
def unregister(self, conn):
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
self.epoll.unregister(fd)
del self.connection_dict[fd]
......@@ -299,7 +299,7 @@ class EpollEventManager(object):
def addReader(self, conn):
try:
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
if fd not in self.reader_set:
self.reader_set.add(fd)
self.epoll.modify(fd, 1, fd in self.writer_set)
......@@ -308,7 +308,7 @@ class EpollEventManager(object):
def removeReader(self, conn):
try:
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
if fd in self.reader_set:
self.reader_set.remove(fd)
self.epoll.modify(fd, 0, fd in self.writer_set)
......@@ -317,7 +317,7 @@ class EpollEventManager(object):
def addWriter(self, conn):
try:
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
if fd not in self.writer_set:
self.writer_set.add(fd)
self.epoll.modify(fd, fd in self.reader_set, 1)
......@@ -326,7 +326,7 @@ class EpollEventManager(object):
def removeWriter(self, conn):
try:
fd = conn.getDescriptor()
fd = conn.getConnector().getDescriptor()
if fd in self.writer_set:
self.writer_set.remove(fd)
self.epoll.modify(fd, fd in self.reader_set, 0)
......
#
# Copyright (C) 2006-2009 Nexedi SA
#
......
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