Exemplo n.º 1
0
/**
 * @brief Determine the dupreq2 DRC type to handle the supplied svc_req
 *
 * @param[in] req The svc_req being processed
 *
 * @return a value of type enum_drc_type.
 */
static inline enum drc_type get_drc_type(struct svc_req *req)
{
	if (get_ipproto_by_xprt(req->rq_xprt) == IPPROTO_UDP)
		return DRC_UDP_V234;
	else {
		if (req->rq_vers == 4)
			return DRC_TCP_V4;
	}
	return DRC_TCP_V3;
}
Exemplo n.º 2
0
int nfs_dupreq_add_not_finished(long xid,
                                struct svc_req *ptr_req,
                                SVCXPRT *xprt,
                                struct prealloc_pool *dupreq_pool,
                                nfs_res_t *res_nfs)
{
  hash_buffer_t buffkey;
  hash_buffer_t buffval;
  hash_buffer_t buffdata;
  dupreq_entry_t *pdupreq = NULL;
  int status = 0;
  dupreq_key_t *pdupkey = NULL;
  hash_table_t * ht_dupreq = NULL ;

  /* Get correct HT depending on proto used */
  ht_dupreq = get_ht_by_xprt( xprt ) ;
 
  /* Entry to be cached */
  GetFromPool(pdupreq, dupreq_pool, dupreq_entry_t);
  if(pdupreq == NULL)
    return DUPREQ_INSERT_MALLOC_ERROR;

  memset(pdupreq, 0, sizeof(*pdupreq));
  if(pthread_mutex_init(&pdupreq->dupreq_mutex, NULL) == -1)
    {
      ReleaseToPool(pdupreq, dupreq_pool);
      return DUPREQ_INSERT_MALLOC_ERROR;
    }

  if((pdupkey = (dupreq_key_t *) Mem_Alloc(sizeof(dupreq_key_t))) == NULL)
    {
      ReleaseToPool(pdupreq, dupreq_pool);
      return DUPREQ_INSERT_MALLOC_ERROR;
    }

  /* Get the socket address for the key and the request */
  if(copy_xprt_addr(&pdupkey->addr, xprt) == 0 ||
     copy_xprt_addr(&pdupreq->addr, xprt) == 0)
    {
      Mem_Free(pdupkey);
      ReleaseToPool(pdupreq, dupreq_pool);
      return DUPREQ_INSERT_MALLOC_ERROR;
    }

  pdupkey->xid = xid;
  pdupreq->xid = xid;

  /* Checksum the request */
  pdupkey->checksum = 0;
  pdupreq->checksum = 0;

  /* I have to keep an integer as key, I wil use the pointer buffkey->pdata for this,
   * this also means that buffkey->len will be 0 */
  buffkey.pdata = (caddr_t) pdupkey;
  buffkey.len = sizeof(dupreq_key_t);

  /* I build the data with the request pointer that should be in state 'IN USE' */
  pdupreq->rq_prog = ptr_req->rq_prog;
  pdupreq->rq_vers = ptr_req->rq_vers;
  pdupreq->rq_proc = ptr_req->rq_proc;
  pdupreq->timestamp = time(NULL);
  pdupreq->processing = 1;
  pdupreq->ipproto = get_ipproto_by_xprt( xprt ) ;
  buffdata.pdata = (caddr_t) pdupreq;
  buffdata.len = sizeof(dupreq_entry_t);

  LogDupReq("Add Not Finished", &pdupreq->addr, pdupreq->xid, pdupreq->rq_prog);

  status = HashTable_Test_And_Set(ht_dupreq, &buffkey, &buffdata,
                                  HASHTABLE_SET_HOW_SET_NO_OVERWRITE);

  if (status == HASHTABLE_ERROR_KEY_ALREADY_EXISTS)
    {
      if(HashTable_Get(ht_dupreq, &buffkey, &buffval) == HASHTABLE_SUCCESS)
        {
          P(((dupreq_entry_t *)buffval.pdata)->dupreq_mutex);
          if ( ((dupreq_entry_t *)buffval.pdata)->processing == 1)
            {
              status = DUPREQ_BEING_PROCESSED;
            }
          else
            {
              *res_nfs = ((dupreq_entry_t *) buffval.pdata)->res_nfs;
              status = DUPREQ_ALREADY_EXISTS;
            }
          V(((dupreq_entry_t *)buffval.pdata)->dupreq_mutex);
        }
      else
        status = DUPREQ_NOT_FOUND;
    }
  else if (status == HASHTABLE_INSERT_MALLOC_ERROR)
      status = DUPREQ_INSERT_MALLOC_ERROR;
  else
    status = DUPREQ_SUCCESS;
  if (status != DUPREQ_SUCCESS) {
    ReleaseToPool(pdupreq, dupreq_pool);
    Mem_Free(pdupkey);
  }
  return status;
}                               /* nfs_dupreq_add_not_finished */
Exemplo n.º 3
0
static hash_table_t * get_ht_by_xprt( SVCXPRT * xprt )
{
   return (get_ipproto_by_xprt( xprt )==IPPROTO_UDP)?ht_dupreq_udp:ht_dupreq_tcp ;
}