Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad file descriptor in io_worker #28

Closed
MurphyMc opened this issue Jun 23, 2012 · 2 comments
Closed

Bad file descriptor in io_worker #28

MurphyMc opened this issue Jun 23, 2012 · 2 comments
Labels

Comments

@MurphyMc
Copy link
Collaborator

Here's a stack trace from Sam:

File "/usr/lib/python2.7/threading.py", line 552, in __bootstrap_inner │
self.run() │
File "/usr/lib/python2.7/threading.py", line 505, in run │
self.__target(*self.__args, **self.__kwargs) │
File "/home/sam/code/debugger/sts/../pox/pox/lib/recoco/recoco.py", line 574, in _threadProc │
xl.keys(), timeout ) │
File "/home/sam/code/debugger/sts/../pox/pox/lib/ioworker/io_worker.py", line 77, in fileno │
return self.socket.fileno() │
File "/usr/lib/python2.7/socket.py", line 224, in meth │
return getattr(self._sock,name)(*args) │
File "/usr/lib/python2.7/socket.py", line 170, in _dummy │
raise error(EBADF, 'Bad file descriptor') │
error: [Errno 9] Bad file descriptor
@MurphyMc
Copy link
Collaborator Author

The problem would seem to be that close() is being called on a worker socket while Select() either still has the socket (because close() is called from other thread or maybe another Task, for example), or close() is called on a socket that is passed back into Select().

It's not immediately clear to me how the latter could be happening, because _workers.remove() or _workers.discard() seems to be called in every place that close() is called on a worker socket.

The former is a possibility, though I don't know the io_worker code well enough to immediately say. 96b8074 fixed a similar problem by changing calls from socket.close() to socket.shutdown(), relying on recoco to close them eventually. This might work here?

@samwhitlock
Copy link
Contributor

I was accidentally closing my socket's file descriptor because I misunderstood how python's finally statement worked. My bad :P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants