Re: epoll_ctl and const correctness

From: nicolas sitbon
Date: Fri Mar 27 2009 - 18:56:34 EST


Do you read my post? there is a confusion, my question was first : why
the structure isn't const? and you answer me. ok. second, I asked if
the kernel keep track of this structure, that is, it keeps a pointer
on it for doing his job? according to your last answer, no. last
question : why the size type of the first parameter of epoll_create is
int and not size_t? no answer for the moment.

2009/3/27 Michael Tokarev <mjt@xxxxxxxxxx>:
> nicolas sitbon wrote:
>>
>> 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?
>
> I've no idea what are you talking about and what exactly
> is your problem. ÂBoth the examples (one at cplayer.org and
> another above) gives correct usage of epoll. ÂIf you don't
> understand it, well, I'd suggest reading some documentation
> first, maybe in kernel, maybe in glibc, maybe numerous
> available on the net. ÂAnd all the numerous examples too,
> which you quote as, for some reason, wrong.
>
> /mjt
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/