Пример #1
0
/**
 * FSAL_proxy_clientid_renewer_thread: this thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *  This thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *
 * \return never returns... This is a infinite loop that will die when the daemon stops
 */
void *FSAL_proxy_clientid_renewer_thread(void *Arg)
{
  int rc;

  COMPOUND4args argnfs4;
  COMPOUND4res resnfs4;
  struct timeval timeout = TIMEOUTRPC;
  fsal_status_t fsal_status;
  proxyfsal_op_context_t fsal_context;
  proxyfsal_op_context_t *p_context = &fsal_context;
#define FSAL_RENEW_LEASE_NB_OP_ALLOC 1
  nfs_argop4 argoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];
  nfs_resop4 resoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];

  LogEvent(COMPONENT_FSAL, "FSAL_proxy_clientid_refresher_thread: starting...");

  sleep(6);    /** @todo: use getattr to have an actual value of server's lease duration */

  memset(&fsal_context, 0, sizeof(proxyfsal_op_context_t));
  fsal_status = PROXYFSAL_InitClientContext((fsal_op_context_t *)p_context);

  if(FSAL_IS_ERROR(fsal_status))
    {
      LogCrit(COMPONENT_FSAL,
           "FSAL_proxy_clientid_refresher_thread: FSAL error(%u,%u) during init... exiting",
           fsal_status.major, fsal_status.minor);
      exit(1);
    }

  /* Setup results structures */
  argnfs4.argarray.argarray_val = argoparray;
  resnfs4.resarray.resarray_val = resoparray;
  argnfs4.minorversion = 0;
  argnfs4.tag.utf8string_val = NULL;
  argnfs4.tag.utf8string_len = 0;
  argnfs4.argarray.argarray_len = 0;

  argnfs4.argarray.argarray_val[0].argop = NFS4_OP_RENEW;
  argnfs4.argarray.argarray_len = 1;

  while(1)
    {
      sleep(60);  /** @todo: use getattr to have an actual value of server's lease duration */

      /* Call the NFSv4 function */
      TakeTokenFSCall();

      argoparray[0].nfs_argop4_u.oprenew.clientid = fsal_clientid;
      COMPOUNDV4_EXECUTE(p_context, argnfs4, resnfs4, rc);
      if(rc != RPC_SUCCESS)
        {
          ReleaseTokenFSCall();

          LogCrit(COMPONENT_FSAL, "FSAL_PROXY: /!\\ RPC error when connecting to the server");

        }

      ReleaseTokenFSCall();

      if(resnfs4.status != NFS4_OK)
        LogCrit(COMPONENT_FSAL,
                "FSAL_PROXY: /!\\ NFSv4 error %u occured when trying to renew client id %16llx",
                resnfs4.status, (long long)argoparray[0].nfs_argop4_u.oprenew.clientid);

    }                           /* while( 1 ) */
}                               /* FSAL_proxy_clientid_renewer_thread */
Пример #2
0
/**
 * FSAL_proxy_clientid_renewer_thread: this thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *  This thread is made for refreshing the clientid used by the FSAL, automatically.
 *
 *
 * \return never returns... This is a infinite loop that will die when the daemon stops
 */
void *FSAL_proxy_clientid_renewer_thread(void *Arg)
{
  int rc;

  COMPOUND4args argnfs4;
  COMPOUND4res resnfs4;
  struct timeval timeout = TIMEOUTRPC;
  fsal_status_t fsal_status;
  proxyfsal_op_context_t fsal_context;
  proxyfsal_op_context_t *p_context = &fsal_context;
#define FSAL_RENEW_LEASE_NB_OP_ALLOC 1
  nfs_argop4 argoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];
  nfs_resop4 resoparray[FSAL_RENEW_LEASE_NB_OP_ALLOC];
#ifndef _NO_BUDDY_SYSTEM
  buddy_parameter_t buddy_param = default_buddy_parameter;
#endif

  LogEvent(COMPONENT_FSAL, "FSAL_proxy_clientid_refresher_thread: starting...");

  sleep(6);    /** @todo: use getattr to have an actual value of server's lease duration */

#ifndef _NO_BUDDY_SYSTEM
  if((rc = BuddyInit(&buddy_param)) != BUDDY_SUCCESS)
    {
      /* Failed init */
      LogCrit(COMPONENT_FSAL,
          "FSAL_proxy_clientid_renewer_thread: Memory manager could not be initialized, exiting...");
      exit(1);
    }
#endif

  memset((char *)&fsal_context, 0, sizeof(proxyfsal_op_context_t));
  fsal_status = PROXYFSAL_InitClientContext(p_context);

  if(FSAL_IS_ERROR(fsal_status))
    {
      LogCrit(COMPONENT_FSAL,
           "FSAL_proxy_clientid_refresher_thread: FSAL error(%u,%u) during init... exiting",
           fsal_status.major, fsal_status.minor);
      exit(1);
    }

  /* Setup results structures */
  argnfs4.argarray.argarray_val = argoparray;
  resnfs4.resarray.resarray_val = resoparray;
  argnfs4.minorversion = 0;
  argnfs4.tag.utf8string_val = NULL;
  argnfs4.tag.utf8string_len = 0;
  argnfs4.argarray.argarray_len = 0;

  argnfs4.argarray.argarray_val[0].argop = NFS4_OP_RENEW;
  argnfs4.argarray.argarray_val[0].nfs_argop4_u.oprenew.clientid = fsal_clientid;
  argnfs4.argarray.argarray_len = 1;

  while(1)
    {
      sleep(60);  /** @todo: use getattr to have an actual value of server's lease duration */

      /* Call the NFSv4 function */
      TakeTokenFSCall();

      COMPOUNDV4_EXECUTE(p_context, argnfs4, resnfs4, rc);
      if(rc != RPC_SUCCESS)
        {
          ReleaseTokenFSCall();

          LogCrit(COMPONENT_FSAL, "FSAL_PROXY: /!\\ RPC error when connecting to the server");

        }

      ReleaseTokenFSCall();

      if(resnfs4.status != NFS4_OK)
        LogCrit(COMPONENT_FSAL,
                "FSAL_PROXY: /!\\ NFSv4 error %u occured when trying to new clienitf %llu",
                resnfs4.status, (long long unsigned int)fsal_clientid);

    }                           /* while( 1 ) */
}                               /* FSAL_proxy_clientid_renewer_thread */