You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
static__poll_tsock_poll(structfile*file, poll_table*wait)
{
// 关键点structsocket*sock=file->private_data;
conststructproto_ops*ops=READ_ONCE(sock->ops);
__poll_tevents=poll_requested_events(wait), flag=0;
if (!ops->poll)
return0;
if (sk_can_busy_loop(sock->sk)) {
/* poll once if requested by the syscall */if (events&POLL_BUSY_LOOP)
sk_busy_loop(sock->sk, 1);
/* if this socket can poll_ll, tell the system call */flag=POLL_BUSY_LOOP;
}
returnops->poll(file, sock, wait) | flag;
}
目标:
一个极简epoll server程序(无法编译,只说明流程)
epoll 注册 wake callback
直接看追踪的call stack
epoll_ctl(ep, EPOLL_CTL_ADD, child, &event)
: called from epoll_ctl syscall把
ep_ptable_queue_proc
放入_qproc
,在接下来的poll_wait
调用file->f_op->poll(file, pt);
1. ep_poll_callback 添加到 wait queue
struct file 转换成 struct sock
struct sock
有最核心弄明白的点在于skb buff 如何转换成struct socket
结构sock_poll将
file->private_data
转换成struct sock
,从而调用到epoll的socket实现Why does the Linux kernel have `struct sock` and `struct socket`? - Stack Overflow
sock wake epoll callback
唤醒
ep->wq
ep_poll_callbackThe text was updated successfully, but these errors were encountered: