コード例 #1
0
void
CS_set_server_connect(char *listen_id)
{
    i4		i;

    CS_find_server_slot(&i);

    STncpy( Cs_svinfo->csi_connect_id, listen_id,
	(sizeof(Cs_svinfo->csi_connect_id) - 1) );
    Cs_svinfo->csi_connect_id[ sizeof(Cs_svinfo->csi_connect_id) - 1 ] = EOS;
}
コード例 #2
0
/*{
** Name: CS_init_pseudo_server() - init CS for a peudo-server
**
** Description:
**      Allocate resources for server-server processing by a process
**      which exists at server functional level without full server
**      task switching and asycronous i/o.  Such processes do not
**      need a shared memory segement but do need cross process semaphores
**      and other resources of a server that are keep in the system
**      shared memory segment.
**
**      It is expected that CS will call CS_init_pseudo_server() and
**      CS_map_serv_segment() once at pseudo-server initialization.
**
**      This call is internal to CS is meant only to be called by CL, and may
**      only exist on unix systems supporting shared memory.
**
** Inputs:
**      size                            size in bytes of shared mem segment.
**
** Outputs:
**      id                              on success set to id of segment.
**      err_code                        system dependent error code.
**
**      Returns:
**          E_DB_OK
**
**      Exceptions:
**          none
**
** Side Effects:
**          none
**
** History:
**      28-mar-88 (anton)
**          Created.
**      3-jul-1992 (bryanp)
**          Install the server event handler for pseudo-servers here.
*/
STATUS
CS_init_pseudo_server(u_i4 *server_seg_num)
{
    STATUS              status = OK;
    CS_SERV_INFO        *serv_info;
    i4                  i;
    CSSL_CB             *slcb;

    status = CS_find_server_slot(&i);

    serv_info = Cs_sm_cb->css_servinfo;

    if (!status)
    {
        /* initialize it's description in the master control block */

        Cs_svinfo->csi_serv_desc.cssm_size = 0;
        Cs_svinfo->csi_serv_desc.cssm_id = -1;

        *server_seg_num = i;

        /*
        ** Explicitly clear these TAS objects, for machines such as the HP
        ** where MEfill'ing the memory with zeros does not initialize the
        ** TAS objects to "clear" state.
        */
        CS_ACLR(&Cs_svinfo->csi_nullev);
        CS_ACLR(&Cs_svinfo->csi_events_outstanding);
        CS_ACLR(&Cs_svinfo->csi_wakeme);
        CS_SPININIT(&Cs_svinfo->csi_spinlock);
        for (i = 0;
                i < (sizeof(Cs_svinfo->csi_subwake) /
                sizeof(Cs_svinfo->csi_subwake[0]));
                i++)
        {
            CS_ACLR(&Cs_svinfo->csi_subwake[i]);
        }

        status = CSinstall_server_event(&slcb, 0, 0, CSev_resume);

        /* FIX ME - bunch of other stuff */
    }

    return(status);
}
コード例 #3
0
/*{
** Name: CS_alloc_serv_segment()        - Create shared memory for a server
**
** Description:
**      Allocate a shared memory segment of "size" bytes.  All data placed
**      in this segment should be position independent.
**
**      Upon success this function will create the shared memory segment with
**      the given id and size.  To actually access the shared memory segment
**      the user must make a CS_map_server_segment() call.  It is expected
**      that this single request will fulfill all shared memory needs particular
**      to a single server.  It may be difficult or impossible to extend the
**      shared memory resources of some machines to provide for more than 3
**      different shared memory segments mapped to a single process (the
**      control segment, the locking/logging segment, and the server segment).
**
**      It is expected that CS will call CS_alloc_serv_segment() and
**      CS_map_serv_segment() once at server initialization.
**      Slaves will only call the map function.
**
**      This call is internal to CS is meant only to be called by CS, and may
**      only exist on unix systems supporting shared memory.
**
** Inputs:
**      size                            size in bytes of shared mem segment.
**
** Outputs:
**      id                              on success set to id of segment.
**      err_code                        system dependent error code.
**
**      Returns:
**          E_DB_OK
**
**      Exceptions:
**          none
**
** Side Effects:
**          none
**
** History:
**      08-sep-88 (mmm)
**          First Version
**      12-jun-89 (rogerk)
**          Changed arguments to MEget_pages, MEdetach calls.  They now use
**          character name keys rather than a LOCATION pointer.  Changed
**          ME_loctokey call to ME_getkey.
**      26-aug-89 (rexl)
**          Added calls to protect page allocator.
**      3-jul-1992 (bryanp)
**          Explicitly ACLR the TAS objects when allocating server segment.
**      07-nov-1996 (canor01)
**          Explicitly initialize the csi_spinlock object.
*/
STATUS
CS_alloc_serv_segment(SIZE_TYPE size, u_i4 *server_seg_num,
	PTR *address, CL_ERR_DESC *err_code)
{
    STATUS              status = OK;
    CS_SERV_INFO        *serv_info;
    PTR                 dummy;
    i4                  i;
    SIZE_TYPE           alloc_pages;
    char                segname[48];

    status = CS_find_server_slot(&i);

    serv_info = Cs_sm_cb->css_servinfo;

    if (!address)
    {
        address = &dummy;
    }

    if (status)
    {
        SETCLERR(err_code, 0, 0);    /* since find_server_slot doesn't set */
    }
    else
    {
        /* now allocate and initialize the server segment */

        STcopy("server.", segname);
        CVna(i, segname+STlength(segname));

        size = (size + ME_MPAGESIZE - 1) & ~ (ME_MPAGESIZE - 1);
# ifdef SERV_MAP_ADDR
        *address = (PTR) SERV_MAP_ADDR;
        status = MEget_pages(ME_MZERO_MASK|ME_SSHARED_MASK|ME_CREATE_MASK|
                        ME_ADDR_SPEC, size/ME_MPAGESIZE, segname, address,
                        &alloc_pages, err_code);
# else
        status = MEget_pages(ME_MZERO_MASK|ME_SSHARED_MASK|ME_CREATE_MASK,
                             size/ME_MPAGESIZE, segname, address,
                             &alloc_pages, err_code);
# endif

        if (status)
        {
            /* Unable to create lg/lk shared memory segment */
            status = FAIL;
        }
        else
        {
            /* initialize it's description in the master control block */

            Cs_svinfo->csi_serv_desc.cssm_size = size;
            Cs_svinfo->csi_serv_desc.cssm_id = ME_getkey(segname);

            *server_seg_num = i;

            /*
            ** Explicitly clear these TAS objects, for machines such as the HP
            ** where MEfill'ing the memory with zeros does not initialize the
            ** TAS objects to "clear" state.
            */
            CS_ACLR(&Cs_svinfo->csi_nullev);
            CS_ACLR(&Cs_svinfo->csi_events_outstanding);
            CS_ACLR(&Cs_svinfo->csi_wakeme);
            CS_SPININIT(&Cs_svinfo->csi_spinlock);
            for (i = 0;
                i < (sizeof(Cs_svinfo->csi_subwake) /
                        sizeof(Cs_svinfo->csi_subwake[0]));
                i++)
            {
                CS_ACLR(&Cs_svinfo->csi_subwake[i]);
            }

            if (address == &dummy)
                MEdetach(segname, address, err_code); /* and free pages */

            /* FIX ME - bunch of other stuff */
        }
    }

    return(status);
}