Exemplo n.º 1
0
/* This is the revision department.  */
static THREAD_RET_TYPE
revision_thread (void *arg)
{
  (void)arg;

  while (!stop_revision_thread)
    {
      external_lock_test_lock (__LINE__);
      check_accounts ();
      external_lock_test_unlock (__LINE__);
    }
  return THREAD_RET_VALUE;
}
Exemplo n.º 2
0
/* This is the revision department.  */
static THREAD_RET_TYPE
revision_thread (void *arg)
{
  gpg_err_code_t rc;
  int i = 0;

  (void)arg;

  while (!stop_revision_thread)
    {
      rc = gpgrt_lock_lock (&accounts_lock);
      if (rc)
        fail ("gpgrt_lock_lock failed at %d: %s", __LINE__, gpg_strerror (rc));

      check_accounts ();
      rc = gpgrt_lock_unlock (&accounts_lock);
      if (rc)
        fail ("gpgrt_lock_unlock failed at %d: %s", __LINE__,gpg_strerror (rc));
      if (!(++i%7))
        gpgrt_yield ();
    }
  return THREAD_RET_VALUE;
}
Exemplo n.º 3
0
int
main (int argc, char **argv)
{
  int last_argc = -1;
  int rc;

  if (argc)
    {
      argc--; argv++;
    }
  while (argc && last_argc != argc )
    {
      last_argc = argc;
      if (!strcmp (*argv, "--help"))
        {
          puts (
"usage: ./t-lock [options]\n"
"\n"
"Options:\n"
"  --verbose      Show what is going on\n"
"  --debug        Flyswatter\n"
);
          exit (0);
        }
      if (!strcmp (*argv, "--verbose"))
        {
          verbose = 1;
          argc--; argv++;
        }
      else if (!strcmp (*argv, "--debug"))
        {
          verbose = debug = 1;
          argc--; argv++;
        }
    }

  srand (time(NULL)*getpid());

  if (!gpg_error_check_version (GPG_ERROR_VERSION))
    {
      die ("gpg_error_check_version returned an error");
      errorcount++;
    }

  init_accounts ();
  check_accounts ();
  run_test ();
  check_accounts ();
  /* Run a second time to check deinit code.  */
  run_test ();
  check_accounts ();
  /* And a third time to test an explicit init.  */
  rc = gpgrt_lock_init (&accounts_lock);
  if (rc)
    fail ("gpgrt_lock_init failed at %d: %s", __LINE__, gpg_strerror (rc));
  run_test ();
  check_accounts ();
  if (verbose)
    print_accounts ();

  return errorcount ? 1 : 0;
}
Exemplo n.º 4
0
int
main (int argc, char **argv)
{
  int last_argc = -1;

  if (argc)
    {
      argc--; argv++;
    }
  while (argc && last_argc != argc )
    {
      last_argc = argc;
      if (!strcmp (*argv, "--help"))
        {
          puts (
"usage: ./t-lock [options]\n"
"\n"
"Options:\n"
"  --verbose      Show what is going on\n"
"  --debug        Flyswatter\n"
);
          exit (0);
        }
      if (!strcmp (*argv, "--verbose"))
        {
          verbose = 1;
          argc--; argv++;
        }
      else if (!strcmp (*argv, "--debug"))
        {
          verbose = debug = 1;
          argc--; argv++;
        }
    }

  srand (time(NULL)*getpid());

  if (debug)
    gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0);
  gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
  if (!gcry_check_version (GCRYPT_VERSION))
    die ("version mismatch");
  gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
  gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0);

  if (debug)
    gcry_control (GCRYCTL_PRINT_CONFIG, NULL);

  check_nonce_lock ();

  init_accounts ();
  check_accounts ();

  run_test ();
  check_accounts ();

  /* Run a second time to check deinit code.  */
  run_test ();
  check_accounts ();

  if (verbose)
    print_accounts ();

  return errorcount ? 1 : 0;
}