int
Stream_Order_Test::init (int argc, ACE_TCHAR *argv[])
{
  if (argc < 1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Stream_Order_Test needs at least 1 arg\n")),
                      -1);
  const ACE_Service_Type *st = 0;
  if (ACE_Service_Repository::instance ()->find (argv[0], &st, false) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Cannot find %s\n"), argv[0]), -1);
  const ACE_Service_Type_Impl *st_impl = st->type ();
  MT_Stream *str = reinterpret_cast<MT_Stream *>(st_impl->object ());
  MT_Module *m = 0;
  if (-1 == str->top (m))
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("Cannot get module %p\n"),
                       ACE_TEXT ("top")),
                      -1);
  // Walk down the stream and compare module names. Note we start from the
  // top, i.e., the last module pushed.
  bool error = false;
  for (int i = 1; i < argc; ++i)
    {
      if (m == 0)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("Ran out of modules at layer %d\n"),
                      i));
          continue;
        }
      if (ACE_OS::strcmp (argv[i], m->name ()) != 0)
        {
          ACE_ERROR ((LM_ERROR,
                      ACE_TEXT ("Layer %d: expected module %s, found %s\n"),
                      i,
                      argv[i], m->name ()));
          error = true;
        }
      else
        ACE_DEBUG ((LM_DEBUG,
                    ACE_TEXT ("Layer %d: found module %s, correct\n"),
                    i,
                    m->name ()));
      m = m->next ();
    }
  return error ? -1 : 0;
}
Exemple #2
0
int
ACE_Module_Type::init (int argc, ACE_TCHAR *argv[]) const
{
  ACE_TRACE ("ACE_Module_Type::init");
  void *obj = this->object ();
  MT_Module *mod = (MT_Module *) obj;
  //
  // Change the Module's name to what's in the svc.conf file.
  // We must do this so the names match up so everything shuts
  // down properly during the call to ACE_Stream_Type::fini
  // which calls MT_Stream::remove([name]) for all the modules.
  // If the calls to remove fail, we end up with a double delete
  // during shutdown. Bugzilla #3847
  //
  mod->name (this->name_);
  MT_Task *reader = mod->reader ();
  MT_Task *writer = mod->writer ();

  if (reader->init (argc, argv) == -1
      || writer->init (argc, argv) == -1)
    return -1;
  else
    return 0;
}