• Dmitriy Vyukov's avatar
    runtime: explicitly remove fd's from epoll waitset before close() · 44840786
    Dmitriy Vyukov authored
    Fixes #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.
    
    R=golang-dev, bradfitz, dave
    CC=golang-dev
    https://golang.org/cl/7870043
    44840786
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...