Exemple #1
0
/**
   geo_proc_module_init

  create the geo-replication context pool

@param     : context_count : number of contexts
@retval   : 0 : done
@retval     -1 : out of memory
 */
int geo_proc_module_init(uint32_t context_count) 
{
    geo_proc_ctx_t *p;
    uint32_t idxCur;
    ruc_obj_desc_t *pnext;
    uint32_t ret = 0;


    geo_proc_context_allocated = 0;
    geo_proc_context_count = context_count;
    geo_proc_context_freeListHead = (geo_proc_ctx_t*) NULL;
    /*
    **  create the active list
    */
    ruc_listHdrInit((ruc_obj_desc_t*) & geo_proc_context_activeListHead);

    /*
     ** create the Transaction context pool
     */
    geo_proc_context_freeListHead = (geo_proc_ctx_t*) ruc_listCreate(context_count, sizeof (geo_proc_ctx_t));
    if (geo_proc_context_freeListHead == (geo_proc_ctx_t*) NULL) {
        /* 
        **  out of memory
        */
        severe("Out of memory: requested size %d",(int)(context_count * sizeof (geo_proc_ctx_t)));
        return -1;
    }
    /*
    ** store the pointer to the first context
    */
    geo_proc_context_pfirst = geo_proc_context_freeListHead;
    /*
    **  initialize each entry of the free list
    */
    idxCur = 0;
    pnext = (ruc_obj_desc_t*) NULL;
    while ((p = (geo_proc_ctx_t*) ruc_objGetNext((ruc_obj_desc_t*) geo_proc_context_freeListHead,
            &pnext))
            != (geo_proc_ctx_t*) NULL) {

        p->index = idxCur;
        p->free = TRUE;
        geo_proc_ctxInit(p, TRUE);
	p->record_buf_p = NULL;
        idxCur++;
    }

    /*
     ** Initialize the timer module:period is 100 ms
     */
    geo_ctx_tmr_init(100, 15);
    /*
    ** Clear the statistics counter
    */
    memset(geo_proc_stats, 0, sizeof (uint64_t) * GEO_CTX_COUNTER_MAX);
    geo_proc_debug_init();

    return ret;
}
Exemple #2
0
/*----------------------------------------------
**   Declare a server
**----------------------------------------------
**  IN :
**     . name : name of the server
**     . nbEvent : number of events generated
**                 by the server
**
**  OUT : Server reference or -1
**-----------------------------------------------
*/
uint32_t ruc_observer_declareServer(char * name, uint32_t nbEvent) {
  RUC_OBSERVER_SERVER_T     * pSrv;
  uint32_t                      idx;

  if (ruc_observer_initDone == FALSE) {
    ERRFAT "OBSERVER not initialised" ENDERRFAT;
    return -1;
  }

  /*
  ** get the first element from the free list
  */
  pSrv = (RUC_OBSERVER_SERVER_T*)ruc_objGetFirst((ruc_obj_desc_t*) ruc_observer_server_freeListHead);
  if (pSrv == (RUC_OBSERVER_SERVER_T* )NULL) {
    ERRFAT "Out of server context" ENDERRFAT;
    return -1;
  }
  /*
  **  remove the context from the free list
  */
  ruc_objRemove(&pSrv->link);
  /*
  **  store the callback pointer,the user Reference and priority
  */

  strncpy(pSrv->name,name,RUC_OBSERVER_NAME_MAX);
  pSrv->name[RUC_OBSERVER_NAME_MAX-1] = 0;
  pSrv->nbEvent = nbEvent;

  /*
  ** Allocate an event table
   */
  pSrv->pEventTbl = (RUC_OBSERVER_EVENT_T *)malloc(nbEvent*sizeof(RUC_OBSERVER_EVENT_T));
  if (pSrv->pEventTbl == (RUC_OBSERVER_EVENT_T*)NULL) {
    /*
    ** out of memory
    */
    ERRFAT "Out of memory" ENDERRFAT;
    return -1;
  }
  /*
  **  initialize each event
  */
  for (idx=0; idx < nbEvent; idx++) {
    pSrv->pEventTbl[idx].event = idx;
    pSrv->pEventTbl[idx].pnextCur = NULL;
    ruc_listHdrInit(&pSrv->pEventTbl[idx].head);
  }

  /*
  **  insert in the server active list
  */
  ruc_objInsertTail(&ruc_observer_server_activeList.link, &pSrv->link);

  return (pSrv->ref);
}
Exemple #3
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);

}
Exemple #4
0
/**
   north_lbg_ctxInit

  create the transaction context pool

@param     : pointer to the Transaction context
@retval   : none
 */
void north_lbg_ctxInit(north_lbg_ctx_t *p, uint8_t creation) {
    int i;

    p->family = -1; /**< identifier of the socket family    */
    p->name[0] = 0;

    p->nb_entries_conf = 0; /* number of configured entries  */
    p->nb_active_entries = 0;
    p->next_entry_idx = 0;
    
    p->next_global_entry_idx_p = NULL;

    p->state = NORTH_LBG_DOWN;
    p->userPollingCallBack = NULL;
    p->available_state = 1;
    memset(&p->stats, 0, sizeof (north_lbg_stats_t));

    p->rechain_when_lbg_gets_down = 0;
    p->active_lbg_entry = -1;
    p->active_standby_mode = 0;
    p->local = 0;

    /*
     ** clear the state bitmap
     */
    for (i = 0; i < NORTH__LBG_TB_MAX_ENTRY; i++) p->entry_bitmap_state[i] = 0;


    for (i = 0; i < NORTH_LBG_MAX_PRIO; i++) {
        ruc_listHdrInit((ruc_obj_desc_t *) & p->xmitList[i]);
    }
    /*
     ** init of the context
     */
    for (i = 0; i < NORTH__LBG_MAX_ENTRY; i++) north_lbg_entry_init(p, &p->entry_tb[i], (uint32_t) i);
}
Exemple #5
0
/**
   north_lbg_module_init

  create the Transaction context pool

@param     : north_lbg_ctx_count  : number of Transaction context


@retval   : RUC_OK : done
@retval          RUC_NOK : out of memory
 */
uint32_t north_lbg_module_init(uint32_t north_lbg_ctx_count) {
    north_lbg_ctx_t *p;
    uint32_t idxCur;
    ruc_obj_desc_t *pnext;
    uint32_t ret = RUC_OK;




    north_lbg_context_allocated = 0;
    north_lbg_context_count = north_lbg_ctx_count;

    north_lbg_context_freeListHead = (north_lbg_ctx_t*) NULL;

    /*
     **  create the active list
     */
    ruc_listHdrInit((ruc_obj_desc_t*) & north_lbg_context_activeListHead);

    /*
     ** create the af unix context pool
     */
    north_lbg_context_freeListHead = (north_lbg_ctx_t*) ruc_listCreate(north_lbg_ctx_count, sizeof (north_lbg_ctx_t));
    if (north_lbg_context_freeListHead == (north_lbg_ctx_t*) NULL) {
        /* 
         **  out of memory
         */

        RUC_WARNING(north_lbg_ctx_count * sizeof (north_lbg_ctx_t));
        return RUC_NOK;
    }
    /*
     ** store the pointer to the first context
     */
    north_lbg_context_pfirst = north_lbg_context_freeListHead;

    /*
     **  initialize each entry of the free list
     */
    idxCur = 0;
    pnext = (ruc_obj_desc_t*) NULL;
    while ((p = (north_lbg_ctx_t*) ruc_objGetNext((ruc_obj_desc_t*) north_lbg_context_freeListHead,
            &pnext))
            != (north_lbg_ctx_t*) NULL) {

        p->index = idxCur;
        p->free = TRUE;
        north_lbg_ctxInit(p, TRUE);
        p->state = NORTH_LBG_DEPENDENCY;
        idxCur++;
    }

    north_lbg_debug_init();
    /*
     ** timer mode init
     */
    north_lbg_tmr_init(200, 15);


    return ret;
}
Exemple #6
0
/*----------------------------------------------
**   init of the observer service
**----------------------------------------------
**  IN :
**     . maxServer = number server context
**     . maxClient = number of client context
**  OUT : RUC_OK or RUC_NOK
**-----------------------------------------------
*/
uint32_t ruc_observer_init(uint32_t maxClient, uint32_t maxServer) {
  int                         idx;
  ruc_obj_desc_t            * pnext=(ruc_obj_desc_t*)NULL;
  RUC_OBSERVER_SERVER_T     * pSrv;
  RUC_OBSERVER_CLIENT_T     * pClt;

  if (ruc_observer_initDone == TRUE) {
    return RUC_OK;
  }

  ruc_observer_max_server = maxServer;
  ruc_observer_max_client = maxClient;
  /*
  ** create the server distributor
  */
  ruc_observer_server_freeListHead =
    (RUC_OBSERVER_SERVER_T *)ruc_listCreate(maxServer, sizeof(RUC_OBSERVER_SERVER_T));
  if (ruc_observer_server_freeListHead == (RUC_OBSERVER_SERVER_T*)NULL) {
    /*
    ** out of memory
    */
    ERRFAT "runc_observer_init: out of memory" ENDERRFAT;
    return RUC_NOK;
  }
  /*
  **  initialize each element of the free list
  */
  idx = 0;
  pnext = (ruc_obj_desc_t*)NULL;
  while ((pSrv = (RUC_OBSERVER_SERVER_T*)
	  ruc_objGetNext(&ruc_observer_server_freeListHead->link, &pnext))
	 !=(RUC_OBSERVER_SERVER_T*)NULL)  {
    pSrv->nbEvent   = 0;
    pSrv->ref       = idx;
    pSrv->pEventTbl = NULL;
    strcpy(pSrv->name,"FREE");
    idx +=1;
  }
  ruc_listHdrInit(&ruc_observer_server_activeList.link);



  /*
  ** create the client distributor
  */
  ruc_observer_client_freeListHead =
    (RUC_OBSERVER_CLIENT_T *)ruc_listCreate(maxClient, sizeof(RUC_OBSERVER_CLIENT_T));
  if (ruc_observer_client_freeListHead == (RUC_OBSERVER_CLIENT_T*)NULL) {
    /*
    ** out of memory
    */
    ERRFAT "runc_observer_init: out of memory" ENDERRFAT;
    return RUC_NOK;
  }
  /*
  **  initialize each element of the free list
  */
  idx = 0;
  pnext = (ruc_obj_desc_t*)NULL;
  while ((pClt = (RUC_OBSERVER_CLIENT_T*)
              ruc_objGetNext((ruc_obj_desc_t*)ruc_observer_client_freeListHead, &pnext))
	 !=(RUC_OBSERVER_CLIENT_T*)NULL)  {
    pClt->priority  = -1;
    pClt->ref       = idx;
    pClt->objRef    = NULL;
    pClt->event     = -1;
    pClt->callBack  = (ruc_observer_cbk)NULL;
    strcpy(pClt->name,"FREE");
    idx +=1;
  }

  ruc_observer_initDone = TRUE;
  return RUC_OK;

}
Exemple #7
0
/*
**----------------------------------------------
**  geo_ctx_tmr_init
**----------------------------------------------
**
**   charging timer service initialisation request
**    
**  IN : period_ms : period between two queue sequence reading in ms
**       credit    : pdp credit processing number
**
**  OUT : OK/NOK
**
**-----------------------------------------------
*/
int geo_ctx_tmr_init(uint32_t period_ms,
                    uint32_t credit)
{

    int i;
    
    /**************************/
    /* configuration variable */
    /* initialization         */
    /**************************/


    /*
    ** time between to look up to the charging timer queue
    */
    if (period_ms!=0){
        geo_ctx_tmr.period_ms=period_ms;
    } else {
        severe( "bad provided timer period (0 ms), I continue with 100 ms" );
        geo_ctx_tmr.period_ms=100;
    }

    /*
    ** Number of pdp context processed at each look up;
    */
    if (credit!=0){
        geo_ctx_tmr.credit=credit;
    } else {
        severe( "bad provided  credit (0), I continue with 1" );
        geo_ctx_tmr.credit=1;
    }

    /**************************/
    /* working variable       */
    /* initialization         */
    /**************************/


    /*
    **  queue initialization
    */
    for (i = 0; i < GEO_CTX_TMR_SLOT_MAX; i++)
    {
      ruc_listHdrInit(&geo_ctx_tmr.queue[i]);
    }

    /*
    ** charging timer periodic launching
    */
    geo_ctx_tmr.p_periodic_timCell=ruc_timer_alloc(0,0);
    if (geo_ctx_tmr.p_periodic_timCell == (struct timer_cell *)NULL){
        severe( "No timer available for MS timer periodic" );
        return(RUC_NOK);
    }
    ruc_periodic_timer_start(geo_ctx_tmr.p_periodic_timCell,
	      (geo_ctx_tmr.period_ms*TIMER_TICK_VALUE_100MS/100),
	      &geo_ctx_tmr_periodic,
	      0);
	      
    return(RUC_OK);
}
Exemple #8
0
/**
*  Init of the pseudo fuse thread 

  @param ch : initial channel
  @param se : initial session
  @param rozofs_fuse_buffer_count : number of request buffers (corresponds to the number of fuse save context)  
  
  @retval 0 on success
  @retval -1 on error
*/
int rozofs_fuse_init(struct fuse_chan *ch,struct fuse_session *se,int rozofs_fuse_buffer_count)
{
  int status = 0;
  int i;
  
//   return 0;

  fuse_sharemem_init_done = 0;   
  
  int fileflags;
  rozofs_fuse_ctx_p = malloc(sizeof (rozofs_fuse_ctx_t));
  if (rozofs_fuse_ctx_p == NULL) 
  {
    /*
    ** cannot allocate memory for fuse rozofs context
    */
    return -1;
  }
  memset(rozofs_fuse_ctx_p,0,sizeof (rozofs_fuse_ctx_t));
  /*
  ** clear read/write merge stats table
  */
  memset(rozofs_write_merge_stats_tab,0,sizeof(uint64_t)*RZ_FUSE_WRITE_MAX);
  memset (rozofs_write_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset (rozofs_read_buf_section_table,0,sizeof(uint64_t)*ROZOFS_FUSE_NB_OF_BUSIZE_SECTION_MAX);
  memset(&rozofs_fuse_read_write_stats_buf,0,sizeof(rozofs_fuse_read_write_stats));
  /*
  ** init of the context
  */
  rozofs_fuse_ctx_p->fuseReqPoolRef = NULL;
  rozofs_fuse_ctx_p->ch             = NULL;
  rozofs_fuse_ctx_p->se             = se;
  rozofs_fuse_ctx_p->bufsize        = 0; 
  rozofs_fuse_ctx_p->buf_fuse_req_p = NULL;
  rozofs_fuse_ctx_p->dir_attr_invalidate = 0;
  rozofs_fuse_ctx_p->initBufCount   = rozofs_fuse_buffer_count;
  
  while (1)
  {
     /*
     ** get the receive buffer size for former channel in order to create the request distributor:
     ** note: by default the fuse buffer is 4K+128K: for RozoFS the payload can reach 512K (x4)
     */
     int bufsize = fuse_chan_bufsize(ch)*4;
     rozofs_fuse_ctx_p->bufsize = bufsize;
     /*
     ** create the distributor fro receiving data from fuse kernel
     */
     status = rozofs_fuse_init_rcv_buffer_pool(ROZOFS_FUSE_RECV_BUF_COUNT,bufsize);
     if (status < 0)
     {
        severe( "rozofs_fuse_init fuse buffer pool creation error(%d,%d)", (int)ROZOFS_FUSE_RECV_BUF_COUNT, (int)bufsize ) ;
        status = -1;
        break;     
     
     }
     /*
     ** create the pool
     */
     rozofs_fuse_ctx_p->fuseReqPoolRef = ruc_buf_poolCreate(rozofs_fuse_buffer_count,sizeof(rozofs_fuse_save_ctx_t));
     if (rozofs_fuse_ctx_p->fuseReqPoolRef == NULL)
     {
        severe( "rozofs_fuse_init buffer pool creation error(%d,%d)", (int)rozofs_fuse_buffer_count, (int)sizeof(rozofs_fuse_save_ctx_t) ) ;
        status = -1;
        break;
     }
     ruc_buffer_debug_register_pool("fuseCtx",  rozofs_fuse_ctx_p->fuseReqPoolRef);
     /*
     ** Allocate a head of list for queueing pending lookup requests
     */
     for (i=0; i< ROZOFS_MAX_LKUP_QUEUE ; i++)
     {
       ruc_listHdrInit(&rozofs_lookup_queue[i]);
     }
     
     
     /*
     ** allocate a buffer for receiving the fuse request
     */
     rozofs_fuse_ctx_p->buf_fuse_req_p = malloc(bufsize);
     if (rozofs_fuse_ctx_p == NULL) 
     {     
        severe( "rozofs_fuse_init out of memory %d", bufsize ) ;
        status = -1;
        break;     
     }
     /*
     ** get the fd of the channel
     */
     rozofs_fuse_ctx_p->fd = fuse_chan_fd(ch);
     /*
     ** wait the end of the share memroy init prior providing it to fuse
     */
     while (rozofs_shared_mem_init_done == 0) sleep(1);  
     /*
     ** create a new channel with the specific operation for rozofs (non-blocking)
     */  
     rozofs_fuse_ctx_p->ch = fuse_chan_new(&rozofs_fuse_ch_ops,fuse_chan_fd(ch),bufsize,rozofs_fuse_ctx_p);  
     if (rozofs_fuse_ctx_p->ch == NULL)
     {
        severe( "rozofs_fuse_init fuse_chan_new error"  ) ;
        status = -1;
        break;          
     }
     /*
     ** remove the association between the initial session and channel
     */
     fuse_session_remove_chan(ch);  
     /*
     ** OK, now add the new channel
     */
     fuse_session_add_chan(se,rozofs_fuse_ctx_p->ch );  
     /*
     ** set the channel in non blocking mode
     */
     if((fileflags=fcntl(rozofs_fuse_ctx_p->fd,F_GETFL,0))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }

     if((fcntl(rozofs_fuse_ctx_p->fd,F_SETFL,fileflags|O_NDELAY))==-1)
     {
       RUC_WARNING(errno);
       status = -1; 
       break;   
     }
     /*
     ** send XON to the fuse channel
     */
     {
        int ret;
	rozofs_fuse_ctx_p->ioctl_supported = 1;
	rozofs_fuse_ctx_p->data_xon        = 1;
     
        while(1)
	{	
	  ret = ioctl(rozofs_fuse_ctx_p->fd,1,NULL);
	  if (ret < 0) 
	  {
	     warning("ioctl error %s",strerror(errno));
	     rozofs_fuse_ctx_p->ioctl_supported = 0;
	     break;

	  }
          if (rozofs_fuse_ctx_p->dir_attr_invalidate == 0)
	  {
	    ret = ioctl(rozofs_fuse_ctx_p->fd,3,NULL);
	    if (ret < 0) 
	    {
	       warning("ioctl error %s",strerror(errno));
//	       rozofs_fuse_ctx_p->ioctl_supported = 0;
	       rozofs_fuse_ctx_p->dir_attr_invalidate = 1;
	       break;
	    }		
	  }
	  break;     
        }
     }
     /*
     ** perform the connection with the socket controller
     */
   /*
   ** OK, we are almost done, just need to connect with the socket controller
   */
   rozofs_fuse_ctx_p->connectionId = ruc_sockctl_connect(rozofs_fuse_ctx_p->fd,  // Reference of the socket
                                              "rozofs_fuse",                 // name of the socket
                                              3,                             // Priority within the socket controller
                                              (void*)rozofs_fuse_ctx_p,      // user param for socketcontroller callback
                                              &rozofs_fuse_callBack_sock);   // Default callbacks
    if (rozofs_fuse_ctx_p->connectionId == NULL)
    {
       /*
       ** Fail to connect with the socket controller
       */
       RUC_WARNING(-1);
       status = -1; 
       break;   
    } 
    rozofs_fuse_get_ticker();

     status = 0;
     break;
  }
  /*
  ** attach the callback on socket controller
  */
//#warning no poller
  ruc_sockCtrl_attach_applicative_poller(rozofs_fuse_scheduler_entry_point); 
  for(i = 0; i < 3;i++) fuse_profile[i] = 0;
  
  uma_dbg_addTopic("fuse", rozofs_fuse_show);
  return status;
  
}
Exemple #9
0
/**
   af_unix_module_init

  create the Transaction context pool

@param     : af_unix_ctx_count  : number of Transaction context
@param     : max_xmit_buf_count : number of xmit buffers
@param     : max_xmit_buf_size  : xmit buffer size
@param     : max_recv_buf_count : number of receive buffers
@param     : max_recv_buf_count : receive buffer size

@retval   : RUC_OK : done
@retval          RUC_NOK : out of memory
 */
uint32_t af_unix_module_init(uint32_t af_unix_ctx_count,
        int max_xmit_buf_count, int max_xmit_buf_size,
        int max_recv_buf_count, int max_recv_buf_size
        ) {
    af_unix_ctx_generic_t *p;
    uint32_t idxCur;
    ruc_obj_desc_t *pnext;
    uint32_t ret = RUC_OK;

    af_unix_xmit_buf_count = max_xmit_buf_count;
    af_unix_xmit_buf_size = max_xmit_buf_size;
    af_unix_recv_buf_count = max_recv_buf_count;
    af_unix_recv_buf_size = max_recv_buf_size;



    af_unix_context_allocated = 0;
    af_unix_context_count = af_unix_ctx_count;

    while (1) {
        af_unix_buffer_pool_tb[0] = ruc_buf_poolCreate(af_unix_xmit_buf_count, af_unix_xmit_buf_size);
        if (af_unix_buffer_pool_tb[0] == NULL) {
            ret = RUC_NOK;
            severe( "xmit ruc_buf_poolCreate(%d,%d)", af_unix_xmit_buf_count, af_unix_xmit_buf_size );
            break;
        }
        af_unix_buffer_pool_tb[1] = ruc_buf_poolCreate(af_unix_recv_buf_count, af_unix_recv_buf_size);
        if (af_unix_buffer_pool_tb[1] == NULL) {
            ret = RUC_NOK;
            severe( "rcv ruc_buf_poolCreate(%d,%d)", af_unix_recv_buf_count, af_unix_recv_buf_size );
            break;
        }

        af_unix_context_freeListHead = (af_unix_ctx_generic_t*) NULL;

        /*
         **  create the active list
         */
        ruc_listHdrInit((ruc_obj_desc_t*) & af_unix_context_activeListHead);

        /*
         ** create the af unix context pool
         */
        af_unix_context_freeListHead = (af_unix_ctx_generic_t*) ruc_listCreate(af_unix_ctx_count, sizeof (af_unix_ctx_generic_t));
        if (af_unix_context_freeListHead == (af_unix_ctx_generic_t*) NULL) {
            /*
             **  out of memory
             */

            RUC_WARNING(af_unix_ctx_count * sizeof (af_unix_ctx_generic_t));
            return RUC_NOK;
        }
        /*
         ** store the pointer to the first context
         */
        af_unix_context_pfirst = af_unix_context_freeListHead;

        /*
         **  initialize each entry of the free list
         */
        idxCur = 0;
        pnext = (ruc_obj_desc_t*) NULL;
        while ((p = (af_unix_ctx_generic_t*) ruc_objGetNext((ruc_obj_desc_t*) af_unix_context_freeListHead,
                &pnext))
                != (af_unix_ctx_generic_t*) NULL) {

            p->index = idxCur;
            p->free = TRUE;
            af_unix_ctxInit(p, TRUE);
            idxCur++;
        }

        af_unix_debug_init();
        break;
    }

    return ret;
}
Exemple #10
0
/**
   af_unix_ctxInit

  create the transaction context pool

@param     : pointer to the Transaction context
@retval   : none
 */
void af_unix_ctxInit(af_unix_ctx_generic_t *p, uint8_t creation) {
    int i;
    com_xmit_template_t *xmit_p;
    com_recv_template_t *recv_p;
    rozofs_socket_stats_t *stats_p;

    p->family = -1; /**< identifier of the socket family    */
    p->instance_id = -1; /**< instance number within the family   */
    p->nickname[0] = 0;
    p->dscp = 0;

    p->af_family = -1;
    p->src_sun_path[0] = 0;
    p->remote_sun_path[0] = 0;
    p->src_ipaddr_host = -1;
    p->src_port_host = -1;
    p->remote_ipaddr_host = -1;
    p->remote_port_host = -1;

    p->socketRef = -1; /* clear the reference of the socket  */
    p->connectionId = NULL;
    p->userRcvCallBack = NULL;
    p->userRcvAllocBufCallBack = NULL;
    p->userDiscCallBack = NULL; /* callBack for TCP disconnection detection         */
    p->userRcvReadyCallBack = NULL; /* callBack for receiver ready         */
    p->userXmitReadyCallBack = NULL;
    p->userXmitEventCallBack = NULL;
    p->userConnectCallBack = NULL;
    p->userXmitDoneCallBack = NULL;
    p->userHdrAnalyzerCallBack = NULL;
    p->userRef = NULL; /* user reference that must be recalled in the callbacks */
    p->conf_p = NULL;

    p->userPollingCallBack = NULL;
    p->userAvailabilityCallBack = NULL;
    p->cnx_availability_state = AF_UNIX_CNX_AVAILABLE;
    p->availability_param = (uint32_t) - 1;

    /*
     ** Transmitter init
     */
    xmit_p = &p->xmit;
    xmit_p->xmitPoolOrigin = af_unix_buffer_pool_tb[0]; /**<current pool reference                */
    xmit_p->xmitPoolRef = xmit_p->xmitPoolOrigin; /**< head of the current xmit buffer pool */
    xmit_p->state = XMIT_IDLE; /**< xmit fsm state                       */

    xmit_p->eoc_flag = 0; /**< fin de congestion flag               */
    xmit_p->congested_flag = 0; /**< congested:1                          */
    xmit_p->xmit_req_flag = 0; /**< assert to 1 when xmit ready is required */
    xmit_p->filler_flag = 0; /**< congested:1                          */

    xmit_p->nbWrite = 0;
    xmit_p->nb2Write = 0;
    xmit_p->bufRefCurrent = NULL; /**< reference of the current buffer to send or NULL if no buffer  */
    xmit_p->eoc_threshold = 0; /**< current EOC threshold                */
    xmit_p->eoc_threshold_conf = AF_UNIX_CONGESTION_DEFAULT_THRESHOLD; /**< configured EOC threshold        */
    xmit_p->xmit_credit = 0;
    ; /**< current xmit credit                 */
    xmit_p->xmit_credit_conf = AF_UNIX_XMIT_CREDIT_DEFAULT; /**< configured xmit credit              */
    for (i = 0; i < UMA_MAX_TCP_XMIT_PRIO; i++) {
        ruc_listHdrInit((ruc_obj_desc_t *) & xmit_p->xmitList[i]);

    }
    /*
     ** receiver init
     */

    recv_p = &p->recv;
    recv_p->rcvPoolOrigin = af_unix_buffer_pool_tb[1]; /*current pool reference */
    recv_p->rcvPoolRef = recv_p->rcvPoolOrigin; /* it could be either the reference of
                                    ** the user bufferv reference pool or
				                    ** the default one used by the TCP
				                    ** connection*/

    recv_p->nbread = 0;
    recv_p->nb2read = 0;
    recv_p->bufRefCurrent = NULL;
    recv_p->state = RECV_IDLE;
    /*
     ** clear the rpc part of the stream receiver
     */
    memset(&recv_p->rpc, 0, sizeof (com_rpc_recv_template_t));
    /*
     **  configuration parameters
     */
    recv_p->recv_credit_conf = AF_UNIX_RECV_CREDIT_DEFAULT;
    recv_p->headerSize = 0; /* size of the header to read                 */
    recv_p->msgLenOffset = 0; /* offset where the message length fits       */
    recv_p->msgLenSize = 0; /* size of the message length field in bytes  */
    recv_p->bufSize = 0; /* length of buffer (xmit and received)        */
    /*
     ** Stats initialisation
     */
    stats_p = &p->stats;
    memset(stats_p, 0, sizeof (rozofs_socket_stats_t));

    p->cnx_supevision.u64 = 0;
    p->cnx_availability_state = AF_UNIX_CNX_AVAILABLE;

}