summaryrefslogtreecommitdiff
path: root/netsvcs/lib/TS_Clerk_Handler.h
diff options
context:
space:
mode:
Diffstat (limited to 'netsvcs/lib/TS_Clerk_Handler.h')
-rw-r--r--netsvcs/lib/TS_Clerk_Handler.h162
1 files changed, 83 insertions, 79 deletions
diff --git a/netsvcs/lib/TS_Clerk_Handler.h b/netsvcs/lib/TS_Clerk_Handler.h
index 48024ebf193..cfa92bcfc97 100644
--- a/netsvcs/lib/TS_Clerk_Handler.h
+++ b/netsvcs/lib/TS_Clerk_Handler.h
@@ -1,18 +1,15 @@
/* -*- C++ -*- */
-// $Id$
-
-// ============================================================================
-//
-// = LIBRARY
-// ace
-//
-// = FILENAME
-// TS_Clerk_Handler.h
-//
-// = AUTHOR
-// Prashant Jain
-//
-// ============================================================================
+
+//=============================================================================
+/**
+ * @file TS_Clerk_Handler.h
+ *
+ * $Id$
+ *
+ * @author Prashant Jain
+ */
+//=============================================================================
+
#ifndef ACE_TS_CLERK_HANDLER_H
#define ACE_TS_CLERK_HANDLER_H
@@ -31,10 +28,13 @@
#include "ace/svc_export.h"
#include "ace/os_include/os_dirent.h"
+/**
+ * @class ACE_Time_Info
+ *
+ * @brief A simple struct containing delta time and a sequence number.
+ */
class ACE_Time_Info
{
- // = TITLE
- // A simple struct containing delta time and a sequence number.
public:
long delta_time_;
@@ -48,26 +48,28 @@ class ACE_TS_Clerk_Processor; // forward declaration
template class ACE_Svc_Export ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION_EXPORT */
+/**
+ * @class ACE_TS_Clerk_Handler
+ *
+ * @brief The Clerk Handler provides the interface that is used by the
+ * Clerk Processor to send time update requests to all the
+ * servers. It obtains these updates from the servers and passes
+ * the updates to the Clerk Processor
+ *
+ * The Clerk Processor uses send_request() to send a request for
+ * time update to a server. The Clerk Handler internally computes
+ * the round trip delay for the reply to come back. Once it gets
+ * the reply back from the server (handle_input), it adjusts the
+ * system time using the round trip delay estimate and then
+ * passes the delta time by reference back to the Clerk
+ * Processor.
+ */
class ACE_Svc_Export ACE_TS_Clerk_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
- // = TITLE
- // The Clerk Handler provides the interface that is used by the
- // Clerk Processor to send time update requests to all the
- // servers. It obtains these updates from the servers and passes
- // the updates to the Clerk Processor
- //
- // = DESCRIPTION
- // The Clerk Processor uses send_request() to send a request for
- // time update to a server. The Clerk Handler internally computes
- // the round trip delay for the reply to come back. Once it gets
- // the reply back from the server (handle_input), it adjusts the
- // system time using the round trip delay estimate and then
- // passes the delta time by reference back to the Clerk
- // Processor.
public:
+ /// Default constructor.
ACE_TS_Clerk_Handler (ACE_TS_Clerk_Processor *processor = 0,
ACE_INET_Addr &addr = (ACE_INET_Addr &) ACE_Addr::sap_any);
- // Default constructor.
// = Set/get the current state
enum State
@@ -91,38 +93,38 @@ public:
int max_timeout (void);
void max_timeout (int);
+ /// Activate this instance of the <ACE_TS_Clerk_Handler>
+ /// (called by the <ACE_TS_Clerk_Processor>).
virtual int open (void * = 0);
- // Activate this instance of the <ACE_TS_Clerk_Handler>
- // (called by the <ACE_TS_Clerk_Processor>).
+ /// Return the handle of the message_fifo_;
virtual ACE_HANDLE get_handle (void) const;
- // Return the handle of the message_fifo_;
+ /// Called when object is removed from the ACE_Reactor
virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE,
ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK);
- // Called when object is removed from the ACE_Reactor
+ /// Receive time update from a server.
virtual int handle_input (ACE_HANDLE);
- // Receive time update from a server.
+ /// Restart connection asynchronously when timeout occurs.
virtual int handle_timeout (const ACE_Time_Value &tv,
const void *arg);
- // Restart connection asynchronously when timeout occurs.
+ /// Get/Set remote addr
void remote_addr (ACE_INET_Addr &addr);
ACE_INET_Addr &remote_addr (void);
- // Get/Set remote addr
+ /// Send request for time update to the server as well as return the
+ /// current time info by reference.
int send_request (ACE_UINT32 sequence_num,
ACE_Time_Info &time_info);
- // Send request for time update to the server as well as return the
- // current time info by reference.
protected:
+ /// Handle SIGPIPE.
virtual int handle_signal (int signum,
siginfo_t *,
ucontext_t *);
- // Handle SIGPIPE.
static void stderr_output (int = 0);
@@ -133,96 +135,98 @@ protected:
};
private:
+ /// Receive a reply from a server containing time update
int recv_reply (ACE_Time_Request &reply);
- // Receive a reply from a server containing time update
+ /// Reinitiate connection with the server
int reinitiate_connection (void);
- // Reinitiate connection with the server
+ /// The current state of the connection
State state_;
- // The current state of the connection
+ /// Amount of time to wait between reconnection attempts
int timeout_;
- // Amount of time to wait between reconnection attempts
+ /// Maximum amount of time to wait between reconnection attempts
int max_timeout_;
- // Maximum amount of time to wait between reconnection attempts
+ /// Remote Addr used for connecting to the server
ACE_INET_Addr remote_addr_;
- // Remote Addr used for connecting to the server
+ /// Instance of Clerk Processor used for re-establishing connections
ACE_TS_Clerk_Processor *processor_;
- // Instance of Clerk Processor used for re-establishing connections
+ /// Time at which request was sent (used to compute round trip delay)
ACE_UINT32 start_time_;
- // Time at which request was sent (used to compute round trip delay)
+ /// Next sequence number of time request (waiting for this update from
+ /// the server).
ACE_UINT32 cur_sequence_num_;
- // Next sequence number of time request (waiting for this update from
- // the server).
+ /// Record of current delta time and current sequence number
ACE_Time_Info time_info_;
- // Record of current delta time and current sequence number
};
+/**
+ * @class ACE_TS_Clerk_Processor
+ *
+ * @brief This class manages all the connections to the servers along
+ * with querying them periodically for time updates.
+ *
+ * The Clerk Processor creates connections to all the servers and
+ * creates an ACE_TS_Clerk_Handler for each connection to handle
+ * the requests and replies. It periodically sends a request for
+ * time update through each of the handlers and uses the replies
+ * for computing a synchronized system time.
+ */
class ACE_TS_Clerk_Processor : public ACE_Connector <ACE_TS_Clerk_Handler, ACE_SOCK_CONNECTOR>
{
- // = TITLE
- // This class manages all the connections to the servers along
- // with querying them periodically for time updates.
- //
- // = DESCRIPTION
- // The Clerk Processor creates connections to all the servers and
- // creates an ACE_TS_Clerk_Handler for each connection to handle
- // the requests and replies. It periodically sends a request for
- // time update through each of the handlers and uses the replies
- // for computing a synchronized system time.
public:
+ /// Default constructor
ACE_TS_Clerk_Processor (void);
- // Default constructor
+ /// Query servers for time periodically (timeout value)
virtual int handle_timeout (const ACE_Time_Value &tv,
const void *arg);
- // Query servers for time periodically (timeout value)
+ /// Set up connections to all servers
int initiate_connection (ACE_TS_Clerk_Handler *,
ACE_Synch_Options &);
- // Set up connections to all servers
protected:
// = Dynamic linking hooks.
+ /// Called when service is linked.
virtual int init (int argc, ACE_TCHAR *argv[]);
- // Called when service is linked.
+ /// Called when service is unlinked.
virtual int fini (void);
- // Called when service is unlinked.
+ /// Called to determine info about the service.
virtual int info (ACE_TCHAR **strp, size_t length) const;
- // Called to determine info about the service.
// = Scheduling hooks.
virtual int suspend (void);
virtual int resume (void);
private:
+ /// Parse svc.conf arguments.
int parse_args (int argc, ACE_TCHAR *argv[]);
- // Parse svc.conf arguments.
+ /// Allocate entry in shared memory for system time
void alloc (void);
- // Allocate entry in shared memory for system time
+ /// Update delta_time using times obtained from all servers
int update_time ();
- // Update delta_time using times obtained from all servers
+ /// Allocator (used for reading/writing system time from/to shared memory)
typedef ACE_Malloc <ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> MALLOC;
typedef ACE_Allocator_Adapter<MALLOC> ALLOCATOR;
ALLOCATOR *shmem_;
- // Allocator (used for reading/writing system time from/to shared memory)
+ /// Set of TS_Clerk_Handlers and iterator over the set.
typedef ACE_Unbounded_Set <ACE_TS_Clerk_Handler *> HANDLER_SET;
typedef ACE_Unbounded_Set_Iterator <ACE_TS_Clerk_Handler *> HANDLER_SET_ITERATOR;
HANDLER_SET handler_set_;
- // Set of TS_Clerk_Handlers and iterator over the set.
struct System_Time
{
@@ -230,23 +234,23 @@ private:
long *last_local_time_; // Last local time
};
+ /// Clerk system time containing pointers to entries in shared memory
System_Time system_time_;
- // Clerk system time containing pointers to entries in shared memory
+ /// Timer id returned by Reactor
long timer_id_;
- // Timer id returned by Reactor
+ /// Time period for updating system time
int timeout_;
- // Time period for updating system time
+ /// Pool name for backing store
ACE_TCHAR poolname_[MAXNAMLEN + 1];
- // Pool name for backing store
+ /// Do a blocking/non-blocking connect
int blocking_semantics_;
- // Do a blocking/non-blocking connect
+ /// Sequence number of next expected update from servers
ACE_UINT32 cur_sequence_num_;
- // Sequence number of next expected update from servers
};
ACE_SVC_FACTORY_DECLARE (ACE_TS_Clerk_Processor)