vfs: move poll_link to file.h

Avoids problems with forward declarations in the following patch.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: convert file::f_poll_list to be a boost::intrusive::list

Also use new/delete instead of malloc/free.

Safer for everyone.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
vfs: remove unneeded extern "C" from osv/file.h

Gets in the way of template declarations.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: use correct key

According to epoll(7):

       Q0  What is the key used to distinguish the file descriptors
           registered in an epoll set?

       A0  The key is the combination of the file descriptor number
           and the open file description (also known as an "open file handle",
           the kernel's internal representation of an open file).

Right now we just use the file pointer, which means that two epolls on the
same file, but using a different fd, will fail, where they should succeed.

Fix by using a combination of the file descriptor and the file pointer as
the epoll_key.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: properly lock epoll file

epoll operations can be executed concurrently, protect against this using
file::f_lock.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: handle races between epoll_wait() and epoll_ctl(EPOLL_CTL_DEL)

An epoll_ctl() may remove a file which is being waited on; in that case
we will not be able to look up the key.

Handle this case by ignoring the reported event, since no one is waiting
for it.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
epoll: use epoll_file in epoll_ptr

epoll_ptr refers to two files: the file being watched, and the epoll file
doing the watching.  Use epoll_file as the type for the second, in order to
promote type safety.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tests: add epoll tests for same file/differnt fd

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge tag 'epoll-fixes-v2' of https://github.com/avikivity/osv

Some epoll fixes.

Signed-off-by: Avi Kivity <avi@cloudius-systems.com>