Descriptionruntime: explicitly remove fd's from epoll waitset before close()
Fixes issue 5061.
Current code relies on the fact that fd's are automatically removed from epoll set when closed. However, it is not true. Underlying file description is removed from epoll set only when *all* fd's referring to it are closed.
There are 2 bad consequences:
1. Kernel delivers notifications on already closed fd's.
2. The following sequence of events leads to error:
- add fd1 to epoll
- dup fd1 = fd2
- close fd1 (not removed from epoll since we've dup'ed the fd)
- dup fd2 = fd1 (get the same fd as fd1)
- add fd1 to epoll = EEXIST
So, if fd can be potentially dup'ed of fork'ed, it's necessary to explicitly remove the fd from epoll set.
Patch Set 1 #Patch Set 2 : diff -r b5b5c246be0c https://dvyukov%40google.com@code.google.com/p/go/ #Patch Set 3 : diff -r b5b5c246be0c https://dvyukov%40google.com@code.google.com/p/go/ #
Total comments: 3
Patch Set 4 : diff -r e4e13824b6a3 https://dvyukov%40google.com@code.google.com/p/go/ #
Total comments: 1
Patch Set 5 : diff -r 0d7891ca5e06 https://dvyukov%40google.com@code.google.com/p/go/ #
MessagesTotal messages: 10
|