OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
spec = (store_spec_t *)*store_h; /* Get the store spec. */
hdr = headers + spec->number; /* Point to the correct storelet. */
/* If the thing is actually opened, close it... */
if (hdr->refcount > 0)
{
/* Lock the header first... */
*status = pthread_mutex_lock((pthread_mutex_t *)hdr);
if (*status != 0)
{
printf("Close: lock failed0);
return;
}
/* Check the reference count to make sure no one slipped in */
/* before we could lock the header, and already closed the */
/* critter... */
if (hdr->refcount > 0)
{
/* The store is open, and it’s locked by us, so we */
/* can safely close it. So do it. First, decrement */
/* the reference count... */
hdr->refcount--;
/* Is it completely closed now? */
if (hdr->refcount == 0)
{
/* If so, get rid of its storage space... */
hdr->size = 0;
free(hdr->storage);
}
}
/* If the store turned out to be closed before we could */
/* close it, we have nothing to do but release the lock... */
*status = pthread_mutex_unlock((pthread_mutex_t *)hdr);
if (*status != 0)
{
printf("Close: unlock failed0);
return;
}
}
/* And free our handle space... */
free(spec);
/* Be sure to NULL the context handle. Otherwise, the context */
/* will be considered to be live as long as the client is run- */
/* ning... */
*store_h = NULL;
*status = error_status_ok;
}
/******
*
16 − 18 Tandem Computers Incorporated 124245