and nicer too - Re: [PATCH] epoll more scalable than poll

bert hubert (ahu@ds9a.nl)
Mon, 28 Oct 2002 23:58:21 +0100


On Mon, Oct 28, 2002 at 02:29:37PM -0800, Davide Libenzi wrote:

> sys_epoll, by plugging directly in the existing kernel architecture,
> supports sockets and pipes. It does not support and there're not even
> plans to support other devices like tty, where poll() and select() works
> flawlessy. Since the sys_epoll ( and /dev/epoll ) fd support standard polling, you

Ok. I suggest the manpage mention this prominently.

I tried a somewhat more involved example and it indeed works expected. As an
application developer, this suits my needs just fine. I really like the
'edge' nature of it all.

The interface is also lovely:

for(;;) {
nfds = sys_epoll_wait(kdpfd, &pfds, -1);
fprintf(stderr,"sys_epoll_wait returned: %d\n",nfds);

for(n=0;n<nfds;++n) {
if(pfds[n].fd==s) {
client=accept(s, (struct sockaddr*)&local, &addrlen);

if(client<0){
perror("accept");
continue;
}
if (sys_epoll_ctl(kdpfd, EP_CTL_ADD, client, POLLIN ) < 0) {
fprintf(stderr, "sys_epoll set insertion error: fd=%d\n", client);
return -1;
}
}
else
printf("something happened on fd %d\n", pfds[n].fd);
}
}

Each time a packet comes in, sys_wait returns just once so I can immediately
call it again without having to wait for another thread to have actually
*done* something with that socket.

Righteous stuff, I'll be using this, thanks.

Regards,

bert

-- 
http://www.PowerDNS.com          Versatile DNS Software & Services
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/