Re: [PATCH 3/4] input: evdev: Indicate buffer overrun with SYN_DROPPED.

From: Jeffrey Brown
Date: Fri Mar 25 2011 - 19:12:47 EST


Hi Henrik,

On Fri, Mar 25, 2011 at 2:02 AM, Henrik Rydberg <rydberg@xxxxxxxxxxx> wrote:
> My last comment was not right, the SYN_DROPPED is pushed ahead in the
> buffer, sorry about that. However, this change does not shrink the
> number of buffered elements in case of an overrun, which has been
> discussed before as a possibly important feature of the current
> code. I would be more comfortable prepending the head with a
> SYN_DROPPED, like this:
>
> if (client->head == client->tail) {
>        struct input_event drop;
>
>        drop.time = event->time;
>        drop.type = EV_SYN;
>        drop.code = SYN_DROPPED;
>        drop.value = 0;
>        client->buffer[client->head++] = drop;
>        client->head &= client->bufsize - 1;
>
>        client->buffer[client->head++] = *event;
>        client->head &= client->bufsize - 1;
> }
>
> The main point is that if we end up having to drop an event, it is
> likely we will have to drop the next one, too.

I think that's a good idea. If the client is far behind then we might
as well truncate the buffer as you suggest. I'll do that.

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