Exemple #1
0
/**
 *  init of a load balancer entry

  @param entry_p: pointer to the load balancer entry
  @param index: relative index within the parent load balancer
  @param parent : pointer to the parent north load balancer

  @retval none
 */
void north_lbg_entry_init(void *parent, north_lbg_entry_ctx_t *entry_p, uint32_t index) {

    ruc_listEltInit((ruc_obj_desc_t*) entry_p);

    entry_p->index = index;
    entry_p->free = TRUE;
    entry_p->sock_ctx_ref = -1;
    entry_p->last_reconnect_time = 0;
    entry_p->state = NORTH_LBG_DEPENDENCY;
    memset(&entry_p->stats, 0, sizeof (north_lbg_stats_t));
    entry_p->parent = parent;
    ruc_listEltInit((ruc_obj_desc_t *) & entry_p->rpc_guard_timer);
    ruc_listHdrInit((ruc_obj_desc_t *) & entry_p->xmitList);

}
/**
* init of the configuration gateway 

  @param p : pointer to the context
  @param rank : index of the export gateway
  
  @retval none;
*/
void export_expgw_conf_ctx_init(export_expgw_conf_ctx_t *p,int rank)
{
   ruc_listEltInit(&p->link);
   p->index = rank;
   p->conf_state = EPGW_CONF_UNKNOWN;
   p->poll_conf_tx_state = EPGW_TX_IDLE;
   p->free = TRUE;
   p->port = 0;
   p->ipaddr = 0;
   p->current_conf_idx = 0;
   p->hostname[0] = 0;
   p->gateway_lbg_id = -1;
   memset(&p->stats,0,sizeof(export_expgw_conf_stats_t));
}
Exemple #3
0
/**
   geo_proc_ctxInit

  create the  context pool

@param     : pointer to the context
@retval   : none
 */
void geo_proc_ctxInit(geo_proc_ctx_t *p, uint8_t creation) {

    p->integrity = -1; /* the value of this field is incremented at 
					      each MS ctx allocation */

    p->timestamp = 0;
    p->eid = 0;
    p->site_id = 0;
    p->remote_ref = 0;
    p->local_ref.u32 = 0;
    p->date = 0;
    p->nb_records = 0;
    p->cur_record = 0;
    /* 
     ** timer cell
     */
    ruc_listEltInit((ruc_obj_desc_t *) & p->rpc_guard_timer);
}
Exemple #4
0
/**
ruc_obj_desc_t *ruc_listCreate_shared(uint32_t nbElements,uint32 size)

   creation of a double linked list. The input arguments
    are the number of elements and the size of an element.

   it is mandatory that the element includes ruc_obj_desc_t
    at the beginning of its structure.

   @param  nbElements : number of elements to create
   @param  size  : size of the structure of an element (including the size of ruc_obj_desc_t).
   @param key: key of the shared memory

   @retval <> NULL: pointer to the head of list
   @retval == NULL: out of memory

  note : the number of elements must not include the head of
         list.
*/
ruc_obj_desc_t *ruc_listCreate_shared(uint32_t nbElements,uint32_t size,key_t key)
{

  ruc_obj_desc_t *p,*phead;
  uint32_t   listId;
  uint8_t    *pbyte;
  int i;
  int shmid;

  RUC_LIST_TRC("listCreate_in_shared",nbElements,size,-1,-1);
  /*
  **  reject the creation if the size is less than the
  **  ruc_obj_desc_t structure size
  */
  if (size < sizeof(ruc_obj_desc_t))
  {
    RUC_WARNING(-1);
    return (ruc_obj_desc_t*)NULL;
  }
  /*
  **  if the size is not long word aligned, adjust the size
  **  to do it.
  */
  if ((size & 0x3) != 0)
  {
     size = ((size & (~0x3)) + 4 );
  }
  /*
  ** test that the size does not exceed 32 bits
  */
  {
    uint32_t nbElementOrig;
    uint32_t memRequested;

    nbElementOrig = nbElements+1;
    if (nbElementOrig == 0)
    {
      RUC_WARNING(-1);
      return (ruc_obj_desc_t*)NULL;
    }

    memRequested = size*(nbElementOrig);
    nbElementOrig = memRequested/size;
    if (nbElementOrig != (nbElements+1))
    {
      /*
      ** overlap
      */
      RUC_LIST_TRC("listCreate_err",nbElementOrig,nbElements,-1,-1);
      RUC_WARNING(-1);
      return (ruc_obj_desc_t*)NULL;
    }
  }
  /*
  ** create the shared memory
  */
  if ((shmid = shmget(key, size*(nbElements+1), IPC_CREAT | 0666)) < 0) {
      perror("shmget");
      RUC_WARNING(errno);
      return (ruc_obj_desc_t*)NULL;
  }
  /*
  * Now we attach the segment to our data space.
  */
  if ((p =(ruc_obj_desc_t *) shmat(shmid, NULL, 0)) == (ruc_obj_desc_t *) -1)
  {
    perror("shmat");
    RUC_WARNING(errno);
    return (ruc_obj_desc_t*)NULL;
  }

  /*
  ** get the list Id for the new list
  */
  listId = ruc_getListId();
  /*
  ** store the reference of the shared memory
  */
  ruc_list_shmid_table[listId] = shmid;
  /*
  ** head of list initialization
  */
  phead = p;
  phead->ps     = phead;
  phead->pp     = phead;
  phead->sysRef = p;
  phead->type   = RUC_LIST_HEAD;
  phead->countOrObjId = nbElements ;
  phead->eltSize =  size;
  phead->usrEvtCode = 0;
  phead->listId = listId;

  pbyte = (uint8_t*)p;
  for (i = 0; i < nbElements; i++)
  {
    pbyte +=size;
    p = (ruc_obj_desc_t*)pbyte;
    /*
    **  initialize the element header
    */
    ruc_listEltInit(p);
    p->sysRef = phead;
    p->type   = RUC_LIST_ELEM;
    p->listId = phead->listId;
     /*
     **  insert in the list
     */
    ruc_objInsertTail(phead,p);
  }
  RUC_LIST_TRC("listCreate_out",nbElements,size,phead,phead->listId);
  return phead;
}