lkml.org 
[lkml]   [2003]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: POLLRDONCE optimisation for epoll users (was: epoll and half closed TCP connections)
On Sun, 13 Jul 2003, Davide Libenzi wrote:

> void my_process_read(my_data *d, unsigned int events) {
> int n, s;
>
> do {
> s = d->buffer_size - d->in_buffer;
> if ((n = read(d->fd, d->buffer + d->in_buffer, s)) > 0) {
> process_partial_buffer(d, s);
> d->in_buffer += s;
> }
> } while (n == s);
> if (s == -1 && errno != EAGAIN) {
> handle_read_error(d);
> return;
> }
> if (events & EPOLLRDHUP) {
> d->flags |= HANGUP;
> schedule_removal(d);
> }
> }

Ouch, this is obviously :

void my_process_read(my_data *d, unsigned int events) {
int n, s;

do {
s = d->buffer_size - d->in_buffer;
if ((n = read(d->fd, d->buffer + d->in_buffer, s)) > 0) {
process_partial_buffer(d, n);
d->in_buffer += n;
}
} while (n == s);
if (n == -1 && errno != EAGAIN) {
handle_read_error(d);
return;
}
if (events & EPOLLRDHUP) {
d->flags |= HANGUP;
schedule_removal(d);
}
}



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

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.085 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site