- 论坛徽章:
- 0
|
回复 81# yulihua49
- /usr/src/linux/fs/eventpoll.c
- 898 static int ep_insert(struct eventpoll *ep, struct epoll_event *event,
- 899 struct file *tfile, int fd)
- 900 {
- ......
- 944 /* Add the current item to the list of active epoll hook for this file */
- 945 spin_lock(&tfile->f_lock);
- 946 list_add_tail(&epi->fllink, &tfile->f_ep_links);
- 947 spin_unlock(&tfile->f_lock);
- 948
- 949 /*
- 950 * Add the current item to the RB tree. All RB tree operations are
- 951 * protected by "mtx", and ep_insert() is called with "mtx" held.
- 952 */
- 953 ep_rbtree_insert(ep, epi);
- 954
- 955 /* We have to drop the new item inside our item list to keep track of it */
- 956 spin_lock_irqsave(&ep->lock, flags);
- 957
- 958 /* If the file is already "ready" we drop it inside the ready list */
- 959 if ((revents & event->events) && !ep_is_linked(&epi->rdllink)) {
- 960 list_add_tail(&epi->rdllink, &ep->rdllist);
- 961
- 962 /* Notify waiting tasks that events are available */
- 963 if (waitqueue_active(&ep->wq))
- 964 wake_up_locked(&ep->wq);
- 965 if (waitqueue_active(&ep->poll_wait))
- 966 pwake++;
- 967 }
- 968
- 969 spin_unlock_irqrestore(&ep->lock, flags);
复制代码 |
|