Re: io assumptions

From: Henrik Nordstrom <hno@dont-contact.us>
Date: 05 Dec 2002 11:45:57 +0100

tor 2002-12-05 klockan 11.19 skrev Robert Collins:

> > Is it the OS that makes the callback as a result of a async OS.Open()
> > beeing able to complete immediately.
>
> Yes.

Then this callback is into the storeio driver, and the storeio driver
needs to queue this event until such point in time that it can be
processed safely.

If the OS makes these callbacks at arbitrary points in time then great
care must be taken to not cause race conditions. Basically all you can
do in such case is to note in a separate queue that the condition has
taken place. You cannot trust a SIO there as you do not know for certain
what state the SIO is in if there is no locking involved, and you cannot
do sane locking unless you are doing threading where the callback
executes in it's own thread.

If the OS only makes these callbacks at well defined points then it is
your responsibility to ensure that these well defined points match what
is regarded as safe in Squid. In Squid the point of callback is when
sd->callback() is called.

If you can detect this OS callback before returning from the
storeOpen/Create then cool, you may then return NULL in case of error if
you like, but it is your responsibility to avoid races etc.

If not the actual callback has to be deferred until the storeio driver
is polled via sd->callback()..

Regards
Henrik
Received on Thu Dec 05 2002 - 03:45:51 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:00 MST