Linux epoll_insert的详细功能

Linux epoll_insert的详细功能,linux,io,linux-kernel,linux-device-driver,epoll,Linux,Io,Linux Kernel,Linux Device Driver,Epoll,sys\u epoll\u ctl调用epoll\u insert函数 epoll\u insert功能中有一些关键步骤: 使用队列回调初始化轮询表:ep\ptable\u queue\u proc 它将调用文件->f_op->poll 如果文件已经“就绪”,那么我们将其放入就绪列表中 /* If the file is already "ready" we drop it inside the ready list */ if ((revents & event->events)

sys\u epoll\u ctl
调用
epoll\u insert
函数

epoll\u insert
功能中有一些关键步骤:

  • 使用队列回调初始化轮询表:
    ep\ptable\u queue\u proc

  • 它将调用
    文件->f_op->poll

  • 如果文件已经“就绪”,那么我们将其放入就绪列表中

    /* If the file is already "ready" we drop it inside the ready list */
    if ((revents & event->events) && !ep_is_linked(&epi->rdllink)) {
    
        list_add_tail(&epi->rdllink, &ep->rdllist);
    
        /* Notify waiting tasks that events are available */
        if (waitqueue_active(&ep->wq))
            wake_up_locked(&ep->wq);
        if (waitqueue_active(&ep->poll_wait))
            pwake++;
    }
    

  • 我不明白为什么要在
    epoll\u insert
    函数中检查文件是否准备就绪。我们应该在
    ep\u poll\u callback
    函数中检查它吗?

    ep\u poll\u callback
    仅在其中一个文件描述符的状态更改时调用。如果这是将epoll描述符添加到读取列表的唯一位置,则可能会错过在将epoll描述符添加到epoll之前发生的事件。例如,在web服务器中,如果在连接后立即发送客户端的请求,则可能会错过该请求。

    ep\u poll\u callback
    仅在其中一个文件描述符的状态更改时调用。如果这是将epoll描述符添加到读取列表的唯一位置,则可能会错过在将epoll描述符添加到epoll之前发生的事件。例如,在web服务器中,如果在连接后立即发送客户机请求,则可能会错过该请求