summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>2001-03-23 18:03:42 +0000
committerChris Cleeland <chris.cleeland@gmail.com>2001-03-23 18:03:42 +0000
commitc2b63a1dedf25171b83136b7d33a6ab4acd56cec (patch)
tree3506a79bb65f7388fe1d610c101e5452c099c942
parentba847e557fa9c4d5929ab7dfea0555b6d83d1486 (diff)
downloadATCD-c2b63a1dedf25171b83136b7d33a6ab4acd56cec.tar.gz
Commit so that Carlos and others can take a look at the code.
-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.cpp4
-rw-r--r--TAO/tao/IIOP_Connector.cpp6
-rw-r--r--TAO/tao/IIOP_Transport.cpp52
-rw-r--r--TAO/tao/IIOP_Transport.h56
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connector.cpp2
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.cpp48
-rw-r--r--TAO/tao/Strategies/SHMIOP_Transport.h38
-rw-r--r--TAO/tao/Strategies/UIOP_Connector.cpp2
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.cpp52
-rw-r--r--TAO/tao/Strategies/UIOP_Transport.h38
-rw-r--r--TAO/tao/Sync_Strategies.cpp8
-rw-r--r--TAO/tao/Transport.cpp161
-rw-r--r--TAO/tao/Transport.h191
-rw-r--r--TAO/tao/Transport_Cache_Manager.cpp44
16 files changed, 557 insertions, 178 deletions
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..34600301bbd 100644
--- a/TAO/tao/GIOP_Utils.cpp
+++ b/TAO/tao/GIOP_Utils.cpp
@@ -57,10 +57,10 @@ TAO_GIOP_Utils::read_buffer (TAO_Transport *transport,
if (bytes_read <= 0 && TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t|%N|%l) - %p,\n")
- ACE_TEXT (" transport = %d, ")
+ ACE_TEXT (" transport = %lu, ")
ACE_TEXT ("bytes = %d, len = %d\n"),
ACE_TEXT ("read_buffer"),
- transport->handle (),
+ transport->id (),
bytes_read,
len));
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index bf016deaee9..4f05995a7b7 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -164,6 +164,11 @@ TAO_IIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
if (this->orb_core ()->transport_cache ().find_transport (desc,
base_transport) == 0)
{
+#if 0
+ // @@CJC
+ // Seems that the only reason we have the call to connection_handler is
+ // to print out the debug message. Yucko! We can ditch it, hopefully.
+
// We have found a connection and a transport
svc_handler =
ACE_dynamic_cast (TAO_IIOP_Connection_Handler *,
@@ -173,6 +178,7 @@ TAO_IIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
ACE_TEXT ("(%P|%t) IIOP_Connector::connect - ")
ACE_TEXT ("got an existing connection on HANDLE %d\n"),
svc_handler->peer ().get_handle ()));
+#endif
}
else
{
diff --git a/TAO/tao/IIOP_Transport.cpp b/TAO/tao/IIOP_Transport.cpp
index a86c84819b4..9605f6618ef 100644
--- a/TAO/tao/IIOP_Transport.cpp
+++ b/TAO/tao/IIOP_Transport.cpp
@@ -32,6 +32,10 @@ TAO_IIOP_Transport::TAO_IIOP_Transport (TAO_IIOP_Connection_Handler *handler,
, connection_handler_ (handler)
, messaging_object_ (0)
{
+ // We'll set the id_ (from TAO_Transport) to the handle from our connection
+ if (connection_handler_ != 0)
+ this->id_ = ACE_static_cast (int, this->connection_handler_->get_handle ());
+
if (flag)
{
// Use the lite version of the protocol
@@ -51,43 +55,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 +127,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 +191,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 +204,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 +389,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 +562,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..419c6481fa0 100644
--- a/TAO/tao/IIOP_Transport.h
+++ b/TAO/tao/IIOP_Transport.h
@@ -61,25 +61,11 @@ public:
/// Default destructor.
~TAO_IIOP_Transport (void);
- /// Return the connection service handler
- TAO_IIOP_SVC_HANDLER *service_handler (void);
-
+#if 0
/// 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);
-
- /// 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);
-
-
- /// Read len bytes from into buf.
- virtual ssize_t recv (char *buf,
- size_t len,
- const ACE_Time_Value *s = 0);
+#endif
/// Read and process the message from the connection. The processing
/// of the message is done by delegating the work to the underlying
@@ -87,8 +73,6 @@ public:
virtual int read_process_message (ACE_Time_Value *max_time_value = 0,
int block =0);
- virtual int register_handler (void);
-
/// @@TODO: These methods IMHO should have more meaningful
/// names. The names seem to indicate nothing.
virtual int send_request (TAO_Stub *stub,
@@ -116,10 +100,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 +111,35 @@ public:
/// Open the service context list and process it.
virtual int tear_listen_point_list (TAO_InputCDR &cdr);
+protected:
/// Method to do whatever it needs to do when the connection
/// handler is being closed and destroyed.
- virtual void transition_handler_state (void);
+ virtual void transition_handler_state_i (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.
+ /// 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);
+
- // Access the connection handler
- virtual TAO_Connection_Handler* connection_handler (void) const;
+ /// Read len bytes from into buf.
+ /// Must be called with transport's lock held.
+ virtual ssize_t recv_i (char *buf,
+ size_t len,
+ const ACE_Time_Value *s = 0);
+
+ virtual int register_handler_i (void);
+
+#if 0
+ /// Access the connection handler as <code>TAO_Connection_Handler</code>.
+ /// Must be called with transport's lock held.
+ virtual TAO_Connection_Handler* connection_handler_i (void) const;
+#endif
private:
diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp
index c8e4c3ad189..4972f4505fe 100644
--- a/TAO/tao/Strategies/SHMIOP_Connector.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp
@@ -160,10 +160,12 @@ TAO_SHMIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ")
ACE_TEXT ("got an existing connection \n")));
+#if 0
// We have found a connection and a handler
svc_handler =
ACE_dynamic_cast (TAO_SHMIOP_Connection_Handler *,
base_transport->connection_handler ());
+#endif
}
else
{
diff --git a/TAO/tao/Strategies/SHMIOP_Transport.cpp b/TAO/tao/Strategies/SHMIOP_Transport.cpp
index bb39b601bb8..3ae9fd256ff 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Transport.cpp
@@ -36,6 +36,10 @@ TAO_SHMIOP_Transport::TAO_SHMIOP_Transport (TAO_SHMIOP_Connection_Handler *handl
connection_handler_ (handler),
messaging_object_ (0)
{
+ // We'll set the id_ (from TAO_Transport) to the handle from our connection
+ if (connection_handler_ != 0)
+ this->id_ = ACE_static_cast (int, this->connection_handler_->get_handle ());
+
if (flag)
{
// Use the lite version of the protocol
@@ -55,6 +59,7 @@ TAO_SHMIOP_Transport::~TAO_SHMIOP_Transport (void)
delete this->messaging_object_;
}
+#if 0
TAO_SHMIOP_SVC_HANDLER *
TAO_SHMIOP_Transport::service_handler (void)
{
@@ -66,30 +71,31 @@ TAO_SHMIOP_Transport::handle (void)
{
return this->connection_handler_->get_handle ();
}
+#endif
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 +135,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 +199,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 +212,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 +361,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 +399,17 @@ 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;
}
+#if 0
TAO_Connection_Handler*
TAO_SHMIOP_Transport::connection_handler (void) const
{
return connection_handler_;
}
+#endif
#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..9e17ce40a51 100644
--- a/TAO/tao/Strategies/SHMIOP_Transport.h
+++ b/TAO/tao/Strategies/SHMIOP_Transport.h
@@ -55,24 +55,33 @@ public:
/// Default destructor.
~TAO_SHMIOP_Transport (void);
+#if 0
/// Return the connection service handler
TAO_SHMIOP_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
@@ -80,8 +89,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,12 +136,12 @@ 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);
-
+#if 0
// Access the connection handler
virtual TAO_Connection_Handler* connection_handler (void) const;
+#endif
+
+ //@}
private:
diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp
index b07795db20f..a7be91097bf 100644
--- a/TAO/tao/Strategies/UIOP_Connector.cpp
+++ b/TAO/tao/Strategies/UIOP_Connector.cpp
@@ -167,10 +167,12 @@ TAO_UIOP_Connector::connect (TAO_Transport_Descriptor_Interface *desc,
ACE_TEXT ("(%P|%t) UIOP_Connector::connect ")
ACE_TEXT ("got an existing connection \n")));
+#if 0
// We have found a connection and a handler
svc_handler =
ACE_dynamic_cast (TAO_UIOP_Connection_Handler *,
base_transport->connection_handler ());
+#endif
}
else
{
diff --git a/TAO/tao/Strategies/UIOP_Transport.cpp b/TAO/tao/Strategies/UIOP_Transport.cpp
index 29f67574369..fb5aa9f8c13 100644
--- a/TAO/tao/Strategies/UIOP_Transport.cpp
+++ b/TAO/tao/Strategies/UIOP_Transport.cpp
@@ -32,10 +32,14 @@ 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)
{
+ // We'll set the id_ (from TAO_Transport) to the handle from our connection
+ if (connection_handler_ != 0)
+ this->id_ = ACE_static_cast (int, this->connection_handler_->get_handle ());
+
if (flag)
{
// Use the lite version of the protocol
@@ -55,6 +59,7 @@ TAO_UIOP_Transport::~TAO_UIOP_Transport (void)
delete this->messaging_object_;
}
+#if 0
TAO_UIOP_SVC_HANDLER *
TAO_UIOP_Transport::service_handler (void)
{
@@ -66,32 +71,33 @@ TAO_UIOP_Transport::handle (void)
{
return this->connection_handler_->get_handle ();
}
+#endif
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 +136,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 +200,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 +213,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 +356,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 +393,17 @@ 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;
}
+#if 0
TAO_Connection_Handler*
TAO_UIOP_Transport::connection_handler (void) const
{
return connection_handler_;
}
+#endif
#endif /* TAO_HAS_UIOP */
diff --git a/TAO/tao/Strategies/UIOP_Transport.h b/TAO/tao/Strategies/UIOP_Transport.h
index b9b9b172fc1..ca850a497b1 100644
--- a/TAO/tao/Strategies/UIOP_Transport.h
+++ b/TAO/tao/Strategies/UIOP_Transport.h
@@ -60,24 +60,33 @@ public:
/// Default destructor.
~TAO_UIOP_Transport (void);
+#if 0
/// Return the connection service handler
TAO_UIOP_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
@@ -85,8 +94,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 +137,12 @@ 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);
-
+#if 0
// Access the connection handler
virtual TAO_Connection_Handler* connection_handler (void) const;
+#endif
+
+ //@}
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..f1863fe3f8f 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,13 @@ TAO_Transport::send_or_buffer (TAO_Stub *stub,
const ACE_Message_Block *message_block,
const ACE_Time_Value *max_wait_time)
{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Lock,
+ guard,
+ *this->handler_lock_,
+ -1));
+
if (stub == 0 || two_way)
- return this->send (message_block, max_wait_time);
+ return this->send_i (message_block, max_wait_time);
TAO_Sync_Strategy &sync_strategy = stub->sync_strategy ();
@@ -96,6 +108,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 +128,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 +145,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 +299,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 +387,103 @@ 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)
+{
+ return this->id_;
+}
diff --git a/TAO/tao/Transport.h b/TAO/tao/Transport.h
index c318cc2d9b8..c8b9137ff9f 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,77 @@ 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 a unique identifier for this transport instance.
+ /**
+ * It's established at construction, and not changed throughout the life
+ * of a transport.
+ */
+ virtual int id (void);
+
+protected:
/** @name Template methods
*
* The Transport class uses the Template Method Pattern to implement
@@ -281,10 +376,7 @@ public:
*/
//@{
- /// Call the corresponding connection handler's <close>
- /// method.
- virtual void close_connection (void);
-
+#if 0
/// Return the file descriptor used for this connection.
/**
* @todo Someday we should be able to support protocols that do not
@@ -296,6 +388,7 @@ public:
* file descriptors.)
*/
virtual ACE_HANDLE handle (void) = 0;
+#endif
/// Return the event handler used to receive notifications from the
/// Reactor.
@@ -312,7 +405,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 +440,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 +451,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 +474,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 +508,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 +538,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 +563,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 +578,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 +605,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 +645,13 @@ public:
int make_idle (void);
protected:
+#if 0
+ // Access the connection handler
+ // @@CJC Do we still need this?!
+ virtual TAO_Connection_Handler* connection_handler_i (void) const;
+#endif
+
+ // @@ see if one of these calls send_message()
/// Remove the first message from the outgoing queue.
void dequeue_head (void);
@@ -531,6 +669,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 +723,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)