// Listing 5
// Listing 3 code/ch17
int handle_parent (char *cmdLine)
{
  ACE_TRACE (ACE_TEXT ("::handle_parent"));

  ALLOCATOR * shmem_allocator = 0;
  ACE_MMAP_Memory_Pool_Options options
    (ACE_DEFAULT_BASE_ADDR,
     ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED);

  ACE_NEW_RETURN
    (shmem_allocator,
     ALLOCATOR (BACKING_STORE, BACKING_STORE, &options),
     -1);

  MAP *map = smap (shmem_allocator);

  ACE_Process processa, processb;
  ACE_Process_Options poptions;
  poptions.command_line("%s a", cmdLine);
  {
    ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon,
                      coordMutex, -1);
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) Map has %d entries\n"),
                map->current_size ()));
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("In parent, map is located at %@\n"),
                map));

    // Then have the child show and eat them up.
    processa.spawn (poptions);

    // First append a few records.
    addRecords (map, shmem_allocator);
  }


  {
    ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon,
                      coordMutex, -1);

    // Add a few more records..
    addRecords (map, shmem_allocator);

    // Let's see what's left.
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) Parent finished adding, ")
                ACE_TEXT ("map has %d entries\n"),
                map->current_size ()));

    // Have another child try to eat them up.
    processb.spawn (poptions);
  }

  processa.wait ();
  processb.wait ();

  // No processes are left and we don't want to keep the data
  // around anymore; it's now safe to remove it.
  // !!This will remove the backing store.!!
  shmem_allocator->remove ();
  delete shmem_allocator;
  return 0;
}
Beispiel #2
0
void *
ACE_Function_Node::symbol (ACE_Service_Gestalt *,
                           int &yyerrno,
                           ACE_Service_Object_Exterminator *gobbler)
{
  typedef ACE_Service_Object *(*ACE_Service_Factory_Ptr)
    (ACE_Service_Object_Exterminator *);

  ACE_TRACE ("ACE_Function_Node::symbol");
  if (this->open_dll (yyerrno) == 0)
    {
      this->symbol_ = 0;

      // Locate the factory function <function_name> in the shared
      // object.
      ACE_TCHAR * const function_name =
        const_cast<ACE_TCHAR *> (this->function_name_);

      void * const func_p = this->dll_.symbol (function_name);
      if (func_p == 0)
        {
          ++yyerrno;

#ifndef ACE_NLOGGING
          if (ACE::debug ())
            {
              ACE_TCHAR * const errmsg = this->dll_.error ();
              ACELIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("DLL::symbol failed for function %s: ")
                          ACE_TEXT ("%s\n"),
                          function_name,
                          errmsg ? errmsg : ACE_TEXT ("no error reported")));
            }
#endif /* ACE_NLOGGING */

          return 0;
        }

#if defined (ACE_OPENVMS) && (!defined (__INITIAL_POINTER_SIZE) || (__INITIAL_POINTER_SIZE < 64))
      int const temp_p = reinterpret_cast<int> (func_p);
#else
      intptr_t const temp_p = reinterpret_cast<intptr_t> (func_p);
#endif

      ACE_Service_Factory_Ptr func =
        reinterpret_cast<ACE_Service_Factory_Ptr> (temp_p);

      // Invoke the factory function and record it's return value.
      this->symbol_ = (*func) (gobbler);

      if (this->symbol_ == 0)
        {
          ++yyerrno;
          if (ACE::debug ())
            {
              ACELIB_ERROR ((LM_ERROR,
                         ACE_TEXT ("%p\n"),
                         this->function_name_));
            }
          return 0;
        }
    }
  return this->symbol_;
}
Beispiel #3
0
void *
ACE_Static_Function_Node::symbol (ACE_Service_Gestalt *config,
                                  int &yyerrno,
                                  ACE_Service_Object_Exterminator *gobbler)
{
  ACE_TRACE ("ACE_Static_Function_Node::symbol");

  this->symbol_ = 0;

  // Locate the factory function <function_name> in the statically
  // linked svcs.

  ACE_Static_Svc_Descriptor *ssd = 0;
  if (config->find_static_svc_descriptor (this->function_name_, &ssd) == -1)
    {
      ++yyerrno;
      if (ACE::debug ())
        {
          ACELIB_ERROR ((LM_ERROR,
                     ACE_TEXT ("(%P|%t) No static service ")
                     ACE_TEXT ("registered for function %s\n"),
                     this->function_name_));
        }
      return 0;
    }

  if (ssd->alloc_ == 0)
    {
      ++yyerrno;

      if (this->symbol_ == 0)
        {
          ++yyerrno;

          if (ACE::debug ())
            {
              ACELIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("(%P|%t) No static service factory ")
                          ACE_TEXT ("function registered for function %s\n"),
                          this->function_name_));
            }
          return 0;
        }
    }

  // Invoke the factory function and record it's return value.
  this->symbol_ = (*ssd->alloc_) (gobbler);

  if (this->symbol_ == 0)
    {
      ++yyerrno;
      if (ACE::debug ())
        {
          ACELIB_ERROR ((LM_ERROR,
                      ACE_TEXT ("%p\n"),
                      this->function_name_));
        }
      return 0;
    }

  return this->symbol_;
}
Beispiel #4
0
const ACE_TCHAR *
ACE_Location_Node::pathname (void) const
{
  ACE_TRACE ("ACE_Location_Node::pathname");
  return this->pathname_;
}
Beispiel #5
0
int
ACE_Location_Node::dispose (void) const
{
  ACE_TRACE ("ACE_Location_Node::dispose");
  return this->must_delete_;
}
Beispiel #6
0
void
ACE_Stream_Node::apply (ACE_Service_Gestalt *config, int &yyerrno)
{
  ACE_TRACE ("ACE_Stream_Node::apply");

  const ACE_Service_Type *sst = this->node_->record (config);
  if (sst == 0)
    const_cast<ACE_Static_Node *> (this->node_)->apply (config, yyerrno);

  if (yyerrno != 0) return;

  sst = this->node_->record (config);
  ACE_Stream_Type *st =
      dynamic_cast<ACE_Stream_Type *> (const_cast<ACE_Service_Type_Impl *> (sst->type ()));

  // The modules were linked as popped off the yacc stack, so they're in
  // reverse order from the way they should be pushed onto the stream.
  // So traverse mods_ and and reverse the list, then iterate over it to push
  // the modules in the stream in the correct order.
#if defined (ACE_HAS_ALLOC_HOOKS)
  typedef std::list<const ACE_Static_Node *,
                    ACE_Allocator_Std_Adapter<const ACE_Static_Node *> > list_t;
#else
  typedef std::list<const ACE_Static_Node *> list_t;
#endif /* ACE_HAS_ALLOC_HOOKS */
  list_t mod_list;
  const ACE_Static_Node *module;
  for (module = dynamic_cast<const ACE_Static_Node*> (this->mods_);
       module != 0;
       module = dynamic_cast<ACE_Static_Node*> (module->link()))
    mod_list.push_front (module);

  list_t::const_iterator iter;
  for (iter = mod_list.begin (); iter != mod_list.end (); ++iter)
    {
      module = *iter;
      ACE_ARGV args (module->parameters ());

      const ACE_Service_Type *mst = module->record (config);
      if (mst == 0)
        const_cast<ACE_Static_Node *> (module)->apply (config, yyerrno);

      if (yyerrno != 0)
        {
          if (ACE::debug ())
            {
              ACELIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("dynamic initialization failed for Module %s\n"),
                          module->name ()));
            }
          ++yyerrno;
          continue;     // Don't try anything else with this one
        }

      ACE_Module_Type const * const mt1 =
        static_cast <ACE_Module_Type const *> (module->record (config)->type());

      ACE_Module_Type *mt = const_cast<ACE_Module_Type *>(mt1);

      if (st->push (mt) == -1)
        {
          if (ACE::debug ())
            {
              ACELIB_ERROR ((LM_ERROR,
                          ACE_TEXT ("dynamic initialization failed for Stream %s\n"),
                          this->node_->name ()));
            }
          ++yyerrno;
        }

    }

#ifndef ACE_NLOGGING
  if (ACE::debug ())
    ACELIB_DEBUG ((LM_DEBUG,
                ACE_TEXT ("(%P|%t) Did stream on %s, error = %d\n"),
                this->node_->name (),
                yyerrno));
#endif /* ACE_NLOGGING */
}
Beispiel #7
0
ACE_TCHAR *
ACE_Static_Node::parameters (void) const
{
  ACE_TRACE ("ACE_Static_Node::parameters");
  return this->parameters_;
}
Beispiel #8
0
// Constructor.
ACE_GQoS_Session::ACE_GQoS_Session (void)
{
  ACE_TRACE ("ACE_GQoS_Session::ACE_GQoS_Session");
}
Beispiel #9
0
 virtual int process (Message *message)
 {
     ACE_TRACE (ACE_TEXT ("ReleaseDevice::process()"));
     message->recorder ()->release ();
     return 0;
 }
Beispiel #10
0
int
ACE_System_Time::sync_local_system_time (ACE_System_Time::Sync_Mode)
{
  ACE_TRACE ("ACE_System_Time::sync_local_system_time");
  ACE_NOTSUP_RETURN (-1);
}
Beispiel #11
0
ACE_System_Time::~ACE_System_Time (void)
{
  ACE_TRACE ("ACE_System_Time::~ACE_System_Time");
  delete this->shmem_;
}
Beispiel #12
0
/* VIRTUAL */ int
ACE_Token_Handler::recv_request (void)
{
  ACE_TRACE ("ACE_Token_Handler::recv_request");
  ssize_t n;

  // Read the first 4 bytes to get the length of the message
  // This implementation assumes that the first 4 bytes are
  // the length of the message.
  n = this->peer ().recv ((void *) &this->token_request_,
                          sizeof (ACE_UINT32));

  switch (n)
    {
    case -1:
      /* FALLTHROUGH */
    default:
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p got %d bytes, expected %d bytes\n"),
                  ACE_TEXT ("recv failed"), n, sizeof (ACE_UINT32)));
      /* FALLTHROUGH */
    case 0:
      // We've shutdown unexpectedly, let's abandon the connection.
      this->abandon (0);
      return -1;
      /* NOTREACHED */
    case sizeof (ACE_UINT32):
      {
        // Transform the length into host byte order.
        ssize_t length = this->token_request_.length ();

        // Do a sanity check on the length of the message.
        if (length > (ssize_t) sizeof this->token_request_)
          {
            ACE_ERROR ((LM_ERROR, ACE_TEXT ("length %d too long\n"), length));
            return this->abandon (1);
          }

        // Receive the rest of the request message.
        // @@ beware of blocking read!!!.
        n = this->peer ().recv ((void *) (((char *) &this->token_request_)
                                          + sizeof (ACE_UINT32)),
                                length - sizeof (ACE_UINT32));

        // Subtract off the size of the part we skipped over...
        if (n != (length - (ssize_t) sizeof (ACE_UINT32)))
          {
            ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p expected %d, got %d\n"),
                        ACE_TEXT ("invalid length"), length, n));
            return this->abandon (1);
          }

        // Decode the request into host byte order.
        if (this->token_request_.decode () == -1)
          {
            ACE_ERROR
              ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("decode failed")));
            return this->abandon (1);
          }

        // if (OS::debug)
        this->token_request_.dump ();
      }
    }
  return 0;
}
ACE_Framework_Repository::~ACE_Framework_Repository (void)
{
    ACE_TRACE ("ACE_Framework_Repository::~ACE_Framework_Repository");
    this->close ();
}
Beispiel #14
0
void foo (void)
{
  ACE_TRACE ("foo");

  ACE_DEBUG ((LM_INFO, ACE_TEXT ("%IHowdy Pardner\n")));
}
Beispiel #15
0
ACE_Suspend_Node::ACE_Suspend_Node (const ACE_TCHAR *name)
  : ACE_Parse_Node (name)
{
  ACE_TRACE ("ACE_Suspend_Node::ACE_Suspend_Node");
}
void *
ACE_MEM_Addr::get_addr (void) const
{
  ACE_TRACE ("ACE_MEM_Addr::get_addr");
  return this->external_.get_addr ();
}
Beispiel #17
0
ACE_Remove_Node::ACE_Remove_Node (const ACE_TCHAR *name)
  : ACE_Parse_Node (name)
{
  ACE_TRACE ("ACE_Remove_Node::ACE_Remove_Node");
}
const char *
ACE_MEM_Addr::get_host_name (void) const
{
  ACE_TRACE ("ACE_MEM_Addr::get_host_name");
  return this->external_.get_host_name ();
}
Beispiel #19
0
ACE_Dynamic_Node::~ACE_Dynamic_Node (void)
{
  ACE_TRACE ("ACE_Dynamic_Node::~ACE_Dynamic_Node");
}
ACE_MEM_Addr::ACE_MEM_Addr (u_short port_number)
  : ACE_Addr (AF_INET, sizeof (ACE_MEM_Addr))
{
  ACE_TRACE ("ACE_MEM_Addr::ACE_MEM_Addr");
  this->initialize_local (port_number);
}
Beispiel #21
0
ACE_Location_Node::~ACE_Location_Node (void)
{
  ACE_TRACE ("ACE_Location_Node::~ACE_Location_Node");
}
Beispiel #22
0
const ACE_TCHAR *
ACE_Parse_Node::name (void) const
{
  ACE_TRACE ("ACE_Parse_Node::name");
  return this->name_;
}
Beispiel #23
0
void
ACE_Location_Node::pathname (const ACE_TCHAR *p)
{
  ACE_TRACE ("ACE_Location_Node::pathname");
  this->pathname_ = p;
}
Beispiel #24
0
ACE_Parse_Node *
ACE_Parse_Node::link (void) const
{
  ACE_TRACE ("ACE_Parse_Node::link");
  return this->next_;
}
Beispiel #25
0
void
ACE_Location_Node::set_symbol (void *s)
{
  ACE_TRACE ("ACE_Location_Node::set_symbol");
  this->symbol_ = s;
}
Beispiel #26
0
ACE_Parse_Node::ACE_Parse_Node (void)
  : name_ (0),
    next_ (0)
{
  ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
}
Beispiel #27
0
ACE_Static_Function_Node::ACE_Static_Function_Node (const ACE_TCHAR *func_name)
  : function_name_ (ACE::strnew (func_name))
{
  ACE_TRACE ("ACE_Static_Function_Node::ACE_Static_Function_Node");
  this->must_delete_ = 1;
}
Beispiel #28
0
ACE_Parse_Node::ACE_Parse_Node (const ACE_TCHAR *nm)
  : name_ (ACE::strnew (nm)),
    next_ (0)
{
  ACE_TRACE ("ACE_Parse_Node::ACE_Parse_Node");
}
Beispiel #29
0
ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor (void)
{
  ACE_TRACE ("ACE_LSOCK_Acceptor::ACE_LSOCK_Acceptor");
}
void *
ACE_Shared_Memory_Pool::base_addr (void) const
{
    ACE_TRACE ("ACE_Shared_Memory_Pool::base_addr");
    return this->base_addr_;
}