summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>2001-03-24 02:11:48 +0000
committerChris Cleeland <chris.cleeland@gmail.com>2001-03-24 02:11:48 +0000
commit450cea0401f48f3e9828c0d984c98ae2d3274048 (patch)
treef386ecc8908eb51b7597b8d6cdd047f4fb22021f
parent64e4f26946e40b3ddd57c5d79d51b7176be4e51b (diff)
downloadATCD-450cea0401f48f3e9828c0d984c98ae2d3274048.tar.gz
ChangeLogTag: Fri Mar 23 18:15:58 2001 Chris Cleeland <cleeland_c@ociweb.com>
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a93
-rw-r--r--TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp3
-rw-r--r--TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp58
-rw-r--r--TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h47
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/IIOP_SSL_Connector.cpp7
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp3
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp8
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp49
-rw-r--r--TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h38
-rw-r--r--TAO/tao/GIOP_Message_Base.cpp23
-rw-r--r--TAO/tao/GIOP_Message_Lite.cpp10
-rw-r--r--TAO/tao/GIOP_Utils.cpp2
-rw-r--r--TAO/tao/IIOP_Connection_Handler.cpp3
-rw-r--r--TAO/tao/IIOP_Connector.cpp8
-rw-r--r--TAO/tao/IIOP_Transport.cpp48
-rw-r--r--TAO/tao/IIOP_Transport.h51
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp3
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connector.cpp8
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.cpp58
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.h42
-rw-r--r--TAO/tao/Strategies/UIOP_Connection_Handler.cpp3
-rw-r--r--TAO/tao/Strategies/UIOP_Connector.cpp8
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.cpp62
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.h40
-rw-r--r--TAO/tao/Sync_Strategies.cpp8
-rw-r--r--TAO/tao/Transport.cpp166
-rw-r--r--TAO/tao/Transport.h198
-rw-r--r--TAO/tao/Transport_Cache_Manager.cpp44
28 files changed, 721 insertions, 370 deletions
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 7884ca24bf2..e66a0b01f63 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,96 @@
+Fri Mar 23 18:15:58 2001 Chris Cleeland <cleeland_c@ociweb.com>
+
+ * tao/GIOP_Message_Base.cpp:
+ * tao/GIOP_Message_Lite.cpp:
+ * tao/GIOP_Utils.cpp:
+
+ Changed uses of TAO_Tranport::handle() to TAO_Transport::id()
+ the uses were for debug/informational message purposes.
+
+ * tao/IIOP_Connector.cpp:
+ * tao/Strategies/UIOP_Connector.cpp:
+ * tao/Strategies/SHMIOP_Connector.cpp:
+ * tao/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp:
+
+ Changed debug message accesses to the transport's handler's
+ handle, and replaced with calls to TAO_Transport::id().
+
+ * tao/Sync_Strategies.cpp (timer_check): Eliminated direct
+ references to the transport's event handler and used the new
+ TAO_Transport::register_for_timer_event method to do this in a
+ lock-safe manner.
+
+ * tao/Transport_Cache_Manager.cpp (make_idle_i): Protected against
+ being passed a zero pointer as argument.
+
+ * tao/Transport_Cache_Manager.cpp (close_i): Added back code to
+ fill in an ACE_Handle_Set of all transports' associated handlers
+ which are registered with the reactor. This is necessary to
+ perform an orderly close and unloading of the ORB.
+
+ * tao/Transport.cpp:
+ * tao/Transport.h:
+
+ Added an ACE_Lock, initialized identically to the way that the
+ TAO_Transport_Cache_Manager's lock is initialized, to lock
+ accesses to or through the protocol-specific transport's
+ handler. Although the handler doesn't exist in the generic
+ TAO_Transport, the lock does so that the framework handles all
+ the tedious locking issues and the pluggable protocol
+ implementor only needs to override methods which are called in
+ lock-safe manner. Note that since the lock is initialized from
+ the resource factory, single-threaded implementations need not
+ pay locking penalties.
+
+ Added provide_handle method to permit the Sync Strategies to
+ fill in an ACE_Handle_Set without violating locking and
+ encapsulation.
+
+ Made the following methods lock-safe and created corresponding
+ _i methods which assume that the lock is already held--send,
+ recv, register_handler, event_handler, transtion_handler_state.
+ The corresponding _i methods are protected.
+
+ Eliminated service_handler and connection_handler accessors
+ since all they did was confuse the issue. Moreover, gaining
+ access to these would have violated the locking protocol. They
+ weren't necessary, so they're gone.
+
+ Added an id_ data member and getter/setter methods. Formerly,
+ the connection's handle was used for identifying the
+ transport--especially in debug messages--but the need for
+ lock-safety made that unreliable. Now, the id() is used
+ instead, and transport-savvy connection handlers can feel free
+ to change the id to anything they desire such as, say, the
+ handle_. :-)
+
+ * tao/IIOP_Transport.cpp:
+ * tao/IIOP_Transport.h:
+ * tao/Strategies/SHMIOP_Transport.cpp:
+ * tao/Strategies/SHMIOP_Transport.h:
+ * tao/Strategies/UIOP_Transport.cpp:
+ * tao/Strategies/UIOP_Transport.h:
+ * tao/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp:
+ * tao/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h:
+ * examples/PluggableUDP/DIOP/DIOP_Transport.cpp:
+ * examples/PluggableUDP/DIOP/DIOP_Transport.h:
+
+ Updated all of these to reflect the changes outlined for the
+ TAO_Transport base class.
+
+ * tao/IIOP_Connection_Handler.cpp (activate):
+ * tao/Strategies/UIOP_Connection_Handler.cpp (activate):
+ * tao/Strategies/SHMIOP_Connection_Handler.cpp (activate):
+ * tao/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp (activate):
+ * examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp (activate):
+
+ Added code to set the transport's id to the handler's handle,
+ thus making debug messages referring to that (which are
+ everywhere!) more useful.
+
+ Thanks to Carlos, Bala, Chad, and my family for all their help
+ on this change!
+
Fri Mar 23 15:16:57 2001 Irfan Pyarali <irfan@cs.wustl.edu>
* tao/PortableServer/POA.cpp (deactivate_all_objects_i):
diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp b/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp
index daf7b24f8bc..9b24c46178f 100644
--- a/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp
+++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Connection_Handler.cpp
@@ -213,6 +213,9 @@ TAO_DIOP_Connection_Handler::activate (long flags,
// @@ Michael: I believe we do not need active service handlers right now.
// @@ Frank: Not disabled yet...
+ // Set the id in the transport now that we're active.
+ this->transport ()->id (this->get_handle ());
+
return TAO_DIOP_SVC_HANDLER::activate (flags,
n_threads,
force_active,
diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp
index 61a4aa587db..e549ac38c4f 100644
--- a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp
+++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.cpp
@@ -53,28 +53,16 @@ TAO_DIOP_Transport::~TAO_DIOP_Transport (void)
delete this->messaging_object_;
}
-TAO_DIOP_SVC_HANDLER *
-TAO_DIOP_Transport::service_handler (void)
-{
- return this->connection_handler_;
-}
-
-ACE_HANDLE
-TAO_DIOP_Transport::handle (void)
-{
- return this->connection_handler_->get_handle ();
-}
-
ACE_Event_Handler *
-TAO_DIOP_Transport::event_handler (void)
+TAO_DIOP_Transport::event_handler_i (void)
{
return this->connection_handler_;
}
ssize_t
-TAO_DIOP_Transport::send (const ACE_Message_Block *message_block,
- const ACE_Time_Value * /*max_wait_time*/,
- size_t *bt)
+TAO_DIOP_Transport::send_i (const ACE_Message_Block *message_block,
+ const ACE_Time_Value * /*max_wait_time*/,
+ size_t *bt)
{
const ACE_INET_Addr &addr = this->connection_handler_->addr ();
@@ -141,8 +129,8 @@ TAO_DIOP_Transport::send (const ACE_Message_Block *message_block,
{
ssize_t current_transfer =
this->connection_handler_->dgram ().send (iov,
- iovcnt,
- addr);
+ iovcnt,
+ addr);
// Errors.
if (current_transfer == -1 || current_transfer == 0)
return current_transfer;
@@ -162,9 +150,9 @@ TAO_DIOP_Transport::send (const ACE_Message_Block *message_block,
}
ssize_t
-TAO_DIOP_Transport::recv (char *buf,
- size_t len,
- const ACE_Time_Value * /*max_wait_time*/)
+TAO_DIOP_Transport::recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value * /*max_wait_time*/)
{
ACE_INET_Addr from_addr;
@@ -174,8 +162,8 @@ TAO_DIOP_Transport::recv (char *buf,
{
local_buffer_.crunch ();
ssize_t n = this->connection_handler_->dgram ().recv (local_buffer_.wr_ptr (),
- local_buffer_.size (),
- from_addr);
+ local_buffer_.size (),
+ from_addr);
// Remember the from addr to eventually use it as remote
// addr for the reply.
@@ -250,7 +238,7 @@ TAO_DIOP_Transport::read_process_message (ACE_Time_Value *max_wait_time,
int
-TAO_DIOP_Transport::register_handler (void)
+TAO_DIOP_Transport::register_handler_i (void)
{
// @@ It seems like this method should go away, the right reactor is
// picked at object creation time.
@@ -314,8 +302,8 @@ TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream,
{
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO: (%P|%t|%N|%l) closing conn %d after fault %p\n"),
- this->handle (),
+ ACE_TEXT ("TAO: (%P|%t|%N|%l) closing transport %d after fault %p\n"),
+ this->id (),
ACE_TEXT ("send_message ()\n")));
return -1;
@@ -327,8 +315,8 @@ TAO_DIOP_Transport::send_message (TAO_OutputCDR &stream,
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n")
- ACE_TEXT ("EOF, closing conn %d\n"),
- this->handle()));
+ ACE_TEXT ("EOF, closing transport %d\n"),
+ this->id ()));
return -1;
}
@@ -514,8 +502,8 @@ TAO_DIOP_Transport::process_message (void)
// every reply on this connection.
if (TAO_debug_level > 0)
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) : DIOP_Client_Transport::")
- ACE_TEXT ("handle_client_input - ")
+ ACE_TEXT ("TAO (%P|%t) : DIOP_Transport::")
+ ACE_TEXT ("process_message - ")
ACE_TEXT ("dispatch reply failed\n")));
this->messaging_object_->reset ();
@@ -689,13 +677,7 @@ TAO_DIOP_Transport::get_listen_point (
*/
void
-TAO_DIOP_Transport::transition_handler_state (void)
-{
- connection_handler_ = 0;
-}
-
-TAO_Connection_Handler*
-TAO_DIOP_Transport::connection_handler (void) const
+TAO_DIOP_Transport::transition_handler_state_i (void)
{
- return connection_handler_;
+ this->connection_handler_ = 0;
}
diff --git a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h
index 3fee5adb1cf..c2f33f2f19e 100644
--- a/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h
+++ b/TAO/examples/PluggableUDP/DIOP/DIOP_Transport.h
@@ -60,25 +60,25 @@ public:
/// Default destructor.
~TAO_DIOP_Transport (void);
- /// Return the connection service handler
- TAO_DIOP_SVC_HANDLER *service_handler (void);
+protected:
+ /** @name Overridden Template Methods
+ *
+ * These are implementations of template methods declared by TAO_Transport.
+ */
+ //@{
- /// The TAO_Transport methods, please check the documentation in
- /// "tao/Pluggable.h" for more details.
- virtual ACE_HANDLE handle (void);
-
- virtual ACE_Event_Handler *event_handler (void);
+ virtual ACE_Event_Handler *event_handler_i (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *s = 0,
- size_t *bytes_transferred = 0);
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *s = 0,
+ size_t *bytes_transferred = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -86,8 +86,13 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
+ virtual int register_handler_i (void);
+
+ /// Method to do whatever it needs to do when the connection
+ /// handler is being closed and destroyed.
+ virtual void transition_handler_state_i (void);
+public:
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -124,21 +129,9 @@ public:
virtual int messaging_init (CORBA::Octet major,
CORBA::Octet minor);
- // @@ Frank : Not needed
- /*
- /// Open the service context list and process it.
- virtual int tear_listen_point_list (TAO_InputCDR &cdr);
- */
-
- /// Method to do whatever it needs to do when the connection
- /// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
-
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ //@}
private:
-
/// Process the message that we have read
int process_message (void);
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/IIOP_SSL_Connector.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/IIOP_SSL_Connector.cpp
index 9e42db7e892..ee9f22db91c 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/IIOP_SSL_Connector.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/IIOP_SSL_Connector.cpp
@@ -164,11 +164,8 @@ TAO_IIOP_SSL_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) IIOP_SSL_Connector::connect ")
- ACE_TEXT ("got an existing connection \n")));
- // We have found a connection and a handler
- svc_handler =
- ACE_dynamic_cast (TAO_IIOP_SSL_Connection_Handler *,
- base_transport->connection_handler ());
+ ACE_TEXT ("got an existing transport with id %d \n"),
+ base_transport->id ()));
}
else
{
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp
index 665bdeef1bd..14e72398fb5 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connection_Handler.cpp
@@ -157,6 +157,9 @@ TAO_SSLIOP_Connection_Handler::activate (long flags,
flags,
THR_BOUND));
+ // Set the id in the transport now that we're active.
+ this->transport ()->id (this->get_handle ());
+
return TAO_SSL_SVC_HANDLER::activate (flags,
n_threads,
force_active,
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
index f877e9208aa..e0ed5fe96d2 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Connector.cpp
@@ -210,12 +210,8 @@ TAO_SSLIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) SSLIOP_Connector::connect ")
- ACE_TEXT ("got an existing connection \n")));
-
- // We have found a connection and a handler
- svc_handler =
- ACE_dynamic_cast (TAO_SSLIOP_Connection_Handler *,
- base_transport->connection_handler ());
+ ACE_TEXT ("got an existing transport with id %d\n"),
+ base_transport->id ()));
}
else
{
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp
index 5fad414b4a6..bca0c50df4e 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.cpp
@@ -42,6 +42,7 @@ TAO_SSLIOP_Transport::~TAO_SSLIOP_Transport (void)
delete this->messaging_object_;
}
+#if 0
TAO_SSL_SVC_HANDLER *
TAO_SSLIOP_Transport::service_handler (void)
{
@@ -53,17 +54,18 @@ TAO_SSLIOP_Transport::handle (void)
{
return this->connection_handler_->get_handle ();
}
+#endif
ACE_Event_Handler *
-TAO_SSLIOP_Transport::event_handler (void)
+TAO_SSLIOP_Transport::event_handler_i (void)
{
return this->connection_handler_;
}
ssize_t
-TAO_SSLIOP_Transport::send (const ACE_Message_Block *message_block,
- const ACE_Time_Value *max_wait_time,
- size_t *bt)
+TAO_SSLIOP_Transport::send_i (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *max_wait_time,
+ size_t *bt)
{
// @@ This code should be refactored into ACE.cpp or something
// similar!
@@ -98,12 +100,12 @@ TAO_SSLIOP_Transport::send (const ACE_Message_Block *message_block,
if (iovcnt == IOV_MAX)
{
if (max_wait_time == 0)
- n = this->service_handler ()->peer ().sendv_n (iov,
- iovcnt);
+ n = this->connection_handler_->peer ().sendv_n (iov,
+ iovcnt);
else
// @@ No timeouts!!!
- n = this->service_handler ()->peer ().sendv_n (iov,
- iovcnt /*,
+ n = this->connection_handler_->peer ().sendv_n (iov,
+ iovcnt /*,
max_wait_time */);
if (n == 0 ||
@@ -119,8 +121,8 @@ TAO_SSLIOP_Transport::send (const ACE_Message_Block *message_block,
// Check for remaining buffers to be sent!
if (iovcnt != 0)
{
- n = this->service_handler ()->peer ().sendv_n (iov,
- iovcnt);
+ n = this->connection_handler_->peer ().sendv_n (iov,
+ iovcnt);
if (n == 0 ||
n == -1)
return n;
@@ -132,13 +134,13 @@ TAO_SSLIOP_Transport::send (const ACE_Message_Block *message_block,
}
ssize_t
-TAO_SSLIOP_Transport::recv (char *buf,
- size_t len,
- const ACE_Time_Value * /*max_wait_time*/)
+TAO_SSLIOP_Transport::recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value * /*max_wait_time*/)
{
- return this->service_handler ()->peer ().recv (buf,
- len
- /*, max_wait_time*/);
+ return this->connection_handler_->peer ().recv (buf,
+ len
+ /*, max_wait_time*/);
}
@@ -178,7 +180,7 @@ TAO_SSLIOP_Transport::read_process_message (ACE_Time_Value *max_wait_time,
int
-TAO_SSLIOP_Transport::register_handler (void)
+TAO_SSLIOP_Transport::register_handler_i (void)
{
// @@ It seems like this method should go away, the right reactor is
// picked at object creation time.
@@ -242,8 +244,8 @@ TAO_SSLIOP_Transport::send_message (TAO_OutputCDR &stream,
{
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO: (%P|%t|%N|%l) closing conn %d after fault %p\n"),
- this->handle (),
+ ACE_TEXT ("TAO: (%P|%t|%N|%l) closing transport %d after fault %p\n"),
+ this->id (),
ACE_TEXT ("send_message ()\n")));
return -1;
@@ -255,8 +257,8 @@ TAO_SSLIOP_Transport::send_message (TAO_OutputCDR &stream,
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n")
- ACE_TEXT ("EOF, closing conn %d\n"),
- this->handle()));
+ ACE_TEXT ("EOF, closing transport %d\n"),
+ this->id ()));
return -1;
}
@@ -599,13 +601,16 @@ TAO_SSLIOP_Transport::get_listen_point (
}
void
-TAO_SSLIOP_Transport::transition_handler_state (void)
+TAO_SSLIOP_Transport::transition_handler_state_i (void)
{
connection_handler_ = 0;
}
+#if 0
TAO_Connection_Handler*
TAO_SSLIOP_Transport::connection_handler (void) const
{
return connection_handler_;
}
+#endif
+
diff --git a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h
index 37e07b07a7f..891748a6283 100644
--- a/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h
+++ b/TAO/orbsvcs/orbsvcs/SSLIOP/SSLIOP_Transport.h
@@ -62,24 +62,33 @@ public:
/// Default destructor.
~TAO_SSLIOP_Transport (void);
+#if 0
/// Return the connection service handler
TAO_SSL_SVC_HANDLER *service_handler (void);
/// The TAO_Transport methods, please check the documentation in
/// "tao/Pluggable.h" for more details.
virtual ACE_HANDLE handle (void);
+#endif
- virtual ACE_Event_Handler *event_handler (void);
+protected:
+ /** @name Overridden Template Methods
+ *
+ * These are implementations of template methods declared by TAO_Transport.
+ */
+ //@{
+
+ virtual ACE_Event_Handler *event_handler_i (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *s = 0,
- size_t *bytes_transferred = 0);
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *s = 0,
+ size_t *bytes_transferred = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -87,8 +96,13 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
+ virtual int register_handler_i (void);
+ /// Method to do whatever it needs to do when the connection
+ /// handler is being closed and destroyed.
+ virtual void transition_handler_state_i (void);
+
+public:
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -128,12 +142,12 @@ public:
/// Open teh service context list and process it.
virtual int tear_listen_point_list (TAO_InputCDR &cdr);
- /// Method to do whatever it needs to do when the connection
- /// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
-
+#if 0
// Access the connection handler
virtual TAO_Connection_Handler* connection_handler (void) const;
+#endif
+
+ //@}
private:
diff --git a/TAO/tao/GIOP_Message_Base.cpp b/TAO/tao/GIOP_Message_Base.cpp
index 6db8d12025c..534defedb1f 100644
--- a/TAO/tao/GIOP_Message_Base.cpp
+++ b/TAO/tao/GIOP_Message_Base.cpp
@@ -880,8 +880,6 @@ TAO_GIOP_Message_Base::send_error (TAO_Transport *transport)
(const u_char *) error_message,
TAO_GIOP_MESSAGE_HEADER_LEN );
- ACE_HANDLE which = transport->handle ();
-
ACE_Data_Block data_block (TAO_GIOP_MESSAGE_HEADER_LEN,
ACE_Message_Block::MB_DATA,
error_message,
@@ -897,8 +895,8 @@ TAO_GIOP_Message_Base::send_error (TAO_Transport *transport)
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO (%N|%l|%P|%t) error sending error to %d\n"),
- which));
+ ACE_TEXT ("TAO (%N|%l|%P|%t) error sending error to transport %lu\n"),
+ transport->id ()));
}
return result;
@@ -997,6 +995,14 @@ TAO_GIOP_Message_Base::
(const u_char *) close_message,
TAO_GIOP_MESSAGE_HEADER_LEN);
+#if 0
+ // @@CJC I don't think we need this check b/c the transport's send()
+ // will simply return -1. However, I guess we could create something
+ // like TAO_Tranport::is_closed() that returns whether the connection
+ // is already closed. The problem with that, however, is that it's
+ // entirely possible that is_closed() could return TRUE, and then the
+ // transport could get closed down btw. the time it gets called and the
+ // time that the send actually occurs.
ACE_HANDLE which = transport->handle ();
if (which == ACE_INVALID_HANDLE)
{
@@ -1006,6 +1012,7 @@ TAO_GIOP_Message_Base::
" connection already closed\n"));
return;
}
+#endif
ACE_Data_Block data_block (TAO_GIOP_MESSAGE_HEADER_LEN,
ACE_Message_Block::MB_DATA,
@@ -1017,18 +1024,18 @@ TAO_GIOP_Message_Base::
ACE_Message_Block message_block(&data_block);
message_block.wr_ptr (TAO_GIOP_MESSAGE_HEADER_LEN);
- if (transport->send (&message_block) == -1)
+ if (transport->send (&message_block) == -1 && errno != ENOENT)
{
if (TAO_orbdebug)
ACE_ERROR ((LM_ERROR,
- "(%P|%t) error closing connection %d\n",
- which));
+ "(%P|%t) error closing connection %lu, errno = %d\n",
+ transport->id (), errno));
}
transport->close_connection ();
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) shut down transport, handle %d\n",
- which));
+ transport-> id ()));
}
diff --git a/TAO/tao/GIOP_Message_Lite.cpp b/TAO/tao/GIOP_Message_Lite.cpp
index 55c1159bed2..4ef083ccf55 100644
--- a/TAO/tao/GIOP_Message_Lite.cpp
+++ b/TAO/tao/GIOP_Message_Lite.cpp
@@ -1290,8 +1290,8 @@ TAO_GIOP_Message_Lite::send_reply_exception (
// Close the handle.
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t|%N|%l) cannot marshal exception, handle = %d: %p\n"),
- transport->handle (),
+ ACE_TEXT ("(%P|%t|%N|%l) cannot marshal exception on transport %lu: %p\n"),
+ transport->id (),
ACE_TEXT ("send_reply_exception ()")));
return -1;
}
@@ -1355,8 +1355,6 @@ TAO_GIOP_Message_Lite::send_error (TAO_Transport *transport)
(const u_char *) error_message,
TAO_GIOP_LITE_HEADER_LEN);
- ACE_HANDLE which = transport->handle ();
-
ACE_Data_Block data_block (TAO_GIOP_LITE_HEADER_LEN,
ACE_Message_Block::MB_DATA,
error_message,
@@ -1374,8 +1372,8 @@ TAO_GIOP_Message_Lite::send_error (TAO_Transport *transport)
{
ACE_DEBUG ((
LM_DEBUG,
- ACE_TEXT ("TAO (%N|%l|%P|%t) error sending error to %d\n"),
- which
+ ACE_TEXT ("TAO (%N|%l|%P|%t) error sending error to transport %lu, errno = %d\n"),
+ transport->id (), errno
));
}
}
diff --git a/TAO/tao/GIOP_Utils.cpp b/TAO/tao/GIOP_Utils.cpp
index fba958a8111..67df0d37c77 100644
--- a/TAO/tao/GIOP_Utils.cpp
+++ b/TAO/tao/GIOP_Utils.cpp
@@ -60,7 +60,7 @@ TAO_GIOP_Utils::read_buffer (TAO_Transport *transport,
ACE_TEXT (" transport = %d, ")
ACE_TEXT ("bytes = %d, len = %d\n"),
ACE_TEXT ("read_buffer"),
- transport->handle (),
+ transport->id (),
bytes_read,
len));
diff --git a/TAO/tao/IIOP_Connection_Handler.cpp b/TAO/tao/IIOP_Connection_Handler.cpp
index 18abad588b8..ddb675cc7d6 100644
--- a/TAO/tao/IIOP_Connection_Handler.cpp
+++ b/TAO/tao/IIOP_Connection_Handler.cpp
@@ -142,6 +142,9 @@ TAO_IIOP_Connection_Handler::activate (long flags,
flags,
THR_BOUND));
+ // Set the id in the transport now that we're active.
+ this->transport ()->id (this->get_handle ());
+
return TAO_IIOP_SVC_HANDLER::activate (flags,
n_threads,
force_active,
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index bf016deaee9..51dacc45089 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -164,15 +164,11 @@ TAO_IIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (this->orb_core ()->transport_cache ().find_transport (desc,
base_transport) == 0)
{
- // We have found a connection and a transport
- svc_handler =
- ACE_dynamic_cast (TAO_IIOP_Connection_Handler *,
- base_transport->connection_handler ());
if (TAO_debug_level > 2)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) IIOP_Connector::connect - ")
- ACE_TEXT ("got an existing connection on HANDLE %d\n"),
- svc_handler->peer ().get_handle ()));
+ ACE_TEXT ("got an existing transport with id %d\n"),
+ base_transport->id ()));
}
else
{
diff --git a/TAO/tao/IIOP_Transport.cpp b/TAO/tao/IIOP_Transport.cpp
index a86c84819b4..16be7c5eb40 100644
--- a/TAO/tao/IIOP_Transport.cpp
+++ b/TAO/tao/IIOP_Transport.cpp
@@ -51,43 +51,39 @@ TAO_IIOP_Transport::~TAO_IIOP_Transport (void)
delete this->messaging_object_;
}
-TAO_IIOP_SVC_HANDLER *
-TAO_IIOP_Transport::service_handler (void)
-{
- return this->connection_handler_;
-}
-
+#if 0
ACE_HANDLE
TAO_IIOP_Transport::handle (void)
{
return this->connection_handler_->get_handle ();
}
+#endif
ACE_Event_Handler *
-TAO_IIOP_Transport::event_handler (void)
+TAO_IIOP_Transport::event_handler_i (void)
{
return this->connection_handler_;
}
ssize_t
-TAO_IIOP_Transport::send (const ACE_Message_Block *message_block,
- const ACE_Time_Value *max_wait_time,
- size_t *bytes_transferred)
+TAO_IIOP_Transport::send_i (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *max_wait_time,
+ size_t *bytes_transferred)
{
- return ACE::send_n (this->handle (),
+ return ACE::send_n (this->connection_handler_->get_handle (),
message_block,
max_wait_time,
bytes_transferred);
}
ssize_t
-TAO_IIOP_Transport::recv (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_IIOP_Transport::recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
- return this->service_handler ()->peer ().recv (buf,
- len,
- max_wait_time);
+ return this->connection_handler_->peer ().recv (buf,
+ len,
+ max_wait_time);
}
@@ -127,7 +123,7 @@ TAO_IIOP_Transport::read_process_message (ACE_Time_Value *max_wait_time,
int
-TAO_IIOP_Transport::register_handler (void)
+TAO_IIOP_Transport::register_handler_i (void)
{
// @@ It seems like this method should go away, the right reactor is
// picked at object creation time.
@@ -191,8 +187,8 @@ TAO_IIOP_Transport::send_message (TAO_OutputCDR &stream,
{
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO: (%P|%t|%N|%l) closing conn %d after fault %p\n"),
- this->handle (),
+ ACE_TEXT ("TAO: (%P|%t|%N|%l) closing transport %d after fault %p\n"),
+ this->id (),
ACE_TEXT ("send_message ()\n")));
return -1;
@@ -204,8 +200,8 @@ TAO_IIOP_Transport::send_message (TAO_OutputCDR &stream,
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n")
- ACE_TEXT ("EOF, closing conn %d\n"),
- this->handle()));
+ ACE_TEXT ("EOF, closing transport %d\n"),
+ this->id ()));
return -1;
}
@@ -389,8 +385,8 @@ TAO_IIOP_Transport::process_message (void)
// every reply on this connection.
if (TAO_debug_level > 0)
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) : IIOP_Client_Transport::")
- ACE_TEXT ("handle_client_input - ")
+ ACE_TEXT ("TAO (%P|%t) : IIOP_Transport::")
+ ACE_TEXT ("process_message - ")
ACE_TEXT ("dispatch reply failed\n")));
this->messaging_object_->reset ();
@@ -562,13 +558,15 @@ TAO_IIOP_Transport::get_listen_point (
}
void
-TAO_IIOP_Transport::transition_handler_state (void)
+TAO_IIOP_Transport::transition_handler_state_i (void)
{
connection_handler_ = 0;
}
+#if 0
TAO_Connection_Handler*
TAO_IIOP_Transport::connection_handler (void) const
{
return connection_handler_;
}
+#endif
diff --git a/TAO/tao/IIOP_Transport.h b/TAO/tao/IIOP_Transport.h
index b8990bf2462..f882ef18ce2 100644
--- a/TAO/tao/IIOP_Transport.h
+++ b/TAO/tao/IIOP_Transport.h
@@ -61,25 +61,29 @@ public:
/// Default destructor.
~TAO_IIOP_Transport (void);
- /// Return the connection service handler
- TAO_IIOP_SVC_HANDLER *service_handler (void);
+protected:
+ /** @name Overridden Template Methods
+ *
+ * These are implementations of template methods declared by TAO_Transport.
+ */
+ //@{
- /// The TAO_Transport methods, please check the documentation in
- /// "tao/Pluggable.h" for more details.
- virtual ACE_HANDLE handle (void);
-
- virtual ACE_Event_Handler *event_handler (void);
+ /// Access connection_handler_ as an <code>ACE_Event_Handler</code>.
+ /// Must be called with transport's lock held.
+ virtual ACE_Event_Handler *event_handler_i (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *s = 0,
- size_t *bytes_transferred = 0);
+ /// Must be called with transport's lock held.
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *s = 0,
+ size_t *bytes_transferred = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ /// Must be called with transport's lock held.
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -87,8 +91,13 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
+ virtual int register_handler_i (void);
+
+ /// Method to do whatever it needs to do when the connection
+ /// handler is being closed and destroyed.
+ virtual void transition_handler_state_i (void);
+public:
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -116,10 +125,9 @@ public:
ACE_THROW_SPEC ((CORBA::SystemException));
- virtual CORBA::Boolean
- send_request_header (TAO_Operation_Details &opdetails,
- TAO_Target_Specification &spec,
- TAO_OutputCDR &msg);
+ virtual CORBA::Boolean send_request_header (TAO_Operation_Details &opdetails,
+ TAO_Target_Specification &spec,
+ TAO_OutputCDR &msg);
/// Initialising the messaging object
virtual int messaging_init (CORBA::Octet major,
@@ -128,12 +136,7 @@ public:
/// Open the service context list and process it.
virtual int tear_listen_point_list (TAO_InputCDR &cdr);
- /// Method to do whatever it needs to do when the connection
- /// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
-
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ //@}
private:
diff --git a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
index 802e34af5d5..96320dfe48c 100644
--- a/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connection_Handler.cpp
@@ -145,6 +145,9 @@ TAO_SHMIOP_Connection_Handler::activate (long flags,
flags,
THR_BOUND));
+ // Set the id in the transport now that we're active.
+ this->transport ()->id (this->get_handle ());
+
return TAO_SHMIOP_SVC_HANDLER::activate (flags,
n_threads,
force_active,
diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp
index c8e4c3ad189..4644ff6c698 100644
--- a/TAO/tao/Strategies/SHMIOP_Connector.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp
@@ -158,12 +158,8 @@ TAO_SHMIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ")
- ACE_TEXT ("got an existing connection \n")));
-
- // We have found a connection and a handler
- svc_handler =
- ACE_dynamic_cast (TAO_SHMIOP_Connection_Handler *,
- base_transport->connection_handler ());
+ ACE_TEXT ("got an existing transport with id %d \n"),
+ base_transport->id ()));
}
else
{
diff --git a/TAO/tao/Strategies/SHMIOP_Transport.cpp b/TAO/tao/Strategies/SHMIOP_Transport.cpp
index bb39b601bb8..0702b07e05f 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Transport.cpp
@@ -55,41 +55,29 @@ TAO_SHMIOP_Transport::~TAO_SHMIOP_Transport (void)
delete this->messaging_object_;
}
-TAO_SHMIOP_SVC_HANDLER *
-TAO_SHMIOP_Transport::service_handler (void)
-{
- return this->connection_handler_;
-}
-
-ACE_HANDLE
-TAO_SHMIOP_Transport::handle (void)
-{
- return this->connection_handler_->get_handle ();
-}
-
ACE_Event_Handler *
-TAO_SHMIOP_Transport::event_handler (void)
+TAO_SHMIOP_Transport::event_handler_i (void)
{
return this->connection_handler_;
}
ssize_t
-TAO_SHMIOP_Transport::send (const ACE_Message_Block *message_block,
- const ACE_Time_Value *max_wait_time,
- size_t *)
+TAO_SHMIOP_Transport::send_i (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *max_wait_time,
+ size_t *)
{
- return this->service_handler ()->peer ().send (message_block,
- max_wait_time);
+ return this->connection_handler_->peer ().send (message_block,
+ max_wait_time);
}
ssize_t
-TAO_SHMIOP_Transport::recv (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_SHMIOP_Transport::recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
- return this->service_handler ()->peer ().recv (buf,
- len,
- max_wait_time);
+ return this->connection_handler_->peer ().recv (buf,
+ len,
+ max_wait_time);
}
@@ -129,7 +117,7 @@ TAO_SHMIOP_Transport::read_process_message (ACE_Time_Value *max_wait_time,
int
-TAO_SHMIOP_Transport::register_handler (void)
+TAO_SHMIOP_Transport::register_handler_i (void)
{
// @@ It seems like this method should go away, the right reactor is
// picked at object creation time.
@@ -193,8 +181,8 @@ TAO_SHMIOP_Transport::send_message (TAO_OutputCDR &stream,
{
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO: (%P|%t|%N|%l) closing conn %d after fault %p\n"),
- this->handle (),
+ ACE_TEXT ("TAO: (%P|%t|%N|%l) closing transport %d after fault %p\n"),
+ this->id (),
ACE_TEXT ("send_message ()\n")));
return -1;
@@ -206,8 +194,8 @@ TAO_SHMIOP_Transport::send_message (TAO_OutputCDR &stream,
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n")
- ACE_TEXT ("EOF, closing conn %d\n"),
- this->handle()));
+ ACE_TEXT ("EOF, closing transport %d\n"),
+ this->id ()));
return -1;
}
@@ -355,8 +343,8 @@ TAO_SHMIOP_Transport::process_message (void)
{
if (TAO_debug_level > 0)
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) : SHMIOP_Client_Transport::")
- ACE_TEXT ("handle_client_input - ")
+ ACE_TEXT ("TAO (%P|%t) : SHMIOP_Transport::")
+ ACE_TEXT ("process_message - ")
ACE_TEXT ("dispatch reply failed\n")));
this->messaging_object_->reset ();
this->tms_->connection_closed ();
@@ -393,15 +381,9 @@ TAO_SHMIOP_Transport::process_message (void)
}
void
-TAO_SHMIOP_Transport::transition_handler_state (void)
+TAO_SHMIOP_Transport::transition_handler_state_i (void)
{
connection_handler_ = 0;
}
-TAO_Connection_Handler*
-TAO_SHMIOP_Transport::connection_handler (void) const
-{
- return connection_handler_;
-}
-
#endif /* TAO_HAS_SHMIOP && TAO_HAS_SHMIOP != 0 */
diff --git a/TAO/tao/Strategies/SHMIOP_Transport.h b/TAO/tao/Strategies/SHMIOP_Transport.h
index 00aa36b4c75..5c6f4e84176 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.h
+++ b/TAO/tao/Strategies/SHMIOP_Transport.h
@@ -55,24 +55,24 @@ public:
/// Default destructor.
~TAO_SHMIOP_Transport (void);
- /// Return the connection service handler
- TAO_SHMIOP_SVC_HANDLER *service_handler (void);
+protected:
+ /** @name Overridden Template Methods
+ *
+ * These are implementations of template methods declared by TAO_Transport.
+ */
+ //@{
- /// The TAO_Transport methods, please check the documentation in
- /// "tao/Pluggable.h" for more details.
- virtual ACE_HANDLE handle (void);
-
- virtual ACE_Event_Handler *event_handler (void);
+ virtual ACE_Event_Handler *event_handler_i (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *s = 0,
- size_t *bytes_transferred = 0);
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *s = 0,
+ size_t *bytes_transferred = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -80,8 +80,13 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
+ virtual int register_handler_i (void);
+ /// Method to do whatever it needs to do when the connection
+ /// handler is being closed and destroyed.
+ virtual void transition_handler_state_i (void);
+
+public:
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -122,20 +127,13 @@ public:
/// signalling.
virtual int reactor_signalling (void);
- /// Method to do whatever it needs to do when the connection
- /// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
-
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ //@}
private:
-
/// Process the message that we have read
int process_message (void);
private:
-
/// The connection service handler used for accessing lower layer
/// communication protocols.
TAO_SHMIOP_Connection_Handler *connection_handler_;
diff --git a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
index 37c252530ca..f17c384286e 100644
--- a/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
+++ b/TAO/tao/Strategies/UIOP_Connection_Handler.cpp
@@ -127,6 +127,9 @@ TAO_UIOP_Connection_Handler::activate (long flags,
flags,
THR_BOUND));
+ // Set the id in the transport now that we're active.
+ this->transport ()->id (this->get_handle ());
+
return TAO_UIOP_SVC_HANDLER::activate (flags,
n_threads,
force_active,
diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp
index b07795db20f..61c328b3863 100644
--- a/TAO/tao/Strategies/UIOP_Connector.cpp
+++ b/TAO/tao/Strategies/UIOP_Connector.cpp
@@ -165,12 +165,8 @@ TAO_UIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (TAO_debug_level > 5)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
- ACE_TEXT ("got an existing connection \n")));
-
- // We have found a connection and a handler
- svc_handler =
- ACE_dynamic_cast (TAO_UIOP_Connection_Handler *,
- base_transport->connection_handler ());
+ ACE_TEXT ("got an existing transport with id %d \n"),
+ base_transport->id ()));
}
else
{
diff --git a/TAO/tao/Strategies/UIOP_Transport.cpp b/TAO/tao/Strategies/UIOP_Transport.cpp
index 29f67574369..5a438d9f994 100644
--- a/TAO/tao/Strategies/UIOP_Transport.cpp
+++ b/TAO/tao/Strategies/UIOP_Transport.cpp
@@ -32,9 +32,9 @@ TAO_UIOP_Transport::TAO_UIOP_Transport (TAO_UIOP_Connection_Handler *handler,
TAO_ORB_Core *orb_core,
CORBA::Boolean flag)
: TAO_Transport (TAO_TAG_UIOP_PROFILE,
- orb_core),
- connection_handler_ (handler),
- messaging_object_ (0)
+ orb_core)
+ , connection_handler_ (handler)
+ , messaging_object_ (0)
{
if (flag)
{
@@ -55,43 +55,31 @@ TAO_UIOP_Transport::~TAO_UIOP_Transport (void)
delete this->messaging_object_;
}
-TAO_UIOP_SVC_HANDLER *
-TAO_UIOP_Transport::service_handler (void)
-{
- return this->connection_handler_;
-}
-
-ACE_HANDLE
-TAO_UIOP_Transport::handle (void)
-{
- return this->connection_handler_->get_handle ();
-}
-
ACE_Event_Handler *
-TAO_UIOP_Transport::event_handler (void)
+TAO_UIOP_Transport::event_handler_i (void)
{
return this->connection_handler_;
}
ssize_t
-TAO_UIOP_Transport::send (const ACE_Message_Block *message_block,
- const ACE_Time_Value *max_wait_time,
- size_t *bytes_transferred)
+TAO_UIOP_Transport::send_i (const ACE_Message_Block *message_block,
+ const ACE_Time_Value *max_wait_time,
+ size_t *bytes_transferred)
{
- return ACE::send_n (this->handle (),
+ return ACE::send_n (this->connection_handler_->get_handle (),
message_block,
max_wait_time,
bytes_transferred);
}
ssize_t
-TAO_UIOP_Transport::recv (char *buf,
- size_t len,
- const ACE_Time_Value *max_wait_time)
+TAO_UIOP_Transport::recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *max_wait_time)
{
- return this->service_handler ()->peer ().recv (buf,
- len,
- max_wait_time);
+ return this->connection_handler_->peer ().recv (buf,
+ len,
+ max_wait_time);
}
int
@@ -130,7 +118,7 @@ TAO_UIOP_Transport::read_process_message (ACE_Time_Value *max_wait_time,
int
-TAO_UIOP_Transport::register_handler (void)
+TAO_UIOP_Transport::register_handler_i (void)
{
// @@ It seems like this method should go away, the right reactor is
// picked at object creation time.
@@ -194,8 +182,8 @@ TAO_UIOP_Transport::send_message (TAO_OutputCDR &stream,
{
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("TAO: (%P|%t|%N|%l) closing conn %d after fault %p\n"),
- this->handle (),
+ ACE_TEXT ("TAO: (%P|%t|%N|%l) closing transport %d after fault %p\n"),
+ this->id (),
ACE_TEXT ("send_message ()\n")));
return -1;
@@ -207,8 +195,8 @@ TAO_UIOP_Transport::send_message (TAO_OutputCDR &stream,
if (TAO_debug_level)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO: (%P|%t|%N|%l) send_message () \n")
- ACE_TEXT ("EOF, closing conn %d\n"),
- this->handle()));
+ ACE_TEXT ("EOF, closing transport %d\n"),
+ this->id ()));
return -1;
}
@@ -350,8 +338,8 @@ TAO_UIOP_Transport::process_message (void)
{
if (TAO_debug_level > 0)
ACE_ERROR ((LM_ERROR,
- ACE_TEXT ("TAO (%P|%t) : UIOP_Client_Transport::")
- ACE_TEXT ("handle_client_input - ")
+ ACE_TEXT ("TAO (%P|%t) : UIOP_Transport::")
+ ACE_TEXT ("process_message - ")
ACE_TEXT ("dispatch reply failed\n")));
this->messaging_object_->reset ();
this->tms_->connection_closed ();
@@ -387,15 +375,9 @@ TAO_UIOP_Transport::process_message (void)
}
void
-TAO_UIOP_Transport::transition_handler_state (void)
+TAO_UIOP_Transport::transition_handler_state_i (void)
{
connection_handler_ = 0;
}
-TAO_Connection_Handler*
-TAO_UIOP_Transport::connection_handler (void) const
-{
- return connection_handler_;
-}
-
#endif /* TAO_HAS_UIOP */
diff --git a/TAO/tao/Strategies/UIOP_Transport.h b/TAO/tao/Strategies/UIOP_Transport.h
index b9b9b172fc1..b95eeec6e89 100644
--- a/TAO/tao/Strategies/UIOP_Transport.h
+++ b/TAO/tao/Strategies/UIOP_Transport.h
@@ -60,24 +60,24 @@ public:
/// Default destructor.
~TAO_UIOP_Transport (void);
- /// Return the connection service handler
- TAO_UIOP_SVC_HANDLER *service_handler (void);
+protected:
+ /** @name Overridden Template Methods
+ *
+ * These are implementations of template methods declared by TAO_Transport.
+ */
+ //@{
- /// The TAO_Transport methods, please check the documentation in
- /// "tao/Pluggable.h" for more details.
- virtual ACE_HANDLE handle (void);
-
- virtual ACE_Event_Handler *event_handler (void);
+ virtual ACE_Event_Handler *event_handler_i (void);
/// Write the complete Message_Block chain to the connection.
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *s = 0,
- size_t *bytes_transferred = 0);
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *s = 0,
+ size_t *bytes_transferred = 0);
/// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -85,8 +85,13 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
+ virtual int register_handler_i (void);
+
+ /// Method to do whatever it needs to do when the connection
+ /// handler is being closed and destroyed.
+ virtual void transition_handler_state_i (void);
+public:
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -123,12 +128,7 @@ public:
virtual int messaging_init (CORBA::Octet major,
CORBA::Octet minor);
- /// Method to do whatever it needs to do when the connection
- /// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
-
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ //@}
private:
diff --git a/TAO/tao/Sync_Strategies.cpp b/TAO/tao/Sync_Strategies.cpp
index c679fc3405c..d09bcd1a5a5 100644
--- a/TAO/tao/Sync_Strategies.cpp
+++ b/TAO/tao/Sync_Strategies.cpp
@@ -212,13 +212,7 @@ TAO_Eager_Buffering_Sync_Strategy::timer_check (TAO_Transport &transport,
ACE_Time_Value timeout =
this->time_conversion (buffering_constraint.timeout);
- // Get our reactor.
- ACE_Reactor *reactor = transport.orb_core ()->reactor ();
-
- long timer_id = reactor->schedule_timer (transport.event_handler (),
- 0,
- timeout,
- timeout);
+ long timer_id = transport.register_for_timer_event (0, timeout, timeout);
transport.buffering_timer_id (timer_id);
transport.buffering_timeout_value (timeout);
diff --git a/TAO/tao/Transport.cpp b/TAO/tao/Transport.cpp
index daaeee617ec..c58fddc97c1 100644
--- a/TAO/tao/Transport.cpp
+++ b/TAO/tao/Transport.cpp
@@ -57,6 +57,7 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag,
, buffering_queue_ (0)
, buffering_timer_id_ (0)
, bidirectional_flag_ (-1)
+ , id_ ((int)this)
{
TAO_Client_Strategy_Factory *cf =
this->orb_core_->client_factory ();
@@ -66,6 +67,10 @@ TAO_Transport::TAO_Transport (CORBA::ULong tag,
// Create TMS now.
this->tms_ = cf->create_transport_mux_strategy (this);
+
+ // Create a handler lock
+ this->handler_lock_ =
+ this->orb_core_->resource_factory ()->create_cached_connection_lock ();
}
TAO_Transport::~TAO_Transport (void)
@@ -77,6 +82,8 @@ TAO_Transport::~TAO_Transport (void)
this->tms_ = 0;
delete this->buffering_queue_;
+
+ delete this->handler_lock_;
}
ssize_t
@@ -85,8 +92,11 @@ TAO_Transport::send_or_buffer (TAO_Stub *stub,
const ACE_Message_Block *message_block,
const ACE_Time_Value *max_wait_time)
{
+
if (stub == 0 || two_way)
- return this->send (message_block, max_wait_time);
+ {
+ return this->send (message_block, max_wait_time);
+ }
TAO_Sync_Strategy &sync_strategy = stub->sync_strategy ();
@@ -96,6 +106,18 @@ TAO_Transport::send_or_buffer (TAO_Stub *stub,
max_wait_time);
}
+void
+TAO_Transport::provide_handle (ACE_Handle_Set &handle_set)
+{
+ ACE_MT (ACE_GUARD (ACE_Lock,
+ guard,
+ *this->handler_lock_));
+ ACE_Event_Handler *eh = this->event_handler_i ();
+ TAO_Connection_Handler *ch = ACE_dynamic_cast (TAO_Connection_Handler *, eh);
+ if (ch && ch->is_registered ())
+ handle_set.set_bit (eh->get_handle ());
+}
+
ssize_t
TAO_Transport::send_buffered_messages (const ACE_Time_Value *max_wait_time)
{
@@ -104,6 +126,16 @@ TAO_Transport::send_buffered_messages (const ACE_Time_Value *max_wait_time)
this->buffering_queue_->is_empty ())
return 1;
+ // Now, we can take the lock and try to do something.
+ //
+ // @@CJC We might be able to reduce the length of time we hold
+ // the lock depending on whether or not we need to hold the
+ // hold the lock while we're doing queueing activities.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+
// Get the first message from the queue.
ACE_Message_Block *queued_message = 0;
ssize_t result = this->buffering_queue_->peek_dequeue_head (queued_message);
@@ -111,11 +143,13 @@ TAO_Transport::send_buffered_messages (const ACE_Time_Value *max_wait_time)
// @@ What to do here on failures?
ACE_ASSERT (result != -1);
+ // @@CJC take lock??
// Actual network send.
size_t bytes_transferred = 0;
- result = this->send (queued_message,
- max_wait_time,
- &bytes_transferred);
+ result = this->send_i (queued_message,
+ max_wait_time,
+ &bytes_transferred);
+ // @@CJC release lock??
// Cannot send completely: timed out.
if (result == -1 &&
@@ -263,20 +297,30 @@ TAO_Transport::reactor_signalling (void)
void
TAO_Transport::connection_handler_closing (void)
{
- this->transition_handler_state ();
+ {
+ ACE_MT (ACE_GUARD (ACE_Lock,
+ guard,
+ *this->handler_lock_));
- this->orb_core_->transport_cache ().purge_entry (
- this->cache_map_entry_);
+ this->transition_handler_state_i ();
+
+ this->orb_core_->transport_cache ().purge_entry (
+ this->cache_map_entry_);
+ }
+ // Can't hold the lock while we release, b/c the release could
+ // invoke the destructor!
// This should be the last thing we do here
TAO_Transport::release(this);
}
+#if 0
TAO_Connection_Handler*
TAO_Transport::connection_handler (void) const
{
return 0;
}
+#endif
TAO_Transport*
TAO_Transport::_duplicate (TAO_Transport* transport)
@@ -341,14 +385,110 @@ TAO_Transport::make_idle (void)
void
TAO_Transport::close_connection (void)
{
- // Call handle close on the connection handler.
+ ACE_MT (ACE_GUARD (ACE_Lock,
+ guard,
+ *this->handler_lock_));
+
+ // Call handle close on the handler.
// The event handler is as common as we can get
- if (this->event_handler () != 0)
- {
- this->event_handler ()->handle_close (ACE_INVALID_HANDLE,
- ACE_Event_Handler::ALL_EVENTS_MASK);
- }
+ ACE_Event_Handler *eh = this->event_handler_i ();
+ if (eh)
+ eh->handle_close (ACE_INVALID_HANDLE,
+ ACE_Event_Handler::ALL_EVENTS_MASK);
// Purge the entry
this->orb_core_->transport_cache ().purge_entry (this->cache_map_entry_);
}
+
+ssize_t
+TAO_Transport::send (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *timeout,
+ size_t *bytes_transferred)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+
+ // if there's no associated event handler, then we act like a null transport
+ if (this->event_handler_i () == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) transport %d (tag=%d) send() ")
+ ACE_TEXT ("no longer associated with handler, returning -1 with errno = ENOENT\n"),
+ this->id (),
+ this->tag_));
+ errno = ENOENT;
+ return -1;
+ }
+
+ // now call the template method
+ return this->send_i (mblk, timeout, bytes_transferred);
+}
+
+ssize_t
+TAO_Transport::recv (char *buffer,
+ size_t len,
+ const ACE_Time_Value *timeout)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+
+ // if there's no associated event handler, then we act like a null transport
+ if (this->event_handler_i () == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) transport %d (tag=%d) recv() ")
+ ACE_TEXT ("no longer associated with handler, returning -1 with errno = ENOENT\n"),
+ this->id (),
+ this->tag_));
+ // @@CJC Should we return -1, like an error, or should we return 0, like an EOF?
+ errno = ENOENT;
+ return -1;
+ }
+
+ // now call the template method
+ return this->recv_i (buffer, len, timeout);
+}
+
+long
+TAO_Transport::register_for_timer_event (const void* arg,
+ const ACE_Time_Value &delay,
+ const ACE_Time_Value &interval)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+
+ ACE_Event_Handler *eh = this->event_handler_i ();
+ if (eh == 0)
+ return -1;
+
+ return this->orb_core_->reactor ()->schedule_timer (eh, arg, delay, interval);
+}
+
+int
+TAO_Transport::register_handler (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+ return this->register_handler_i ();
+}
+
+int
+TAO_Transport::id (void) const
+{
+ return this->id_;
+}
+
+void
+TAO_Transport::id (int id)
+{
+ this->id_ = id;
+}
+
diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h
index c318cc2d9b8..4feb9dccaed 100644
--- a/TAO/tao/Transport.h
+++ b/TAO/tao/Transport.h
@@ -201,9 +201,13 @@ public:
* If any data is to be sent it blocks until the queue is completely
* drained.
*
+ * This method serializes on handler_lock_, guaranteeing that only
+ * thread can execute it on the same instance concurrently.
+ *
* @todo: this routine will probably go away as part of the
* reorganization to support non-blocking writes.
*/
+ // @@ lockme
ssize_t send_or_buffer (TAO_Stub *stub,
int two_way,
const ACE_Message_Block *mblk,
@@ -228,6 +232,7 @@ public:
void buffering_timeout_value (const ACE_Time_Value &time);
/// Send any messages that have been buffered.
+ // @@ lockme
ssize_t send_buffered_messages (const ACE_Time_Value *max_wait_time = 0);
/**
@@ -242,6 +247,14 @@ public:
virtual int bidirectional_flag (void) const;
virtual void bidirectional_flag (int flag);
+ /// Fill in a handle_set with any associated handler's reactor handle.
+ /**
+ * Called by the cache when the cache is closing in order to fill
+ * in a handle_set in a lock-safe manner.
+ * @param handle_set the ACE_Handle_Set into which the transport should place any handle registered with the reactor
+ */
+ void provide_handle (ACE_Handle_Set &handle_set);
+
/// @@ Bala: you must document this function!!
/// @@ Bala: from the implementation in IIOP_Transport it looks more
// like it process the list of listening endpoints, or it is
@@ -254,6 +267,19 @@ public:
*/
void dequeue_all (void);
+ /// Register the handler with the reactor.
+ /**
+ * This method is used by the Wait_On_Reactor strategy. The
+ * transport must register its event handler with the ORB's Reactor.
+ *
+ * @todo: I think this method is pretty much useless, the
+ * connections are *always* registered with the Reactor, except in
+ * thread-per-connection mode. In that case putting the connection
+ * in the Reactor would produce unpredictable results anyway.
+ */
+ // @@ lockme
+ int register_handler (void);
+
/**
* @name Control connection lifecycle
*
@@ -270,8 +296,80 @@ public:
/// now.
virtual int idle_after_reply (void);
+ /// Call the corresponding connection handler's <close>
+ /// method.
+ virtual void close_connection (void);
+
//@}
+ /// Write the complete Message_Block chain to the connection.
+ /**
+ * This method serializes on handler_lock_, guaranteeing that only
+ * thread can execute it on the same instance concurrently.
+ *
+ * Often the implementation simply forwards the arguments to the
+ * underlying ACE_Svc_Handler class. Using the code factored out
+ * into ACE.
+ *
+ * Be careful with protocols that perform non-trivial
+ * transformations of the data, such as SSLIOP or protocols that
+ * compress the stream.
+ *
+ * @param mblk contains the data that must be sent. For each
+ * message block in the cont() chain all the data between rd_ptr()
+ * and wr_ptr() should be delivered to the remote peer.
+ *
+ * @param timeout is the maximum time that the application is
+ * willing to wait for the data to be sent, useful in platforms that
+ * implement timed writes.
+ * The timeout value is obtained from the policies set by the
+ * application.
+ *
+ * @param bytes_transferred should return the total number of bytes
+ * successfully transferred before the connection blocked. This is
+ * required because in some platforms and/or protocols multiple
+ * system calls may be required to send the chain of message
+ * blocks. The first few calls can work successfully, but the final
+ * one can fail or signal a flow control situation (via EAGAIN).
+ * In this case the ORB expects the function to return -1, errno to
+ * be appropriately set and this argument to return the number of
+ * bytes already on the OS I/O subsystem.
+ *
+ * This call can also fail if the transport instance is no longer
+ * associated with a connection (e.g., the connection handler closed
+ * down). In that case, it returns -1 and sets errno to
+ * <code>ENOENT</code>.
+ */
+ ssize_t send (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0);
+
+ /// Read len bytes from into buf.
+ /**
+ * This method serializes on handler_lock_, guaranteeing that only
+ * thread can execute it on the same instance concurrently.
+ *
+ * @param buffer ORB allocated buffer where the data should be
+ * @@ The ACE_Time_Value *s is just a place holder for now. It is
+ * not clear this this is the best place to specify this. The actual
+ * timeout values will be kept in the Policies.
+ */
+ ssize_t recv (char *buffer,
+ size_t len,
+ const ACE_Time_Value *timeout = 0);
+
+
+ /// Return the identifier for this transport instance.
+ /**
+ * If not set, this will return an integer representation of
+ * the <code>this</code> pointer for the instance on which
+ * it's called.
+ */
+ int id (void) const;
+ /// Set the identifier for this transport instance.
+ void id (int id);
+
+protected:
/** @name Template methods
*
* The Transport class uses the Template Method Pattern to implement
@@ -281,22 +379,6 @@ public:
*/
//@{
- /// Call the corresponding connection handler's <close>
- /// method.
- virtual void close_connection (void);
-
- /// Return the file descriptor used for this connection.
- /**
- * @todo Someday we should be able to support protocols that do not
- * have or use file descriptors. But this will require implementing
- * non-reactive concurrency models for some connections. Really
- * hard to do. Meanwhile, look at the SHMIOP protocol for an
- * example on how to use file descriptors for signalling while the
- * actual data is transfer via shared memory (where there are no
- * file descriptors.)
- */
- virtual ACE_HANDLE handle (void) = 0;
-
/// Return the event handler used to receive notifications from the
/// Reactor.
/**
@@ -312,7 +394,9 @@ public:
* will reduce footprint and simplify the process of implementing a
* pluggable protocol.
*/
- virtual ACE_Event_Handler *event_handler (void) = 0;
+ // @@ this is broken once we add the lock b/c it returns the thing
+ // we're trying to lock down! (CJC)
+ virtual ACE_Event_Handler *event_handler_i (void) = 0;
/// Write the complete Message_Block chain to the connection.
/**
@@ -345,9 +429,9 @@ public:
* bytes already on the OS I/O subsystem.
*
*/
- virtual ssize_t send (const ACE_Message_Block *mblk,
- const ACE_Time_Value *timeout = 0,
- size_t *bytes_transferred = 0) = 0;
+ virtual ssize_t send_i (const ACE_Message_Block *mblk,
+ const ACE_Time_Value *timeout = 0,
+ size_t *bytes_transferred = 0) = 0;
// Read len bytes from into buf.
/**
@@ -356,15 +440,17 @@ public:
* not clear this this is the best place to specify this. The actual
* timeout values will be kept in the Policies.
*/
- virtual ssize_t recv (char *buffer,
- size_t len,
- const ACE_Time_Value *timeout = 0) = 0;
+ virtual ssize_t recv_i (char *buffer,
+ size_t len,
+ const ACE_Time_Value *timeout = 0) = 0;
+public:
/// Fill into <output> the right headers to make a request.
/**
* @todo Bala: in the good old days it was decided that the
* pluggable protocol framework would not raise exceptions.
*/
+ // @nolock
virtual void start_request (TAO_ORB_Core *orb_core,
TAO_Target_Specification &spec,
TAO_OutputCDR &output,
@@ -377,6 +463,7 @@ public:
* @todo Bala: in the good old days it was decided that the
* pluggable protocol framework would not raise exceptions.
*/
+ // @@nolock
virtual void start_locate (TAO_ORB_Core *orb_core,
TAO_Target_Specification &spec,
TAO_Operation_Details &opdetails,
@@ -410,6 +497,7 @@ public:
* @todo This is generic code, it should be factored out into the
* Transport class.
*/
+ // @nolock b/c this calls send_or_buffer
virtual int send_request (TAO_Stub *stub,
TAO_ORB_Core *orb_core,
TAO_OutputCDR &stream,
@@ -439,6 +527,7 @@ public:
*
* @todo Another generic method, move to TAO_Transport.
*/
+ // @@ lockme
virtual int send_message (TAO_OutputCDR &stream,
TAO_Stub *stub = 0,
int twoway = 1,
@@ -463,9 +552,11 @@ public:
* @param block Is deprecated and ignored.
*
*/
+ // @@ lockme
virtual int read_process_message (ACE_Time_Value *max_wait_time = 0,
int block = 0) = 0;
+protected:
/// Register the handler with the reactor.
/**
* This method is used by the Wait_On_Reactor strategy. The
@@ -476,8 +567,20 @@ public:
* thread-per-connection mode. In that case putting the connection
* in the Reactor would produce unpredictable results anyway.
*/
- virtual int register_handler (void) = 0;
+ // @@ lockme
+ virtual int register_handler_i (void) = 0;
+ /// Called by <code>connection_handler_closing()</code> to signal
+ /// that the protocol-specific transport should dissociate itself
+ /// with the protocol-specific connection handler.
+ /**
+ * Typically, this just sets the pointer to the associated connection
+ * handler to zero, although it could also clear out any additional
+ * resources associated with the handler association.
+ */
+ virtual void transition_handler_state_i (void) = 0;
+
+public:
/// Indicates whether the reactor is used by the protocol for
/// signalling.
/**
@@ -491,10 +594,27 @@ public:
/// Method for the connection handler to signify that it
/// is being closed and destroyed.
virtual void connection_handler_closing (void);
- virtual void transition_handler_state (void) = 0;
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ /// Register the associated connection handler with the reactor
+ /// for a timer.
+ /**
+ * At this point, only <code>TAO_Eager_Buffering_Sync_Strategy::timer_check()</code>
+ * uses this, and it's unclear whether it needs to stay around. But, it's here
+ * because it uses the associated protocol-specific connection handler, and accesses
+ * to that must be serialized on the internal lock.
+ *
+ * @param arg argument passed to the handle_timeout() method of the event handler
+ * @param delay time interval after which the timer will expire
+ * @param interval time interval after which the timer will be automatically rescheduled
+ * @return -1 on failure, a Reactor timer_id value on success
+ *
+ * @see ACE_Reactor::schedule_timer()
+ * @see TAO_Eager_Buffering_Sync_Strategy::timer_check()
+ */
+ long register_for_timer_event (const void* arg,
+ const ACE_Time_Value &delay,
+ const ACE_Time_Value &interval = ACE_Time_Value::zero);
+
// Maintain reference counting with these
static TAO_Transport* _duplicate (TAO_Transport* transport);
@@ -514,6 +634,7 @@ public:
int make_idle (void);
protected:
+ // @@ see if one of these calls send_message()
/// Remove the first message from the outgoing queue.
void dequeue_head (void);
@@ -531,6 +652,7 @@ protected:
void reset_message (ACE_Message_Block *message_block,
size_t bytes_delivered,
int queued_message);
+
private:
/// Prohibited
ACE_UNIMPLEMENTED_FUNC (TAO_Transport (const TAO_Transport&))
@@ -584,6 +706,28 @@ protected:
* if the server receives the info.
*/
int bidirectional_flag_;
+
+ /// Lock that insures that activities that *might* use handler-related
+ /// resources (such as a connection handler) get serialized.
+ /**
+ * This is an <code>ACE_Lock</code> that gets initialized from
+ * <code>TAO_ORB_Core::resource_factory()->create_cached_connection_lock ()</code>.
+ * This way, one can use a lock appropriate for the type of system, i.e.,
+ * a null lock for single-threaded systems, and a real lock for
+ * multi-threaded systems.
+ */
+ ACE_Lock *handler_lock_;
+
+ /// A unique identifier for the transport.
+ /**
+ * This never *never*
+ * changes over the lifespan, so we don't have to worry
+ * about locking it.
+ *
+ * HINT: Protocol-specific transports that use connection handler
+ * might choose to set this to the handle for their connection.
+ */
+ int id_;
};
#if defined (__ACE_INLINE__)
diff --git a/TAO/tao/Transport_Cache_Manager.cpp b/TAO/tao/Transport_Cache_Manager.cpp
index 9e2e289082c..a8dd4aa2c16 100644
--- a/TAO/tao/Transport_Cache_Manager.cpp
+++ b/TAO/tao/Transport_Cache_Manager.cpp
@@ -110,6 +110,12 @@ int
TAO_Transport_Cache_Manager::find_transport (TAO_Transport_Descriptor_Interface *prop,
TAO_Transport *&transport)
{
+ if (prop == 0)
+ {
+ transport = 0;
+ return -1;
+ }
+
// Compose the ExternId
TAO_Cache_ExtId ext_id (prop);
TAO_Cache_IntId int_id;
@@ -184,7 +190,7 @@ TAO_Transport_Cache_Manager::find_i (const TAO_Cache_ExtId &key,
int
TAO_Transport_Cache_Manager::rebind_i (const TAO_Cache_ExtId &key,
- const TAO_Cache_IntId &value)
+ const TAO_Cache_IntId &value)
{
return this->cache_map_.rebind (key,
value);
@@ -192,7 +198,7 @@ TAO_Transport_Cache_Manager::rebind_i (const TAO_Cache_ExtId &key,
int
TAO_Transport_Cache_Manager::trybind_i (const TAO_Cache_ExtId &key,
- TAO_Cache_IntId &value)
+ TAO_Cache_IntId &value)
{
return this->cache_map_.trybind (key, value);
}
@@ -205,7 +211,7 @@ TAO_Transport_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key)
int
TAO_Transport_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key,
- TAO_Cache_IntId &value)
+ TAO_Cache_IntId &value)
{
return this->cache_map_.unbind (key,
value);
@@ -214,7 +220,9 @@ TAO_Transport_Cache_Manager::unbind_i (const TAO_Cache_ExtId &key,
int
TAO_Transport_Cache_Manager::make_idle_i (HASH_MAP_ENTRY *&entry)
{
-
+ if (entry == 0)
+ return -1;
+
// First get the entry again (if at all things had changed in the
// cache map in the mean time)
HASH_MAP_ENTRY *new_entry = 0;
@@ -240,7 +248,7 @@ TAO_Transport_Cache_Manager::make_idle_i (HASH_MAP_ENTRY *&entry)
int
-TAO_Transport_Cache_Manager::close_i (ACE_Handle_Set & /*handle_set*/)
+TAO_Transport_Cache_Manager::close_i (ACE_Handle_Set &handle_set)
{
for (HASH_MAP_ITER iter = this->cache_map_.begin ();
iter != this->cache_map_.end ();
@@ -251,6 +259,22 @@ TAO_Transport_Cache_Manager::close_i (ACE_Handle_Set & /*handle_set*/)
if ((*iter).int_id_.recycle_state () != ACE_RECYCLABLE_CLOSED)
{
+#if 0
+ // @@ This code from Connection_Cache_Manager disappeared
+ // during the changeover; we need the functional equivalent back.
+ // The problem is that with the locking stuff that we're putting
+ // in to the Transport, we might want to encapsulate the whole
+ // exercise of adding to the handle set in a method on the transport
+ // rather than doing it here. That way, the locking is correct.
+ if ((*iter).int_id_.handler ()->is_registered ())
+ {
+ handle_set.set_bit ((*iter).int_id_.handler ()->fetch_handle ());
+ }
+#else
+ // Get the transport to fill its associated connection's handle in
+ // the handle_set.
+ (*iter).int_id_.transport ()->provide_handle (handle_set);
+#endif
// Inform the transport that has a reference to the entry in the
// map that we are *gone* now. So, the transport should not use
// the reference to the entry that he has, to acces us *at any
@@ -296,10 +320,9 @@ TAO_Transport_Cache_Manager::mark_invalid_i (HASH_MAP_ENTRY *&entry)
int
-TAO_Transport_Cache_Manager::
- get_last_index_bind (TAO_Cache_ExtId &key,
- TAO_Cache_IntId &val,
- HASH_MAP_ENTRY *&entry)
+TAO_Transport_Cache_Manager::get_last_index_bind (TAO_Cache_ExtId &key,
+ TAO_Cache_IntId &val,
+ HASH_MAP_ENTRY *&entry)
{
CORBA::ULong ctr = entry->ext_id_.index ();
@@ -324,8 +347,7 @@ TAO_Transport_Cache_Manager::
int
-TAO_Transport_Cache_Manager::
- is_entry_idle (HASH_MAP_ENTRY *&entry)
+TAO_Transport_Cache_Manager::is_entry_idle (HASH_MAP_ENTRY *&entry)
{
if (entry->int_id_.recycle_state () == ACE_RECYCLABLE_IDLE_AND_PURGABLE ||
entry->int_id_.recycle_state () == ACE_RECYCLABLE_IDLE_BUT_NOT_PURGABLE)