Subject: Re: wsevent cleanup
To: Iain Hibbert <plunky@rya-online.net>
From: Julio M. Merino Vidal <jmmv84@gmail.com>
List: tech-kern
Date: 02/06/2006 18:51:14
El 06/02/2006, a las 18:34, Iain Hibbert escribi=F3:

> On Mon, 6 Feb 2006, Julio M. Merino Vidal wrote:
>
>> El 06/02/2006, a las 16:25, Iain Hibbert escribi=F3:
>>
>>> On Mon, 6 Feb 2006, Julio M. Merino Vidal wrote:
>>>> struct wscons_event evt[N];
>>>> ... fill evt with up to N events ...  (see below)
>>>> error =3D wsevent_inject(evar, evt, N);
>>>> if (error !=3D 0)
>>>> 	queue is full
>>>
>>> what will happen if there are X spaces but N > X ?
>>
>> Sorry, the N in the call to wsevent_inject should be the number of
>> events generated, not the maximum size of the vector.
>
> actually, I meant than N to be the number of events to be injected =20
> and X
> is an unknown (to the caller) number that is the number of spaces
> currently available in the queue (neither do we know the max queue =20
> length)

Oh, I understand now.  The caller needs to have a way to get the
queue's size.

>
>>> Which errors can occur with wsevent_inject(), would it be easier =20
>>> to return
>>> the number of items actually queued and leave the caller to =20
>>> supply an
>>> errno? (or simply pass '&num' ?)
>>
>> The only error that can occur is when the queue does not have enough
>> free space.
>
> My point then is that if you can only inject one event, the error =20
> meant
> 'No Space' whereas if you can push several at a time, it will mean =20
> 'Not
> Enough Space for N' which is slightly different and somewhat vague, =20=

> and it
> might be useful to be more specific with 'I injected Y', similar to =20=

> how
> write(2) works..

Yes... looks like that if N > X, write(2) semantics may be better.
But the problem with write(2) semantics, at least as I see it from
the code I converted, is that you either need to sleep if the call
inserts less elements than wanted (to retry later) or you have to
rollback all the inserted events before notifying any reader.

The former is easy but I'm not sure about the implications in the
existing code nor if it'd work at all or could cause unexpected
mouse/whatever behavior.  For the latter, it may be more difficult
because we'd need to store a copy of the previous elements, in case
the caller wants to roll them back...

wsevent_inject could assert that N < X, provided that there is another
operation to retrieve the queue's size.  How do you see this?

--=20
Julio M. Merino Vidal <jmmv84@gmail.com>
The Julipedia - http://julipedia.blogspot.com/