Beispiel #1
0
static int iterate_cb(const char *var, const char *value, void *data)
{
	static int nr;

	if (nr++)
		putchar('\n');

	printf("key=%s\n", var);
	printf("value=%s\n", value ? value : "(null)");
	printf("origin=%s\n", current_config_origin_type());
	printf("name=%s\n", current_config_name());
	printf("scope=%s\n", scope_name(current_config_scope()));

	return 0;
}
Beispiel #2
0
bool
Client::test_oneway_timeout (bool flood)
{
  bool status = true;

  ACE_Auto_Array_Ptr<char> tmp (new char [6000000]);
  char* msg = tmp.get();

  ACE_OS::memset (msg,'A',5999999);
  msg[5999999] = 0;

  test_obj_->dummy_two_way (); // connection establishment

  ACE_Time_Value tv (0);
  if (flood && !this->flood_connection(tv)) {
    ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> flooding failed.\n"));
  }

  // Timeout with SYNC_SCOPE SYNC_NONE
  try {
    std::string scope_name ("SYNC_NONE");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());
    test_obj_none_timeout_->dummy_one_way (msg);

    if (flood && flush_strategy_ == BLOCKING) {
      // block flushing gives a oneway SYNCH_WITH_TRANSPORT semantics
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: A Timeout was expected for SYNC_NONE.\n"));
    }
    else {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_NONE\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood && flush_strategy_ == BLOCKING) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected a timeout was received for SYNC_NONE.\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                  "timeout exception with synch scope SYNC_NONE.\n"));
      status = false;
    }
  }


  // Timeout with TAO specific SYNC_SCOPE SYNC_EAGER_BUFFERING
  try {
    std::string scope_name ("SYNC_EAGER_BUFFERING");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());

    /* BLOCKed flushing has SYNCH_WITH_TRANSPORT semantics. With flooding turned on
        you would have received a TIMEOUT in the previous test (SYNC_NONE). Even without
        flooding there is a chance to get back a TIMEOUT. The TIMEOUT has the side-effect
        closing out the connection. Therefore when flush_strategy is set to BLOCK we want
        to re-establish connection before each test. With flooding turned on we need
        to first unsleep the test server, re-establish connection and put it back to sleep.
        With flooding=0 we simple re-establish connection. This trick is performed at beginning
        of every test for flush_strategy == BLOCKING.
     */
    if (flush_strategy_ == BLOCKING) {
      if (flood) {
        management_->unsleep ();
        test_obj_->sleep (0, 0); // rebuild connection and put server thread to sleep
      }
      else {
        // else simply re-establish connection
        test_obj_->dummy_two_way ();
      }
    }

    test_obj_eager_timeout_->dummy_one_way (msg);

    if (flood && flush_strategy_ == BLOCKING) {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: A Timeout was expected for SYNC_EAGER_BUFFERING\n"));
    }
    else {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_EAGER_BUFFERING\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood && flush_strategy_ == BLOCKING) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected a timeout was received for SYNC_EAGER_BUFFERING\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                  "timeout exception with synch scope SYNC_EAGER_BUFFERING.\n"));
      status = false;
    }
  }

  // Timeout with TAO specific SYNC_SCOPE SYNC_DELAYED_BUFFERING
  try {
    std::string scope_name ("SYNC_DELAYED_BUFFERING");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());

    if (flush_strategy_ == BLOCKING) {
      if (flood) {
        management_->unsleep ();
        test_obj_->sleep (0, 0);
      }
      else {
        test_obj_->dummy_two_way ();
      }
    }

    test_obj_delayed_timeout_->dummy_one_way (msg);

    if (flood && flush_strategy_ == BLOCKING) {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: A Timeout was expected for SYNC_DELAYED_BUFFERING\n"));
    }
    else {
      test_obj_delayed_timeout_->dummy_one_way ("SYNC_DELAYED_BUFFERING");
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_DELAYED_BUFFERING\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood && flush_strategy_ == BLOCKING) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected timeout received for SYNC_DELAYED_BUFFERING\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                "timeout exception with synch scope SYNC_DELAYED_BUFFERING.\n"));
      status = false;
    }
  }

  /* Cleanup queue before the synchronous tests. We don't want the test
      results affected by leftovers from previous runs.
   */
  ACE_Time_Value tv_tmp (1);
  orb_->run (tv_tmp);

  // Timeout with SYNC_SCOPE SYNC_WITH_TRANSPORT
  try {
    std::string scope_name ("SYNC_WITH_TRANSPORT");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());

    if (flush_strategy_ == BLOCKING) {
      if (flood) {
        management_->unsleep ();
        test_obj_->sleep (0, 0);
      }
      else {
        test_obj_->dummy_two_way ();
      }
    }

    test_obj_transport_timeout_->dummy_one_way (msg);

    if (flood) {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
                  "timeout not received for synch scope SYNC_WITH_TRANSPORT.\n"
                  ));
      status = false;
    }
    else {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_WITH_TRANSPORT\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected Timeout received for SYNC_WITH_TRANSPORT\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                  "timeout exception with synch scope SYNC_WITH_TRANSPORT.\n"));
      status = false;
    }
  }

// Timeout with default SYNC_SCOPE SYNC_WITH_SERVER
  try {
    std::string scope_name ("SYNC_WITH_SERVER");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());

    if (flush_strategy_ == BLOCKING) {
      if (flood) {
        management_->unsleep ();
        test_obj_->sleep (0, 0);
      }
      else {
        test_obj_->dummy_two_way ();
      }
    }

    test_obj_server_timeout_->dummy_one_way (msg);

    if (flood) {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
                  "timeout not received for SYNC_SCOPE SYNC_WITH_SERVER.\n"));
      status = false;
    }
    else {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_WITH_SERVER\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected Timeout received for SYNC_WITH_SERVER\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                  "timeout exception with synch scope SYNC_WITH_SERVER.\n"));
      status = false;
    }
  }


  // Timeout with default SYNC_SCOPE (SYNC_WITH_TARGET)
  try {
    std::string scope_name ("SYNC_WITH_TARGET");
    ACE_OS::strncpy (msg, scope_name.c_str(), scope_name.length());

    if (flush_strategy_ == BLOCKING) {
      if (flood) {
        management_->unsleep ();
        test_obj_->sleep (0, 0);
      }
      else {
        test_obj_->dummy_two_way ();
      }
    }

    test_obj_target_timeout_->dummy_one_way (msg);

    if (flood) {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
                  "timeout not received for SYNC_SCOPE SYNC_WITH_TARGET.\n"));
      status = false;
    }
    else {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) As expected no Timeout received for SYNC_WITH_TARGET\n"));
    }
  }
  catch (const CORBA::TIMEOUT&) {
    if (flood) {
      ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected Timeout received for SYNC_WITH_TARGET\n"));
    }
    else {
      ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
                  "timeout exception with synch scope SYNC_WITH_TARGET.\n"));
      status = false;
    }
  }

  if (flood) {
    management_->unsleep ();
  }

  return status;
}