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

Davide Libenzi (davidel@xmailserver.org)
Mon, 28 Oct 2002 16:32:50 -0800 (PST)


On Tue, 29 Oct 2002, bert hubert wrote:

> 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.

The code above it's just fine. The "fd" is not lost because the falling
through :

do_use_fd(fd);

will make good use of it.

- Davide

-
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/