diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-01-04 18:14:58 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-01-04 18:14:58 +0000 |
commit | b8f8e47bffeb5d188942075775298fe51428c89b (patch) | |
tree | 6e42e33b5024548034b10871b9a5065ad8a1d492 /apps/Gateway | |
parent | 00842ed4a148e1cd6f116671f397417b69642a75 (diff) | |
download | ATCD-b8f8e47bffeb5d188942075775298fe51428c89b.tar.gz |
*** empty log message ***
Diffstat (limited to 'apps/Gateway')
-rw-r--r-- | apps/Gateway/Gateway/Concrete_Connection_Handlers.cpp | 46 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Connection_Handler.cpp | 20 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Connection_Handler.h | 32 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Connection_Handler_Acceptor.h | 4 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Connection_Handler_Connector.cpp | 6 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Event_Channel.cpp | 70 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Event_Channel.h | 13 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp | 1 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Event_Forwarding_Discriminator.h | 4 | ||||
-rw-r--r-- | apps/Gateway/Gateway/File_Parser.h | 12 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Gateway.cpp | 43 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Gateway.h | 4 | ||||
-rw-r--r-- | apps/Gateway/Gateway/Options.h | 2 | ||||
-rw-r--r-- | apps/Gateway/Peer/Options.h | 2 |
14 files changed, 150 insertions, 109 deletions
diff --git a/apps/Gateway/Gateway/Concrete_Connection_Handlers.cpp b/apps/Gateway/Gateway/Concrete_Connection_Handlers.cpp index f60a8068db4..6e8d227501b 100644 --- a/apps/Gateway/Gateway/Concrete_Connection_Handlers.cpp +++ b/apps/Gateway/Gateway/Concrete_Connection_Handlers.cpp @@ -12,8 +12,8 @@ Consumer_Handler::Consumer_Handler (const Connection_Config_Info &pci) } // This method should be called only when the Consumer shuts down -// unexpectedly. This method simply marks the Connection_Handler as having -// failed so that handle_close () can reconnect. +// unexpectedly. This method simply marks the Connection_Handler as +// having failed so that handle_close () can reconnect. int Consumer_Handler::handle_input (ACE_HANDLE) @@ -27,17 +27,20 @@ Consumer_Handler::handle_input (ACE_HANDLE) case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%t) Peer has failed unexpectedly for Consumer_Handler %d\n", - this->id ()), -1); + this->id ()), + -1); /* NOTREACHED */ case 0: ACE_ERROR_RETURN ((LM_ERROR, "(%t) Peer has shutdown unexpectedly for Consumer_Handler %d\n", - this->id ()), -1); + this->id ()), + -1); /* NOTREACHED */ default: ACE_ERROR_RETURN ((LM_ERROR, "(%t) Consumer is erroneously sending input to Consumer_Handler %d\n", - this->id ()), -1); + this->id ()), + -1); /* NOTREACHED */ } } @@ -102,7 +105,7 @@ Consumer_Handler::send (ACE_Message_Block *event) else // if (n == length) { // The whole event is sent, we now decrement the reference count - // (which deletes itself with it reaches 0. + // (which deletes itself with it reaches 0). event->release (); errno = 0; } @@ -121,6 +124,7 @@ Consumer_Handler::handle_output (ACE_HANDLE) ACE_DEBUG ((LM_DEBUG, "(%t) in handle_output on handle %d\n", this->get_handle ())); + // The list had better not be empty, otherwise there's a bug! if (this->msg_queue ()->dequeue_head @@ -368,8 +372,9 @@ Supplier_Handler::handle_input (ACE_HANDLE) switch (this->recv (forward_addr)) { case 0: - // Note that a peer should never initiate a shutdown by closing - // the connection. Instead, it should reconnect. + // Note that a peer shouldn't initiate a shutdown by closing the + // connection. Therefore, the peer must have crashed, so we'll + // need to bail out here and let the higher layers reconnect. this->state (Connection_Handler::FAILED); ACE_ERROR_RETURN ((LM_ERROR, "(%t) Peer has closed down unexpectedly for Input Connection_Handler %d\n", @@ -388,6 +393,7 @@ Supplier_Handler::handle_input (ACE_HANDLE) } /* NOTREACHED */ default: + // Route messages to Consumers. return this->forward (forward_addr); } } @@ -401,7 +407,6 @@ Supplier_Handler::forward (ACE_Message_Block *forward_addr) return this->event_channel_->put (forward_addr); } -#if defined (ACE_HAS_THREADS) Thr_Consumer_Handler::Thr_Consumer_Handler (const Connection_Config_Info &pci) : Consumer_Handler (pci) { @@ -471,13 +476,14 @@ Thr_Consumer_Handler::open (void *) int Thr_Consumer_Handler::put (ACE_Message_Block *mb, ACE_Time_Value *) { - // Perform non-blocking enqueue. + // Perform non-blocking enqueue, i.e., if <msg_queue> is full + // *don't* block! return this->msg_queue ()->enqueue_tail (mb, (ACE_Time_Value *) &ACE_Time_Value::zero); } -// Transmit events to the peer (note simplification resulting from -// threads...) +// Transmit events to the peer. Note the simplification resulting +// from the use of threads, compared with the Reactive solution. int Thr_Consumer_Handler::svc (void) @@ -487,7 +493,7 @@ Thr_Consumer_Handler::svc (void) { ACE_DEBUG ((LM_DEBUG, "(%t) Thr_Consumer_Handler's handle = %d\n", - this->peer ().get_handle ())); + this->peer ().get_handle ())); // Since this method runs in its own thread it is OK to block on // output. @@ -496,16 +502,20 @@ Thr_Consumer_Handler::svc (void) this->msg_queue ()->dequeue_head (mb) != -1; ) if (this->send (mb) == -1) - ACE_ERROR ((LM_ERROR, "(%t) %p\n", "send failed")); + ACE_ERROR ((LM_ERROR, + "(%t) %p\n", + "send failed")); ACE_ASSERT (errno == ESHUTDOWN); ACE_DEBUG ((LM_DEBUG, "(%t) shutting down threaded Consumer_Handler %d on handle %d\n", - this->id (), this->get_handle ())); + this->id (), + this->get_handle ())); this->peer ().close (); + // Re-establish the connection, using expoential backoff. for (this->timeout (1); // Default is to reconnect synchronously. this->event_channel_->initiate_connection_connection (this) == -1; ) @@ -571,7 +581,8 @@ Thr_Supplier_Handler::svc (void) // Since this method runs in its own thread and processes events // for one connection it is OK to call down to the - // <Supplier_Handler::handle_input> method, which blocks on input. + // <Supplier_Handler::handle_input> method, which blocks on + // input. while (this->Supplier_Handler::handle_input () != -1) continue; @@ -586,6 +597,7 @@ Thr_Supplier_Handler::svc (void) // Deactivate the queue while we try to get reconnected. this->msg_queue ()->deactivate (); + // Re-establish the connection, using expoential backoff. for (this->timeout (1); // Default is to reconnect synchronously. this->event_channel_->initiate_connection_connection (this) == -1; ) @@ -599,5 +611,3 @@ Thr_Supplier_Handler::svc (void) } ACE_NOTREACHED(return 0); } - -#endif /* ACE_HAS_THREADS */ diff --git a/apps/Gateway/Gateway/Connection_Handler.cpp b/apps/Gateway/Gateway/Connection_Handler.cpp index 3b9e8909dbc..f9e044fcd4f 100644 --- a/apps/Gateway/Gateway/Connection_Handler.cpp +++ b/apps/Gateway/Gateway/Connection_Handler.cpp @@ -11,9 +11,9 @@ Connection_Handler::id (ACE_INT32 id) } ACE_INT32 -Connection_Handler::id (void) +Connection_Handler::connection_id (void) { - return this->id_; + return this->connection_id_; } // The total number of bytes sent/received on this Proxy. @@ -111,11 +111,12 @@ Connection_Handler::max_timeout (void) int Connection_Handler::handle_timeout (const ACE_Time_Value &, - const void *) + const void *) { ACE_DEBUG ((LM_DEBUG, "(%t) attempting to reconnect Connection_Handler %d with timeout = %d\n", - this->id (), this->timeout_)); + this->connection_id (), + this->timeout_)); // Delegate the re-connection attempt to the Event Channel. this->event_channel_->initiate_connection_connection (this); @@ -131,7 +132,8 @@ Connection_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) ACE_DEBUG ((LM_DEBUG, "(%t) shutting down %s Connection_Handler %d on handle %d\n", this->connection_role () == 'C' ? "Consumer" : "Supplier", - this->id (), this->get_handle ())); + this->connection_id (), + this->get_handle ())); // Restart the connection, if possible. return this->event_channel_->reinitiate_connection_connection (this); @@ -179,13 +181,13 @@ Connection_Handler::state (void) return this->state_; } -ACE_INET_Addr & +const ACE_INET_Addr & Connection_Handler::remote_addr (void) { return this->remote_addr_; } -ACE_INET_Addr & +const ACE_INET_Addr & Connection_Handler::local_addr (void) { return this->local_addr_; @@ -205,7 +207,6 @@ Connection_Handler_Factory::make_connection_handler (const Connection_Config_Inf if (pci.connection_role_ == 'C') // Configure a Consumer_Handler. { -#if defined (ACE_HAS_THREADS) // Create a threaded Consumer_Handler. if (ACE_BIT_ENABLED (Options::instance ()->threading_strategy (), Options::OUTPUT_MT)) @@ -215,14 +216,12 @@ Connection_Handler_Factory::make_connection_handler (const Connection_Config_Inf // Create a reactive Consumer_Handler. else -#endif /* ACE_HAS_THREADS */ ACE_NEW_RETURN (connection_handler, Consumer_Handler (pci), 0); } else // connection_role == 'S', so configure a Supplier_Handler. { -#if defined (ACE_HAS_THREADS) // Create a threaded Supplier_Handler. if (ACE_BIT_ENABLED (Options::instance ()->threading_strategy (), Options::INPUT_MT)) @@ -232,7 +231,6 @@ Connection_Handler_Factory::make_connection_handler (const Connection_Config_Inf // Create a reactive Supplier_Handler. else -#endif /* ACE_HAS_THREAD */ ACE_NEW_RETURN (connection_handler, Supplier_Handler (pci), 0); diff --git a/apps/Gateway/Gateway/Connection_Handler.h b/apps/Gateway/Gateway/Connection_Handler.h index 665c1635a97..ea21af476b8 100644 --- a/apps/Gateway/Gateway/Connection_Handler.h +++ b/apps/Gateway/Gateway/Connection_Handler.h @@ -30,11 +30,11 @@ class Event_Channel; class Connection_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH> { // = TITLE - // Connection_Handler contains info about connection state and - // addressing. + // <Connection_Handler> contains info about connection state and + // addressing. // // = DESCRIPTION - // The Connection_Handler classes process events sent to the + // The <Connection_Handler> classes process events sent to the // Event Channel from Suppliers and forward them to Consumers. public: Connection_Handler (void); @@ -44,18 +44,18 @@ public: // Real constructor. virtual int open (void * = 0); - // Initialize and activate a single-threaded Connection_Handler (called by - // ACE_Connector::handle_output()). + // Initialize and activate a single-threaded <Connection_Handler> + // (called by <ACE_Connector::handle_output>). - ACE_INET_Addr &remote_addr (void); + const ACE_INET_Addr &remote_addr (void); // Returns the peer's routing address. - ACE_INET_Addr &local_addr (void); + const ACE_INET_Addr &local_addr (void); // Returns our local address. - // = Set/get routing id. - ACE_INT32 id (void); - void id (ACE_INT32); + // = Set/get connection id. + CONNECTION_ID connection_id (void); + void connection_id (CONNECTION_ID); // = The current state of the Connection_Handler. enum State @@ -97,19 +97,14 @@ public: // Perform Connection_Handler termination. protected: - enum - { - MAX_RETRY_TIMEOUT = 300 // 5 minutes is the maximum timeout. - }; - ACE_INET_Addr remote_addr_; // Address of peer. ACE_INET_Addr local_addr_; // Address of us. - ACE_INT32 id_; - // The assigned routing ID of this entry. + CONNECTION_ID connection_id_; + // The assigned connection ID of this entry. size_t total_bytes_; // The total number of bytes sent/received on this proxy. @@ -143,7 +138,8 @@ class Connection_Handler_Factory // <Thr_Supplier_Handler>). public: Connection_Handler *make_connection_handler (const Connection_Config_Info &); - // Make the appropriate type of <Connection_Handler>. + // Make the appropriate type of <Connection_Handler>, based on the + // <Connection_Config_Info> parameter. }; #endif /* _CONNECTION_HANDLER */ diff --git a/apps/Gateway/Gateway/Connection_Handler_Acceptor.h b/apps/Gateway/Gateway/Connection_Handler_Acceptor.h index fc54a363595..31ca2f99c0c 100644 --- a/apps/Gateway/Gateway/Connection_Handler_Acceptor.h +++ b/apps/Gateway/Gateway/Connection_Handler_Acceptor.h @@ -34,8 +34,8 @@ public: Connection_Handler_Acceptor (Event_Channel &, char connection_role); - virtual int make_svc_handler (Connection_Handler *&ph); - // Hook method for creating an appropriate <Connection_Handler>. + virtual int make_svc_handler (Connection_Handler *&ph); + // Hook method for creating an appropriate <Connection_Handler>. protected: Event_Channel &event_channel_; diff --git a/apps/Gateway/Gateway/Connection_Handler_Connector.cpp b/apps/Gateway/Gateway/Connection_Handler_Connector.cpp index 56ac92d9c2f..6e82fa7618d 100644 --- a/apps/Gateway/Gateway/Connection_Handler_Connector.cpp +++ b/apps/Gateway/Gateway/Connection_Handler_Connector.cpp @@ -26,8 +26,10 @@ Connection_Handler_Connector::initiate_connection (Connection_Handler *connectio // Try to connect to the Peer. - if (this->connect (connection_handler, connection_handler->remote_addr (), - synch_options, connection_handler->local_addr ()) == -1) + if (this->connect (connection_handler, + connection_handler->remote_addr (), + synch_options, + connection_handler->local_addr ()) == -1) { if (errno != EWOULDBLOCK) { diff --git a/apps/Gateway/Gateway/Event_Channel.cpp b/apps/Gateway/Gateway/Event_Channel.cpp index c430324b42e..3af0135010d 100644 --- a/apps/Gateway/Gateway/Event_Channel.cpp +++ b/apps/Gateway/Gateway/Event_Channel.cpp @@ -21,8 +21,8 @@ Event_Channel::compute_performance_statistics (void) ACE_DEBUG ((LM_DEBUG, "(%t) doing the performance timeout here...\n")); CONNECTION_MAP_ITERATOR cmi (this->connection_map_); - // If we've got a ACE_Thread Manager then use it to suspend all the - // threads. This will enable us to get an accurate count. + // If we've got a <ACE_Thread_Manager> then use it to suspend all + // the threads. This will enable us to get an accurate count. if (Options::instance ()->threading_strategy () != Options::REACTIVE) @@ -50,7 +50,8 @@ Event_Channel::compute_performance_statistics (void) total_bytes_in += connection_handler->total_bytes (); } - ACE_DEBUG ((LM_DEBUG, "(%t) after %d seconds, \ntotal_bytes_in = %d\ntotal_bytes_out = %d\n", + ACE_DEBUG ((LM_DEBUG, + "(%t) after %d seconds, \ntotal_bytes_in = %d\ntotal_bytes_out = %d\n", Options::instance ()->performance_window (), total_bytes_in, total_bytes_out)); @@ -82,6 +83,7 @@ int Event_Channel::handle_timeout (const ACE_Time_Value &, const void *) { + // This is called periodically to compute performance statistics. return this->compute_performance_statistics (); } @@ -90,11 +92,11 @@ Event_Channel::handle_timeout (const ACE_Time_Value &, int Event_Channel::put (ACE_Message_Block *event, - ACE_Time_Value *) + ACE_Time_Value *) { // We got a valid event, so determine its virtual forwarding // address, which is stored in the first of the two event blocks, - // which are chained together by this->recv(). + // which are chained together by <ACE::recv>. Event_Key *forwarding_addr = (Event_Key *) event->rd_ptr (); @@ -125,7 +127,7 @@ Event_Channel::put (ACE_Message_Block *event, // At this point, we should assign a thread-safe locking // strategy to the Message_Block is we're running in a // multi-threaded configuration. - // data->locking_strategy (MB_Locking_Strategy::instance ()); + data->locking_strategy (MB_Locking_Strategy::instance ()); for (Connection_Handler **connection_handler = 0; dsi.next (connection_handler) != 0; @@ -226,10 +228,8 @@ Event_Channel::reinitiate_connection_connection (Connection_Handler *connection_ { // Skip over proxies with deactivated handles. if (connection_handler->get_handle () != ACE_INVALID_HANDLE) - { - // Make sure to close down peer to reclaim descriptor. - connection_handler->peer ().close (); - } + // Make sure to close down peer to reclaim descriptor. + connection_handler->peer ().close (); if (connection_handler->state () != Connection_Handler::DISCONNECTING) { @@ -251,7 +251,8 @@ Event_Channel::reinitiate_connection_connection (Connection_Handler *connection_ void Event_Channel::initiate_connector (void) { - if (Options::instance ()->enabled (Options::CONSUMER_CONNECTOR | Options::SUPPLIER_CONNECTOR)) + if (Options::instance ()->enabled + (Options::CONSUMER_CONNECTOR | Options::SUPPLIER_CONNECTOR)) { CONNECTION_MAP_ITERATOR cmi (this->connection_map_); @@ -273,7 +274,7 @@ Event_Channel::initiate_connector (void) // Initiate passive acceptor to wait for Consumer and Supplier Peers // to accept. -void +int Event_Channel::initiate_acceptors (void) { if (Options::instance ()->enabled (Options::CONSUMER_ACCEPTOR) @@ -281,16 +282,20 @@ Event_Channel::initiate_acceptors (void) (Options::instance ()->consumer_acceptor_port (), ACE_Reactor::instance (), Options::instance ()->blocking_semantics ()) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", - "cannot register acceptor")); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + "cannot register acceptor"), + -1); if (Options::instance ()->enabled (Options::SUPPLIER_CONNECTOR) && this->supplier_acceptor_.open (Options::instance ()->supplier_acceptor_port (), ACE_Reactor::instance (), Options::instance ()->blocking_semantics ()) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", - "cannot register acceptor")); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", + "cannot register acceptor"), + -1); + + return 0; } // This method gracefully shuts down all the Handlers in the @@ -359,25 +364,29 @@ int Event_Channel::find_proxy (ACE_INT32 connection_id, Connection_Handler *&connection_handler) { - return this->connection_map_.find (connection_id, connection_handler); + return this->connection_map_.find (connection_id, + connection_handler); } int Event_Channel::bind_proxy (Connection_Handler *connection_handler) { - int result = this->connection_map_.bind (connection_handler->id (), connection_handler); + int result = this->connection_map_.bind (connection_handler->id (), + connection_handler); switch (result) { case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%t) bind failed for connection %d\n", - connection_handler->id ()), -1); + connection_handler->id ()), + -1); /* NOTREACHED */ case 1: // Oops, found a duplicate! ACE_ERROR_RETURN ((LM_ERROR, "(%t) duplicate connection %d, already bound\n", - connection_handler->id ()), -1); + connection_handler->id ()), + -1); /* NOTREACHED */ case 0: // Success. @@ -385,7 +394,9 @@ Event_Channel::bind_proxy (Connection_Handler *connection_handler) /* NOTREACHED */ default: ACE_ERROR_RETURN ((LM_DEBUG, - "(%t) invalid result %d\n", result), -1); + "(%t) invalid result %d\n", + result), + -1); /* NOTREACHED */ } @@ -404,19 +415,24 @@ Event_Channel::subscribe (const Event_Key &event_addr, case -1: ACE_ERROR_RETURN ((LM_ERROR, "(%t) bind failed for connection %d\n", - event_addr.connection_id_), -1); + event_addr.connection_id_), + -1); /* NOTREACHED */ case 1: // Oops, found a duplicate! ACE_ERROR_RETURN ((LM_DEBUG, "(%t) duplicate consumer map entry %d, " - "already bound\n", event_addr.connection_id_), -1); + "already bound\n", + event_addr.connection_id_), + -1); /* NOTREACHED */ case 0: // Success. return 0; default: ACE_ERROR_RETURN ((LM_DEBUG, - "(%t) invalid result %d\n", result), -1); + "(%t) invalid result %d\n", + result), + -1); /* NOTREACHED */ } @@ -426,7 +442,7 @@ Event_Channel::subscribe (const Event_Key &event_addr, int Event_Channel::open (void *) { - // Ignore SIPPIPE so each Consumer_Handler can handle it. + // Ignore <SIGPIPE> so each <Consumer_Handler> can handle it. ACE_Sig_Action sig (ACE_SignalHandler (SIG_IGN), SIGPIPE); ACE_UNUSED_ARG (sig); @@ -434,7 +450,8 @@ Event_Channel::open (void *) this->initiate_connector (); // Passively initiate Peer acceptor. - this->initiate_acceptors (); + if (this->initiate_acceptors () == -1) + return -1; // If we're not running reactively, then we need to make sure that // <ACE_Message_Block> reference counting operations are @@ -451,6 +468,7 @@ Event_Channel::open (void *) Options::instance ()->locking_strategy (la); } + return 0; } diff --git a/apps/Gateway/Gateway/Event_Channel.h b/apps/Gateway/Gateway/Event_Channel.h index 4735c7b9d44..6f3a09f63c9 100644 --- a/apps/Gateway/Gateway/Event_Channel.h +++ b/apps/Gateway/Gateway/Event_Channel.h @@ -30,6 +30,9 @@ class ACE_Svc_Export Event_Channel : public ACE_Event_Handler // Define a generic Event_Channel. // // = DESCRIPTION + // The inspiration for this class is derived from the CORBA COS + // Event Channel, though the design is simplified. + // // We inherit from <ACE_Event_Handler> so that we can be // registered with an <ACE_Reactor> to handle timeouts. public: @@ -103,18 +106,18 @@ private: // Used to establish connections passively and create Consumers. // = Make life easier by defining typedefs. - typedef ACE_Map_Manager<ACE_INT32, Connection_Handler *, MAP_MUTEX> + typedef ACE_Map_Manager<CONNECTION_ID, Connection_Handler *, MAP_MUTEX> CONNECTION_MAP; - typedef ACE_Map_Iterator<ACE_INT32, Connection_Handler *, MAP_MUTEX> + typedef ACE_Map_Iterator<CONNECTION_ID, Connection_Handler *, MAP_MUTEX> CONNECTION_MAP_ITERATOR; - typedef ACE_Map_Entry<ACE_INT32, Connection_Handler *> + typedef ACE_Map_Entry<CONNECTION_ID, Connection_Handler *> CONNECTION_MAP_ENTRY; CONNECTION_MAP connection_map_; - // Table that maps Connection IDs to Connection_Handler *'s. + // Table that maps <CONNECTION_ID>s to <Connection_Handler> *'s. Event_Forwarding_Discriminator efd_; - // Map that associates an event to a set of Consumer_Handler *'s. + // Map that associates an event to a set of <Consumer_Handler> *'s. }; #endif /* ACE_EVENT_CHANNEL */ diff --git a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp index 4dfbb658c1f..8bda0e85a4d 100644 --- a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp +++ b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.cpp @@ -42,6 +42,7 @@ int Event_Forwarding_Discriminator_Iterator::next (Consumer_Dispatch_Set *&cds) { ACE_Map_Entry<Event_Key, Consumer_Dispatch_Set *> *temp; + if (this->map_iter_.next (temp) == 0) return 0; else diff --git a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h index ff2298a2756..09b62d007d0 100644 --- a/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h +++ b/apps/Gateway/Gateway/Event_Forwarding_Discriminator.h @@ -40,8 +40,8 @@ public: public: ACE_Map_Manager<Event_Key, Consumer_Dispatch_Set *, ACE_Null_Mutex> map_; - // Map that associates Event Addrs (external ids) with Consumer_Dispatch_Set *'s - // <internal IDs>. + // Map that associates <Event_Key>s (external ids) with + // <Consumer_Dispatch_Set> *'s <internal IDs>. }; class Event_Forwarding_Discriminator_Iterator diff --git a/apps/Gateway/Gateway/File_Parser.h b/apps/Gateway/Gateway/File_Parser.h index 22490c6329b..e32d0948621 100644 --- a/apps/Gateway/Gateway/File_Parser.h +++ b/apps/Gateway/Gateway/File_Parser.h @@ -59,11 +59,23 @@ protected: // Read the next integer. FP::Return_Type readword (char buf[]); + // Read the next "word," which is demarcated by <delimiter>s. + // + // @@ This function is inherently flawed since it doesn't take a + // count of the size of <buf>... + int delimiter (char ch); + // Returns true if <ch> is a delimiter, i.e., ' ', ',', or '\t'. + int comments (char ch); + // Returns true if <ch> is the comment character, i.e., '#'. + int skipline (void); + // Skips to the remainder of a line, e.g., when we find a comment + // character. FILE *infile_; + // Pointer to the file we're reading. }; #if defined (ACE_TEMPLATES_REQUIRE_SOURCE) diff --git a/apps/Gateway/Gateway/Gateway.cpp b/apps/Gateway/Gateway/Gateway.cpp index d86afab90a4..383e9705acb 100644 --- a/apps/Gateway/Gateway/Gateway.cpp +++ b/apps/Gateway/Gateway/Gateway.cpp @@ -47,9 +47,6 @@ protected: Connection_Handler_Factory connection_handler_factory_; // Creates the appropriate type of <Connection_Handlers>. - - int debug_; - // Are we debugging? }; int @@ -120,6 +117,7 @@ Gateway::init (int argc, char *argv[]) Options::instance ()->performance_window ())); } + // Are we running as a connector? if (Options::instance ()->enabled (Options::CONSUMER_CONNECTOR | Options::SUPPLIER_CONNECTOR)) { @@ -208,14 +206,11 @@ Gateway::parse_connection_config_file (void) pci.event_channel_ = &this->event_channel_; // Create the appropriate type of Proxy. - Connection_Handler *connection_handler = - this->connection_handler_factory_.make_connection_handler (pci); + Connection_Handler *connection_handler; - if (connection_handler == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "make_connection_handler"), - -1); + ACE_ALLOCATOR_RETURN (connection_handler, + this->connection_handler_factory_.make_connection_handler (pci), + -1); // Bind the new Connection_Handler to the connection ID. this->event_channel_.bind_proxy (connection_handler); @@ -242,8 +237,8 @@ Gateway::parse_consumer_config_file (void) -1); // Read config file line at a time. - for (Consumer_Config_Info cci; - consumer_file.read_entry (cci, line_number) != FP::EOFILE; + for (Consumer_Config_Info cci_entry; + consumer_file.read_entry (cci_entry, line_number) != FP::EOFILE; ) { file_empty = 0; @@ -253,36 +248,38 @@ Gateway::parse_consumer_config_file (void) ACE_DEBUG ((LM_DEBUG, "(%t) connection id = %d, payload = %d, " "number of consumers = %d\n", - cci.connection_id_, - cci.type_, - cci.total_consumers_)); + cci_entry.connection_id_, + cci_entry.type_, + cci_entry.total_consumers_)); - for (int i = 0; i < cci.total_consumers_; i++) + for (int i = 0; i < cci_entry.total_consumers_; i++) ACE_DEBUG ((LM_DEBUG, "(%t) destination[%d] = %d\n", i, - cci.consumers_[i])); + cci_entry.consumers_[i])); } Consumer_Dispatch_Set *dispatch_set; ACE_NEW_RETURN (dispatch_set, Consumer_Dispatch_Set, -1); - Event_Key event_addr (cci.connection_id_, - cci.type_); + Event_Key event_addr (cci_entry.connection_id_, + cci_entry.type_); // Add the Consumers to the Dispatch_Set. - for (int i = 0; i < cci.total_consumers_; i++) + for (int i = 0; i < cci_entry.total_consumers_; i++) { Connection_Handler *connection_handler = 0; // Lookup destination and add to Consumer_Dispatch_Set set // if found. - if (this->event_channel_.find_proxy (cci.consumers_[i], + if (this->event_channel_.find_proxy (cci_entry.consumers_[i], connection_handler) != -1) dispatch_set->insert (connection_handler); else - ACE_ERROR ((LM_ERROR, "(%t) not found: destination[%d] = %d\n", - i, cci.consumers_[i])); + ACE_ERROR ((LM_ERROR, + "(%t) not found: destination[%d] = %d\n", + i, + cci_entry.consumers_[i])); } this->event_channel_.subscribe (event_addr, dispatch_set); diff --git a/apps/Gateway/Gateway/Gateway.h b/apps/Gateway/Gateway/Gateway.h index ba67df98dd6..5c85f6e696c 100644 --- a/apps/Gateway/Gateway/Gateway.h +++ b/apps/Gateway/Gateway/Gateway.h @@ -9,6 +9,10 @@ // = FILENAME // Gateway.h // +// = DESCRIPTION +// Since the Gateway is an <ACE_Service_Object>, this file defines +// the entry point into the Service Configurator framework. +// // = AUTHOR // Doug Schmidt // diff --git a/apps/Gateway/Gateway/Options.h b/apps/Gateway/Gateway/Options.h index 23b4180dfa8..d32ace5f770 100644 --- a/apps/Gateway/Gateway/Options.h +++ b/apps/Gateway/Gateway/Options.h @@ -22,7 +22,7 @@ class Options { // = TITLE - // Options Singleton for a gatewayd. + // Singleton that consolidates all Options for a gatewayd. public: // = Options that can be enabled/disabled. enum diff --git a/apps/Gateway/Peer/Options.h b/apps/Gateway/Peer/Options.h index c6c605a4d6a..55872a43d0b 100644 --- a/apps/Gateway/Peer/Options.h +++ b/apps/Gateway/Peer/Options.h @@ -21,7 +21,7 @@ class ACE_Svc_Export Options // = TITLE - // Options Singleton for a peerd. + // Singleton that consolidates all Options for a peerd. { public: // = Options that can be enabled/disabled. |