Quantcast
Channel: Active questions tagged kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 6334

Why does epoll use a combination of the file descriptor number and the open file description to distinguish the registered file descriptors?

$
0
0

In epoll(7):

  1. What is the key used to distinguish the file descriptors registered in an interest list?
    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).

Epoll uses struct epoll_filefd to distinguish items in interest list, and in fs/eventpoll.c:

/* Compare RB tree keys */static inline int ep_cmp_ffd(struct epoll_filefd *p1,                 struct epoll_filefd *p2){    return (p1->file > p2->file ? +1:            (p1->file < p2->file ? -1 : p1->fd - p2->fd));}

It seems that Epoll compares the struct file pointer first, then the fd number. Why not just use the fd number, since applications can only do epoll calls on a fd number?


Viewing all articles
Browse latest Browse all 6334

Trending Articles