RE: BGI-spec 1.4

John Ludeman (johnl@microsoft.com)
Fri, 22 Jul 1994 05:56:14 +0200

..
| > Restarting is a little tricky for multi-threaded processes; you need
| > to leave any active threads running until they complete, without
| > making their symbols disappear out from under them. The approach I
| > use is to fork1(2) from inside the accepting thread, with the parent
| > closing the accept socket and thr_exit(2) and with the child duping
| > the handle onto stdin, and re-execing the daemon with an argument
| > telling it to use stdin as the socket to accept on. This can add a
| > little delay to the processing of pending connections, but is the
| > only way I've found to avoid the possiblity of losing connections.
|
| Hmm... This sounds very Sun specific (I'd be interesting in doing
| this on SGI's IRIX 5, which has dynamic linking like SunOS but a
| different thread library).

The solution to (nicely) restarting a W3 server with threads in mount
point handlers or dynamically changing/removing an active BGI mount
point in an OS independent manner is relatively straight forward.

Presumably there is a table in the server providing a mapping between
mount points and function pointers. For each mount point handler, keep
two additional pieces of information, a state variable and a reference
count. When a BGI handler is successfully initialized, set the ref
count to zero and the state to active. In addition, keep a ref count
on the whole table and initialize it to zero.

When a mount handler is called, increment the handler reference count
and the table ref count. When the handler returns, decrement the ref counts.

When a mount point is deleted or changed, set the state to inactive.
All subsequent searches for this mount point will see the state is
inactive and ignore this entry and either go on to find its replacement
or fail and notify the client.

When a mount point's ref count goes to zero and the state is inactive,
do the appropriate cleanup (unmount, unload of entry point, remove from
table etc.).

To stop or restart the server falls out from the above architecture.
Set all of the entries in the mount point table to inactive and wait
for the table ref count to go to zero.

The above data structures of course need to be thread protected.

Simon, do you have any target dates for the BGI spec?