next up previous
Next: Retrieving a blocked system Up: Blocking the caller using Previous: Blocking and completing reads


Using fusd_destroy() to clean up client state

Finally, let's take a look at one last aspect of the pager program: how it cleans up the per-client state when a client leaves. This is mostly straightforward, with one exception: a client may have an outstanding read request out when a close request comes in. Normally, a client can't make another system call request while a previous system call is still blocked. However, the close system call is an exception: it gets called when a client dies (for example, if it receives an interrupt signal). If a close comes in while another system call is still outstanding, the state associated with the outstanding request should be freed to avoid a memory leak. The fusd_destroy function is used to do this, seen on linen 12-14 of Program 13.


\begin{Program}
% latex2html id marker 783\listinginput[5]{1}{pager-close.c.example}
\caption{pager.c (Part 3): Cleaning up when a client leaves}\end{Program}



Jeremy Elson 2003-08-20