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

bert hubert (ahu@ds9a.nl)
Tue, 29 Oct 2002 01:18:43 +0100


On Mon, Oct 28, 2002 at 03:45:06PM -0800, John Gardiner Myers wrote:

> As you have amply demonstrated, the current epoll API is error prone.
> The API should be fixed to test the poll condition and, if necessary,
> drop an event upon insertion to the set.

That is a semantics change and not an API/ABI change. To reiterate, you
mention the following scenario:

for(;;) {
nfds = sys_epoll_wait(kdpfd, &pfds, -1);
for(n = 0; n < nfds; ++n) {
if((fd = pfds[n].fd) == s) {
/* 1: accept client (SYN/SYN|ACK/ACK completed) */
client = accept(s, (struct sockaddr*)&local, &addrlen);
if(client < 0){
perror("accept");
continue;
}

/* 2: packet comes in, client becomes readable */
/* 3: registering interest */
if (sys_epoll_ctl(kdpfd, EP_CTL_ADD, client, POLLIN ) < 0) {
fprintf(stderr, "sys_epoll set insertion error: fd=%d\n", client);
return -1;
}

/* 4: interest only now registered, no edge will be
reported, our fd is lost */

fd = client;
}
do_use_fd(fd);
}
}

There are lots of ways to solve this, I bet Davide knows best. Perhaps it is
solved already, you can't tell from only studying the API, the problem isn't
intrinsic to it.

An easy solution is to have sys_epoll_ctl check if there is there is data
ready and make sure there is an edge to report in that case to the next call
of sys_epoll_ctl().

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/