From: nicolas sitbon <nicolas.sitbon@gmail.com>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: linux-kernel@vger.kernel.org
Subject: Re: epoll_ctl and const correctness
Date: Fri, 27 Mar 2009 23:30:25 +0100 [thread overview]
Message-ID: <84a01a8b0903271530of8d43ffhf77e7ba73e309f75@mail.gmail.com> (raw)
In-Reply-To: <84a01a8b0903271517t668c6276l7fe098d74c24b836@mail.gmail.com>
I was looking at libevent of niels provos, and even him, is apparently
doing a mistake :
static int
epoll_add(void *arg, struct event *ev)
{
struct epollop *epollop = arg;
struct epoll_event epev = {0, {0}};
/* ... some code here ... */
if (epoll_ctl(epollop->epfd, op, ev->ev_fd, &epev) == -1)
return (-1);
/* Update events responsible */
if (ev->ev_events & EV_READ)
evep->evread = ev;
if (ev->ev_events & EV_WRITE)
evep->evwrite = ev;
return (0);
}
the structure pointed to by &epev is allocated on the stack, so how
the kernel could keep track of it?
2009/3/27 nicolas sitbon <nicolas.sitbon@gmail.com>:
> Well, first, thanks for your answer, then, there is a difference
> between saying the kernel modify or not the structure and the kernel
> keep track of it. Consider this user :
> http://www.csplayer.org/2009/02/a-tutorial-example-of-epoll-usage/, he
> thinks the kernel doesn't keep track of the event, and I'm sure he is
> not the first, so please, at least, be more explicit in the
> documentation and again thanks for your answer. And what about size
> parameter in epoll_create()? why is it an int and not a size_t?
>
> 2009/3/27 Michael Tokarev <mjt@tls.msk.ru>:
>> nicolas sitbon wrote:
>>>
>>> Please, can anyone answer me, I need a response.
>>
>>> 2009/3/25 nicolas sitbon <nicolas.sitbon@gmail.com>:
>>>>
>>>> You don't teach me anything, I know that, the fact is the
>>>> documentation is incomplete, so rather saying that, please answer my
>>>> questions. For the moment, only the documenation and the prototype of
>>>> epoll are buggy.
>>
>> So which response do you want -- the one saying that the documentation
>> is buggy or or epoll prototype? Or something else?
>>
>> []
>>>>>>
>>>>>> or the good prototype is
>>>>>>
>>>>>> int epoll_ctl(int epfd, int op, int fd, struct epoll_event const
>>>>>> *event);
>>
>> Why should it be const? There is no guarantee the argument will not be
>> modified by the kernel. Documentation does not say that. Current prototype
>> does not say that. If you need such a guarantee, you're free to add another
>> system call into your kernel, and fix both your documentation and your
>> prototype to match. What's the deal?
>>
>> Back from useless rants and to the technical points.
>>
>> Again: there's no guarantee the `event' argument will not be modified.
>> Even if kernel CURRENTLY indeed does not modify it, but the interface
>> does not PROMISE it to be that way for ever.
>>
>> Why does it not promise that is another question. Just one example:
>> what, some day, stops us from adding some EPOLL_CTL_GET operation
>> to RETRIEVE information associated with that filedescriptor in kernel
>> currently and STORE that info in the structure pointed to by `event'
>> argument? That way it will not be const anymore.
>>
>> So.. what's your problem?
>>
>> /mjt
>>
>
next prev parent reply other threads:[~2009-03-27 22:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-25 12:45 nicolas sitbon
2009-03-25 16:23 ` Davide Libenzi
2009-03-25 17:27 ` nicolas sitbon
2009-03-27 19:43 ` nicolas sitbon
2009-03-25 21:21 ` Jeremy Fitzhardinge
2009-03-25 21:37 ` nicolas sitbon
2009-03-27 9:44 ` nicolas sitbon
2009-03-27 21:47 ` Michael Tokarev
2009-03-27 22:17 ` nicolas sitbon
2009-03-27 22:30 ` nicolas sitbon [this message]
2009-03-27 22:40 ` Davide Libenzi
2009-03-27 22:42 ` Michael Tokarev
2009-03-27 22:55 ` nicolas sitbon
2009-03-27 23:01 ` Michael Tokarev
2009-03-27 23:10 ` nicolas sitbon
2009-03-27 23:16 ` Michael Tokarev
2009-03-27 23:25 ` nicolas sitbon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84a01a8b0903271530of8d43ffhf77e7ba73e309f75@mail.gmail.com \
--to=nicolas.sitbon@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjt@tls.msk.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®