OSF DCE Application Development Guide--Core Components
OSF DCE Application Development Guide—Core Components
16.3.2 Context Handles in a Server Manager
Server manager code to provide a rudimentary implementation of the store interface is
as follows:
/* context_manager.c -- implementation of "store" interface. */
/* */
/* The server maintains a certain number of storage areas, only one of */
/* which can be (or should be) opened by a single client at a time. */
/* More than one client can, however, apparently be invoked (up to the */
/* number of separate storelets == store handles available, defined by */
/* the value of NUM_STORELETS). Each client keeps track of its store */
/* (and likewise enables the server to do the same) by means of the */
/* context handle it receives when it opens its store. */
/* */
/************************************************************************/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <pthread.h>
#include <dce/dce_error.h>
#include <dce/daclif.h>
#include "context.h"
#define NUM_STORELETS 10
/************************************************************************/
/* The actual "storelet" structure... */
typedef struct store_hdr{
pthread_mutex_t ref_lock;
unsigned32 size;
unsigned32 refcount;
idl_byte *storage;
} store_hdr_t;
store_hdr_t headers[NUM_STORELETS]; /* There’s an array of these. */
/************************************************************************/
/* The store specification structure; note that it is equivalent to the */
/* handle; the pointer to it is returned as the handle by the */
/* store_open() routine below... */
/* The assumption is that all access to a given handle is serialized */
/* in a single thread, so no locking is needed for these. */
typedef struct store_spec{
unsigned32 number; /* The storelet number we’ve opened. */
unsigned32 offset; /* The current read/write position. */
} store_spec_t; /* There’s only one of these; it’s the handle that */
/* gives access to one of the NUM_STORELETS set of */
/* "storelets". */
16 − 14 Tandem Computers Incorporated 124245