summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>1999-12-25 23:01:28 +0000
committerbala <balanatarajan@users.noreply.github.com>1999-12-25 23:01:28 +0000
commit477a5f4211f7bba766450f25e1ff579869a29ffc (patch)
treea578aeb5a3fe9a89ad481549c3c884c69efdcadc
parente2bfebbd6f1696703b8a7793552347356b710b67 (diff)
downloadATCD-477a5f4211f7bba766450f25e1ff579869a29ffc.tar.gz
rking version
-rw-r--r--TAO/tao/Acceptor_Registry.cpp1
-rw-r--r--TAO/tao/Asynch_Invocation.cpp2
-rw-r--r--TAO/tao/Connector_Registry.cpp1
-rw-r--r--TAO/tao/GIOPC.cpp111
-rw-r--r--TAO/tao/GIOP_Accept_State.cpp753
-rw-r--r--TAO/tao/GIOP_Acceptors.cpp162
-rw-r--r--TAO/tao/GIOP_Message_Factory.cpp446
-rw-r--r--TAO/tao/GIOP_Message_Invocation.cpp212
-rw-r--r--TAO/tao/GIOP_Server_Request.cpp174
-rw-r--r--TAO/tao/GIOP_Utils.cpp251
-rw-r--r--TAO/tao/IIOP_Acceptor.cpp1
-rw-r--r--TAO/tao/IIOP_Connect.cpp26
-rw-r--r--TAO/tao/IIOP_Connector.cpp1
-rw-r--r--TAO/tao/IIOP_Profile.cpp1
-rw-r--r--TAO/tao/IIOP_Transport.cpp142
-rw-r--r--TAO/tao/Invocation.cpp7
-rw-r--r--TAO/tao/ORB.cpp1
-rw-r--r--TAO/tao/Object.cpp1
-rw-r--r--TAO/tao/Pluggable.cpp6
-rw-r--r--TAO/tao/Pluggable_Messaging.cpp21
-rw-r--r--TAO/tao/Request.cpp2
-rw-r--r--TAO/tao/Stub.cpp1
-rw-r--r--TAO/tao/Typecode_Constants.cpp2
-rw-r--r--TAO/tao/UIOP_Acceptor.cpp1
-rw-r--r--TAO/tao/UIOP_Connect.cpp33
-rw-r--r--TAO/tao/UIOP_Connector.cpp1
-rw-r--r--TAO/tao/UIOP_Profile.cpp1
-rw-r--r--TAO/tao/UIOP_Transport.cpp135
-rw-r--r--TAO/tao/append.cpp1
-rw-r--r--TAO/tao/decode.cpp1
-rw-r--r--TAO/tao/skip.cpp1
31 files changed, 1910 insertions, 589 deletions
diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp
index 67303f84643..aee7db88431 100644
--- a/TAO/tao/Acceptor_Registry.cpp
+++ b/TAO/tao/Acceptor_Registry.cpp
@@ -4,7 +4,6 @@
#include "tao/Acceptor_Registry.h"
#include "tao/Stub.h"
#include "tao/Environment.h"
-#include "tao/GIOP.h"
#include "tao/ORB_Core.h"
#include "tao/params.h"
#include "tao/MProfile.h"
diff --git a/TAO/tao/Asynch_Invocation.cpp b/TAO/tao/Asynch_Invocation.cpp
index f1a3eff31aa..bc8b14430b7 100644
--- a/TAO/tao/Asynch_Invocation.cpp
+++ b/TAO/tao/Asynch_Invocation.cpp
@@ -121,7 +121,7 @@ TAO_GIOP_DII_Deferred_Invocation::start (CORBA::Environment &ACE_TRY_ENV)
ACE_CHECK;
this->transport_->start_request (this->orb_core_,
- this->profile_,
+ this->stub_,
this->out_stream_,
ACE_TRY_ENV);
ACE_CHECK;
diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp
index d6641607364..dcc307b4515 100644
--- a/TAO/tao/Connector_Registry.cpp
+++ b/TAO/tao/Connector_Registry.cpp
@@ -5,7 +5,6 @@
#include "tao/Connector_Registry.h"
#include "tao/Stub.h"
#include "tao/Environment.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
TAO_Connector_Registry::TAO_Connector_Registry (void)
diff --git a/TAO/tao/GIOPC.cpp b/TAO/tao/GIOPC.cpp
index 6fd506855ab..2e950c43030 100644
--- a/TAO/tao/GIOPC.cpp
+++ b/TAO/tao/GIOPC.cpp
@@ -109,48 +109,6 @@ TAO_NAMESPACE_BEGIN (GIOP)
TAO_NAMESPACE_DEFINE (CORBA::TypeCode_ptr, _tc_IORAddressingInfo, &_tc_TAO_tc_GIOP_IORAddressingInfo)
TAO_NAMESPACE_END
-#if !defined (_GIOP_TARGETADDRESS__TAO_SEQ_OCTET_CS_)
-#define _GIOP_TARGETADDRESS__TAO_SEQ_OCTET_CS_
-
-// *************************************************************
-// GIOP::TargetAddress::_tao_seq_Octet
-// *************************************************************
-
-GIOP::TargetAddress::_tao_seq_Octet::_tao_seq_Octet (void)
-{}
-GIOP::TargetAddress::_tao_seq_Octet::_tao_seq_Octet (CORBA::ULong max) // uses max size
- :
-#if !defined (TAO_USE_SEQUENCE_TEMPLATES)
- TAO_Unbounded_Sequence<CORBA::Octet>
-#else /* TAO_USE_SEQUENCE_TEMPLATES */
- TAO_Unbounded_Sequence<CORBA::Octet>
-#endif /* !TAO_USE_SEQUENCE_TEMPLATES */
- (max)
-{}
-GIOP::TargetAddress::_tao_seq_Octet::_tao_seq_Octet (CORBA::ULong max, CORBA::ULong length, CORBA::Octet *buffer, CORBA::Boolean release)
- :
-#if !defined (TAO_USE_SEQUENCE_TEMPLATES)
- TAO_Unbounded_Sequence<CORBA::Octet>
-#else /* TAO_USE_SEQUENCE_TEMPLATES */
- TAO_Unbounded_Sequence<CORBA::Octet>
-#endif /* !TAO_USE_SEQUENCE_TEMPLATES */
- (max, length, buffer, release)
-{}
-GIOP::TargetAddress::_tao_seq_Octet::_tao_seq_Octet (const _tao_seq_Octet &seq) // copy ctor
- :
-#if !defined (TAO_USE_SEQUENCE_TEMPLATES)
- TAO_Unbounded_Sequence<CORBA::Octet>
-#else /* TAO_USE_SEQUENCE_TEMPLATES */
- TAO_Unbounded_Sequence<CORBA::Octet>
-#endif /* !TAO_USE_SEQUENCE_TEMPLATES */
- (seq)
-{}
-GIOP::TargetAddress::_tao_seq_Octet::~_tao_seq_Octet (void) // dtor
-{}
-
-
-#endif /* end #if !defined */
-
// *************************************************************
// Operations for union GIOP::TargetAddress
// *************************************************************
@@ -174,7 +132,7 @@ GIOP::TargetAddress::TargetAddress (const GIOP::TargetAddress &u)
{
ACE_NEW (
this->u_.object_key_,
- GIOP::TargetAddress::_tao_seq_Octet (*u.u_.object_key_)
+ TAO_ObjectKey (*u.u_.object_key_)
);
}
break;
@@ -211,7 +169,7 @@ GIOP::TargetAddress::operator= (const GIOP::TargetAddress &u)
{
ACE_NEW_RETURN (
this->u_.object_key_,
- GIOP::TargetAddress::_tao_seq_Octet (*u.u_.object_key_),
+ TAO_ObjectKey (*u.u_.object_key_),
*this
);
}
@@ -269,7 +227,7 @@ void *GIOP::TargetAddress::_access (CORBA::Boolean alloc_flag)
{
case 0:
if (alloc_flag)
- ACE_NEW_RETURN (this->u_.object_key_, GIOP::TargetAddress::_tao_seq_Octet, 0);
+ ACE_NEW_RETURN (this->u_.object_key_, TAO_ObjectKey, 0);
return this->u_.object_key_;
case 1:
if (alloc_flag)
@@ -543,68 +501,5 @@ CORBA::Boolean operator>>= (
return 0;
}
-#if !defined _TAO_CDR_OP_GIOP_TargetAddress__tao_seq_Octet_CPP_
-#define _TAO_CDR_OP_GIOP_TargetAddress__tao_seq_Octet_CPP_
-
-CORBA::Boolean operator<< (
- TAO_OutputCDR &strm,
- const GIOP::TargetAddress::_tao_seq_Octet &_tao_sequence
- )
-{
- if (strm << _tao_sequence.length ())
- {
- // encode all elements
-
-#if defined (TAO_NO_COPY_OCTET_SEQUENCES)
- {
- TAO_Unbounded_Sequence<CORBA::Octet> *oseq =
- ACE_static_cast (TAO_Unbounded_Sequence<CORBA::Octet>*, (GIOP::TargetAddress::_tao_seq_Octet *)&_tao_sequence);
- if (oseq->mb ())
- return strm.write_octet_array_mb (oseq->mb ());
- else
- return strm.write_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
- }
-
-#else /* TAO_NO_COPY_OCTET_SEQUENCES */
- return strm.write_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
-
-#endif /* TAO_NO_COPY_OCTET_SEQUENCES */
- }
- return 0; // error
-}
-
-CORBA::Boolean operator>> (
- TAO_InputCDR &strm,
- GIOP::TargetAddress::_tao_seq_Octet &_tao_sequence
- )
-{
- CORBA::ULong _tao_seq_len;
- if (strm >> _tao_seq_len)
- {
- // set the length of the sequence
- _tao_sequence.length (_tao_seq_len);
- // retrieve all the elements
-
-#if defined (TAO_NO_COPY_OCTET_SEQUENCES)
- if (ACE_BIT_DISABLED (strm.start ()->flags (),ACE_Message_Block::DONT_DELETE))
- {
- TAO_Unbounded_Sequence<CORBA::Octet> *oseq =
- ACE_static_cast(TAO_Unbounded_Sequence<CORBA::Octet>*, &_tao_sequence);
- oseq->replace (_tao_seq_len, strm.start ());
- oseq->mb ()->wr_ptr (oseq->mb()->rd_ptr () + _tao_seq_len);
- strm.skip_bytes (_tao_seq_len);
- return 1;
- }
- else
- return strm.read_octet_array (_tao_sequence.get_buffer (), _tao_seq_len);
-
-#else /* TAO_NO_COPY_OCTET_SEQUENCES */
- return strm.read_octet_array (_tao_sequence.get_buffer (), _tao_sequence.length ());
-
-#endif /* TAO_NO_COPY_OCTET_SEQUENCES */
- }
- return 0; // error
-}
-#endif /* _TAO_CDR_OP_GIOP_TargetAddress__tao_seq_Octet_CPP_ */
diff --git a/TAO/tao/GIOP_Accept_State.cpp b/TAO/tao/GIOP_Accept_State.cpp
new file mode 100644
index 00000000000..381fa80aeae
--- /dev/null
+++ b/TAO/tao/GIOP_Accept_State.cpp
@@ -0,0 +1,753 @@
+//$Id$
+#include "tao/debug.h"
+#include "tao/GIOP_Accept_State.h"
+#include "tao/GIOP_Server_Request.h"
+#include "tao/POA.h"
+#include "tao/ORB_Core.h"
+//#include "tao/GIOP_Assorted_Headers.h"
+
+#if !defined (__ACE_INLINE__)
+# include "tao/GIOP_Accept_State.i"
+#endif /* __ACE_INLINE__ */
+
+int
+TAO_GIOP_Accept_State::parse_header (TAO_GIOP_Message_State *state)
+{
+ if (TAO_GIOP_Utils::parse_giop_header (state,
+ state->cdr) == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N|%l) Error in parsing headers \n"),
+ -1);
+ }
+ return -1;
+ }
+
+ if (state->cdr.grow (this->header_length () +
+ state->message_size) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP::handle_input, ACE_CDR::grow"));
+ return -1;
+ }
+
+ // Growing the buffer may have reset the rd_ptr(), but we want
+ // to leave it just after the GIOP header (that was parsed
+ // already);
+ state->cdr.skip_bytes (this->header_length ());
+
+ return 1;
+}
+
+
+// Server sends an "I'm shutting down now, any requests you've sent me
+// can be retried" message to the server. The message is prefab, for
+// simplicity.
+//
+// NOTE: this is IIOP-specific though it doesn't look like it is. It
+// relies on a TCP-ism: orderly disconnect, which doesn't exist in all
+// transport protocols. Versions of GIOP atop some transport that's
+// lacking orderly disconnect must define some transport-specific
+// handshaking (e.g. the XNS/SPP handshake convention) in order to
+// know that the same transport semantics are provided when shutdown
+// is begun with messages "in flight". (IIOP doesn't report false
+// errors in the case of "clean shutdown", because it relies on
+// orderly disconnect as provided by TCP. This quality of service is
+// required to write robust distributed systems.)
+
+void
+TAO_GIOP_Accept_State::send_close_connection (const TAO_GIOP_Version& version,
+ TAO_Transport *transport,
+ void *)
+{
+
+ // static CORBA::Octet
+ // I hate this in every method. Till the time I figure out a way
+ // around I will have them here hanging around.
+ const char close_message [TAO_GIOP_HEADER_LEN] =
+ {
+ // The following works on non-ASCII platforms, such as MVS (which
+ // uses EBCDIC).
+ 0x47, // 'G'
+ 0x49, // 'I'
+ 0x4f, // 'O'
+ 0x50, // 'P'
+ version.major,
+ version.minor,
+ TAO_ENCAP_BYTE_ORDER,
+ TAO_GIOP_CLOSECONNECTION,
+ 0, 0, 0, 0
+ };
+
+ // It's important that we use a reliable shutdown after we send this
+ // message, so we know it's received.
+ //
+ // @@ should recv and discard queued data for portability; note
+ // that this won't block (long) since we never set SO_LINGER
+
+ TAO_GIOP_Utils::dump_msg ("send_close_connection",
+ (const u_char *) close_message,
+ TAO_GIOP_HEADER_LEN);
+
+ ACE_HANDLE which = transport->handle ();
+ if (which == ACE_INVALID_HANDLE)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) TAO_GIOP::send_close_connection -"
+ " connection already closed\n"));
+ return;
+ }
+
+ if (transport->send ((const u_char *) close_message,
+ TAO_GIOP_HEADER_LEN) == -1)
+ {
+ if (TAO_orbdebug)
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) error closing connection %d\n",
+ which));
+ }
+
+ transport->close_connection ();
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) shut down transport, handle %d\n",
+ which));
+
+}
+
+
+// Send an "I can't understand you" message -- again, the message is
+// prefabricated for simplicity. This implies abortive disconnect (at
+// the application level, if not at the level of TCP).
+//
+// NOTE that IIOP will still benefit from TCP's orderly disconnect.
+
+int
+TAO_GIOP_Accept_State::send_error (TAO_Transport *transport)
+{
+ TAO_GIOP_Version version (this->major_version (),
+ this->minor_version ());
+ const char
+ error_message [TAO_GIOP_HEADER_LEN] =
+ {
+ // The following works on non-ASCII platforms, such as MVS (which
+ // uses EBCDIC).
+ 0x47, // 'G'
+ 0x49, // 'I'
+ 0x4f, // 'O'
+ 0x50, // 'P'
+ version.major,
+ version.minor,
+ TAO_ENCAP_BYTE_ORDER,
+ TAO_GIOP_MESSAGERROR,
+ 0, 0, 0, 0
+ };
+
+ // @@ Q: How does this works with GIOP lite?
+ // A: It doesn't
+
+ TAO_GIOP_Utils::dump_msg ("send_error",
+ (const u_char *) error_message,
+ TAO_GIOP_HEADER_LEN);
+
+ ACE_HANDLE which = transport->handle ();
+
+ int result = transport->send ((const u_char *)error_message,
+ TAO_GIOP_HEADER_LEN);
+ if (result == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%N|%l|%P|%t) error sending error to %d\n",
+ which));
+ }
+
+ return result;
+}
+
+int
+TAO_GIOP_Accept_State::process_connector_request (TAO_Transport *transport,
+ TAO_ORB_Core* orb_core,
+ TAO_InputCDR &input,
+ TAO_OutputCDR &output)
+{
+ // Get the revision info
+ TAO_GIOP_Version version (this->major_version (),
+ this->minor_version ());
+
+ // This will extract the request header, set <response_required>
+ // and <sync_with_server> as appropriate.
+ TAO_GIOP_ServerRequest request (input,
+ output,
+ orb_core,
+ version);
+ CORBA::Environment &ACE_TRY_ENV = TAO_default_environment ();
+
+ CORBA::ULong request_id = 0;
+ CORBA::Boolean response_required = 0;
+ CORBA::Boolean sync_with_server = 0;
+ CORBA::Boolean location_forward = 0;
+ int parse_error = 0;
+
+ ACE_TRY
+ {
+ parse_error = this->parse_request_header (request);
+
+ // Throw an exception if the
+ if (parse_error != 0)
+ ACE_TRY_THROW (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
+ CORBA::COMPLETED_NO));
+ request_id = request.request_id ();
+
+ response_required = request.response_expected ();
+ sync_with_server = request.sync_with_server ();
+
+#if !defined (TAO_NO_IOR_TABLE)
+ const CORBA::Octet *object_key =
+ request.object_key ().get_buffer ();
+
+ if (ACE_OS::memcmp (object_key,
+ &TAO_POA::objectkey_prefix[0],
+ TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE) != 0)
+ {
+ ACE_CString object_id (ACE_reinterpret_cast (const char *,
+ object_key),
+ request.object_key ().length (),
+ 0,
+ 0);
+
+ // @@ This debugging output should *NOT* be used since the
+ // object key string is not null terminated, nor can it
+ // be null terminated without copying. No copying should
+ // be done since performance is somewhat important here.
+ // So, just remove the debugging output entirely.
+ //
+ // if (TAO_debug_level > 0)
+ // ACE_DEBUG ((LM_DEBUG,
+ // "Simple Object key %s. "
+ // "Doing the Table Lookup ...\n",
+ // object_id.c_str ()));
+
+ CORBA::Object_ptr object_reference =
+ CORBA::Object::_nil ();
+
+ // Do the Table Lookup.
+ int status =
+ orb_core->orb ()->_tao_find_in_IOR_table (object_id,
+ object_reference);
+
+ // If ObjectID not in table or reference is nil raise
+ // OBJECT_NOT_EXIST.
+
+ if (status == -1 || CORBA::is_nil (object_reference))
+ ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST ());
+
+ // ObjectID present in the table with an associated NON-NULL
+ // reference. Throw a forward request exception.
+
+ CORBA::Object_ptr dup =
+ CORBA::Object::_duplicate (object_reference);
+
+ // @@ We could simply write the response at this point...
+ ACE_TRY_THROW (PortableServer::ForwardRequest (dup));
+ }
+#endif /* TAO_NO_IOR_TABLE */
+
+ // Do this before the reply is sent.
+ orb_core->object_adapter ()->dispatch_servant (
+ request.object_key (),
+ request,
+ transport,
+ 0,
+ ACE_TRY_ENV
+ );
+ ACE_TRY_CHECK;
+ }
+#if !defined (TAO_HAS_MINIMUM_CORBA)
+ ACE_CATCH (PortableServer::ForwardRequest, forward_request)
+ {
+ // Make the GIOP header and Reply header
+ this->make_reply (version,
+ TAO_GIOP_REPLY,
+ request_id,
+ output);
+
+ output.write_ulong (TAO_GIOP_LOCATION_FORWARD);
+
+ CORBA::Object_ptr object_ptr =
+ forward_request.forward_reference.in();
+
+ output << object_ptr;
+
+ // Flag for code below catch blocks.
+ location_forward = 1;
+ }
+#else
+ ACE_UNUSED_ARG (request_id);
+#endif /* TAO_HAS_MINIMUM_CORBA */
+ // Only CORBA exceptions are caught here.
+ ACE_CATCHANY
+ {
+ int result = 0;
+ if (response_required)
+ {
+ result = this->send_reply_exception (version,
+ transport,
+ orb_core,
+ request_id,
+ &ACE_ANY_EXCEPTION);
+ if (result == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_ERROR ((LM_ERROR,
+ "TAO: (%P|%t) %p: cannot send exception\n",
+ "TAO_GIOP::process_server_message"));
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "TAO: ");
+ }
+
+ }
+ else if (TAO_debug_level > 0)
+ {
+ // It is unfotunate that an exception (probably a system
+ // exception) was thrown by the upcall code (even by the
+ // user) when the client was not expecting a response.
+ // However, in this case, we cannot close the connection
+ // down, since it really isn't the client's fault.
+
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) exception thrown "
+ "but client is not waiting a response\n"));
+ ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
+ "TAO: ");
+ }
+
+ return result;
+ }
+ #if defined (TAO_HAS_EXCEPTIONS)
+ ACE_CATCHALL
+ {
+ // @@ TODO some c++ exception or another, but what do we do with
+ // it?
+ // We are supposed to map it into a CORBA::UNKNOWN exception.
+ // BTW, this cannot be detected if using the <env> mapping. If
+ // we have native exceptions but no support for them in the ORB
+ // we should still be able to catch it. If we don't have native
+ // exceptions it couldn't have been raised in the first place!
+ int result = 0;
+ if (response_required)
+ {
+ CORBA::UNKNOWN exception
+ (CORBA::SystemException::_tao_minor_code
+ (TAO_UNHANDLED_SERVER_CXX_EXCEPTION, 0),
+ CORBA::COMPLETED_MAYBE);
+
+ result = this->send_reply_exception (version,
+ transport,
+ orb_core,
+ request_id,
+ &exception);
+ if (result == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_ERROR ((LM_ERROR,
+ "TAO: (%P|%t) %p: cannot send exception\n",
+ "TAO_GIOP::process_server_message"));
+ ACE_PRINT_EXCEPTION (exception, "TAO: ");
+ }
+
+ }
+ else if (TAO_debug_level > 0)
+ {
+ // It is unfotunate that an exception (probably a system
+ // exception) was thrown by the upcall code (even by the
+ // user) when the client was not expecting a response.
+ // However, in this case, we cannot close the connection
+ // down, since it really isn't the client's fault.
+ ACE_ERROR ((LM_ERROR,
+ "(%P|%t) exception thrown "
+ "but client is not waiting a response\n"));
+ }
+
+ return result;
+ }
+#endif /* TAO_HAS_EXCEPTIONS */
+ ACE_ENDTRY;
+
+ int result = 0;
+
+ // Do we have a twoway request, a oneway SYNC_WITH_TARGET,
+ // or a oneway SYNC_WITH_SERVER with a location forward reply?
+ if ((response_required && !sync_with_server)
+ || (sync_with_server && location_forward))
+ {
+ result = TAO_GIOP_Utils::send_message (transport,
+ output,
+ this->header_length (),
+ this->offset_length ());
+ if (result == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ // No exception but some kind of error, yet a response
+ // is required.
+ ACE_ERROR ((LM_ERROR,
+ "TAO: (%P|%t) %p: cannot send reply\n",
+ "TAO_GIOP::process_server_message"));
+ }
+ }
+ }
+
+ return result;
+}
+
+int
+TAO_GIOP_Accept_State::process_connector_locate (TAO_Transport *transport,
+ TAO_ORB_Core* orb_core,
+ TAO_InputCDR &input,
+ TAO_OutputCDR &output)
+{
+ // Get the revision info
+ TAO_GIOP_Version version (this->major_version (),
+ this->minor_version ());
+
+ // This will extract the request header, set <response_required> as
+ // appropriate.
+ TAO_GIOP_Locate_Request_Header locate_request (input);
+
+ TAO_GIOP_Locate_Status_Msg status_info;
+
+ // Defaulting
+ status_info.status = TAO_GIOP_UNKNOWN_OBJECT;
+
+ CORBA::Boolean response_required = 1;
+
+ ACE_DECLARE_NEW_CORBA_ENV;
+ ACE_TRY
+ {
+ int parse_error = this->parse_locate_header (locate_request);
+ if (parse_error != 0)
+ ACE_TRY_THROW (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
+ CORBA::COMPLETED_NO));
+#if !defined (TAO_NO_IOR_TABLE)
+
+ const CORBA::Octet *object_key =
+ locate_request.target_address ().object_key ().get_buffer ();
+
+ if (ACE_OS::memcmp (object_key,
+ &TAO_POA::objectkey_prefix[0],
+ TAO_POA::TAO_OBJECTKEY_PREFIX_SIZE) != 0)
+ {
+ CORBA::ULong len =
+ locate_request.target_address ().object_key ().length ();
+
+ ACE_CString object_id (ACE_reinterpret_cast (const char *,
+ object_key),
+ len,
+ 0,
+ 0);
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "Simple Object key %s. Doing the Table Lookup ...\n",
+ object_id.c_str ()));
+
+ CORBA::Object_ptr object_reference;
+
+ // Do the Table Lookup.
+ int find_status =
+ orb_core->orb ()->_tao_find_in_IOR_table (object_id,
+ object_reference);
+
+ // If ObjectID not in table or reference is nil raise
+ // OBJECT_NOT_EXIST.
+
+ if (CORBA::is_nil (object_reference)
+ || find_status == -1)
+ ACE_TRY_THROW (CORBA::OBJECT_NOT_EXIST ());
+
+ // ObjectID present in the table with an associated NON-NULL
+ // reference. Throw a forward request exception.
+
+ CORBA::Object_ptr dup =
+ CORBA::Object::_duplicate (object_reference);
+
+ // @@ We could simply write the response at this point...
+ ACE_TRY_THROW (PortableServer::ForwardRequest (dup));
+ }
+#endif /* TAO_NO_IOR_TABLE */
+
+ // Execute a fake request to find out if the object is there or
+ // if the POA can activate it on demand...
+ char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
+ TAO_OutputCDR dummy_output (repbuf,
+ sizeof repbuf);
+ // This output CDR is not used!
+
+ // This could be tricky if the target_address does not have the
+ // object key. Till then .. Bala
+ TAO_ObjectKey tmp_key (locate_request.target_address ().object_key ().length (),
+ locate_request.target_address ().object_key ().length (),
+ locate_request.target_address ().object_key ().get_buffer (),
+ 0);
+
+ // Set it to an error state
+ parse_error = 1;
+ CORBA::ULong req_id = locate_request.request_id ();
+
+ TAO_GIOP_ServerRequest server_request (req_id,
+ response_required,
+ tmp_key,
+ "_non_existent",
+ dummy_output,
+ orb_core,
+ version,
+ parse_error);
+ if (parse_error != 0)
+ ACE_TRY_THROW (CORBA::MARSHAL (TAO_DEFAULT_MINOR_CODE,
+ CORBA::COMPLETED_NO));
+
+ orb_core->object_adapter ()->dispatch_servant
+ (server_request.object_key (),
+ server_request,
+ transport,
+ 0,
+ ACE_TRY_ENV);
+
+ ACE_TRY_CHECK;
+
+ if (server_request.exception_type () == TAO_GIOP_NO_EXCEPTION)
+ {
+ // We got no exception, so the object is here.
+ status_info.status = TAO_GIOP_OBJECT_HERE;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO: (%P|%t) handle_locate() : found\n"));
+ }
+ else if (server_request.exception_type () != TAO_GIOP_NO_EXCEPTION)
+ {
+ status_info.forward_location_var = server_request.forward_location ();
+ if (!CORBA::is_nil (status_info.forward_location_var.in ()))
+ {
+ status_info.status = TAO_GIOP_OBJECT_FORWARD;
+ ACE_DEBUG ((LM_DEBUG,
+ "handle_locate has been called: forwarding\n"));
+ }
+ else
+ {
+ // Normal exception, so the object is not here
+ status_info.status = TAO_GIOP_UNKNOWN_OBJECT;
+ ACE_DEBUG ((LM_DEBUG,
+ "handle_locate has been called: not here\n"));
+ }
+ }
+
+ }
+
+#if !defined (TAO_HAS_MINIMUM_CORBA)
+ ACE_CATCH (PortableServer::ForwardRequest, forward_request)
+ {
+ status_info.status = TAO_GIOP_OBJECT_FORWARD;
+ status_info.forward_location_var =
+ forward_request.forward_reference;
+ ACE_DEBUG ((LM_DEBUG,
+ "handle_locate has been called: forwarding\n"));
+ }
+#endif /* TAO_HAS_MINIMUM_CORBA */
+ ACE_CATCHANY
+ {
+ // Normal exception, so the object is not here
+ status_info.status = TAO_GIOP_UNKNOWN_OBJECT;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) TAO_GIOP::process_server_locate - "
+ "CORBA exception raised\n"));
+ }
+#if defined (TAO_HAS_EXCEPTIONS)
+ ACE_CATCHALL
+ {
+ // Normal exception, so the object is not here
+ status_info.status = TAO_GIOP_UNKNOWN_OBJECT;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) TAO_GIOP::process_server_locate - "
+ "C++ exception raised\n"));
+ }
+#endif /* TAO_HAS_EXCEPTIONS */
+ ACE_ENDTRY;
+
+
+ return this->make_locate_reply (transport,
+ version,
+ output,
+ locate_request,
+ status_info);
+
+}
+
+
+int
+TAO_GIOP_Accept_State::make_locate_reply (TAO_Transport *transport,
+ const TAO_GIOP_Version &version,
+ TAO_OutputCDR &output,
+ TAO_GIOP_Locate_Request_Header &request,
+ TAO_GIOP_Locate_Status_Msg &status_info)
+
+
+{
+ // Note here we are making the Locate reply header which is *QUITE*
+ // different from the reply header made by the make_reply () cal..
+
+ // Make the GIOP message header
+ TAO_GIOP_Utils::start_message (version,
+ TAO_GIOP_LOCATEREPLY,
+ output);
+
+ // Make the header for the locate request
+ output.write_ulong (request.request_id ());
+ output.write_ulong (status_info.status);
+
+ // @@Does GIOP1.2 need a padding .. Not sure..??
+ if (status_info.status == TAO_GIOP_OBJECT_FORWARD)
+ {
+ CORBA::Object_ptr object_ptr = status_info.forward_location_var.in ();
+ if ((output << object_ptr) == 0)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) TAO_GIOP::process_server_request -"
+ " cannot marshal object reference\n"));
+ }
+ }
+
+ // Get the header & offset length
+ size_t header_len = this->header_length ();
+ size_t offset_len = this->offset_length ();
+
+ // Send the message
+ int result = TAO_GIOP_Utils::send_message (transport,
+ output,
+ header_len,
+ offset_len);
+
+ // Print out message if there is an error
+ if (result == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ "TAO: (%P|%t) %p: cannot send reply\n",
+ "TAO_GIOP::process_server_message"));
+ }
+ }
+
+ return result;
+}
+
+
+int
+TAO_GIOP_Accept_State::send_reply_exception (const TAO_GIOP_Version &version,
+ TAO_Transport *transport,
+ TAO_ORB_Core* orb_core,
+ CORBA::ULong request_id,
+ CORBA::Exception *x)
+{
+ // Create a new output CDR stream
+
+ char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
+#if defined(ACE_HAS_PURIFY)
+ (void) ACE_OS::memset (repbuf,
+ '\0',
+ sizeof repbuf);
+#endif /* ACE_HAS_PURIFY */
+ TAO_OutputCDR output (repbuf,
+ sizeof repbuf,
+ TAO_ENCAP_BYTE_ORDER,
+ orb_core->output_cdr_buffer_allocator (),
+ orb_core->output_cdr_dblock_allocator (),
+ orb_core->orb_params ()->cdr_memcpy_tradeoff (),
+ orb_core->to_iso8859 (),
+ orb_core->to_unicode ());
+
+ // Make the GIOP & reply header. They are version specific.
+ this->make_reply (version,
+ TAO_GIOP_REPLY,
+ request_id,
+ output);
+
+ // A new try/catch block, but if something goes wrong now we have no
+ // hope, just abort.
+ ACE_DECLARE_NEW_CORBA_ENV;
+
+ ACE_TRY
+ {
+ // Write the exception
+ CORBA::TypeCode_ptr except_tc = x->_type ();
+
+ CORBA::exception_type extype =
+ CORBA::USER_EXCEPTION;
+
+ if (CORBA::SystemException::_narrow (x) != 0)
+ extype = CORBA::SYSTEM_EXCEPTION;
+
+ // write the reply_status
+ output.write_ulong
+ (TAO_GIOP_Accept_State::convert_CORBA_to_GIOP_exception (extype));
+
+ // @@ Any way to implement this without interpretive
+ // marshaling???
+ output.encode (except_tc,
+ x,
+ 0,
+ ACE_TRY_ENV);
+ ACE_TRY_CHECK;
+ }
+ ACE_CATCH (CORBA_Exception, ex)
+ {
+ // Now we know that while handling the error an other error
+ // happened -> no hope, close connection.
+
+ // Close the handle.
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) cannot marshal exception, handle = %d: %p\n",
+ transport->handle (),
+ "TAO_GIOP::send_reply_exception"));
+ return -1;
+ }
+ ACE_ENDTRY;
+
+ // Get the header & offset length
+ size_t header_len = this->header_length ();
+ size_t offset_len = this->offset_length ();
+
+ return TAO_GIOP_Utils::send_message (transport,
+ output,
+ header_len,
+ offset_len);
+}
+
+
+TAO_GIOP_Reply_Status_Type
+TAO_GIOP_Accept_State::convert_CORBA_to_GIOP_exception (
+ CORBA::exception_type corba_type)
+{
+ switch (corba_type)
+ {
+ case CORBA::NO_EXCEPTION:
+ return TAO_GIOP_NO_EXCEPTION;
+
+ case CORBA::SYSTEM_EXCEPTION:
+ return TAO_GIOP_SYSTEM_EXCEPTION;
+
+ case CORBA::USER_EXCEPTION:
+ return TAO_GIOP_USER_EXCEPTION;
+
+ default:
+ // Don't know what to do here??
+ return TAO_GIOP_SYSTEM_EXCEPTION;
+ }
+}
diff --git a/TAO/tao/GIOP_Acceptors.cpp b/TAO/tao/GIOP_Acceptors.cpp
index ca0908bbcf6..6e77ea424d7 100644
--- a/TAO/tao/GIOP_Acceptors.cpp
+++ b/TAO/tao/GIOP_Acceptors.cpp
@@ -1 +1,163 @@
//$Id$
+#include "tao/GIOP_Acceptors.h"
+
+#if !defined (__ACE_INLINE__)
+# include "tao/GIOP_Acceptors.i"
+#endif /* __ACE_INLINE__ */
+
+int
+TAO_GIOP_Acceptor_1_1::
+parse_request_header (TAO_GIOP_ServerRequest &request)
+{
+ // Tear out the service context ... we currently ignore it, but it
+ // should probably be passed to each ORB service as appropriate
+ // (e.g. transactions, security).
+ //
+ // NOTE: As security support kicks in, this is a good place to
+ // verify a digital signature, if that is required in this security
+ // environment. It may be required even when using IPSEC security
+ // infrastructure.
+
+ // Get the input CDR in the request class
+ TAO_InputCDR& input = request.incoming ();
+
+ IOP::ServiceContextList service_info;
+ input >> service_info;
+
+ // This method is going to a copy?? Data copy?? Need to figure out a
+ // way to avoid this
+ request.service_info (service_info);
+
+
+ CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit ();
+
+ CORBA::ULong req_id;
+ // Get the rest of the request header ...
+ hdr_status = hdr_status && input.read_ulong (req_id);
+
+ request.request_id (req_id);
+
+ CORBA::Octet response_flags;
+ hdr_status = hdr_status && input.read_octet (response_flags);
+ request.response_expected ((response_flags != 0));
+ request.sync_with_server ((response_flags == 1));
+
+ // We use ad-hoc demarshalling here: there is no need to increase
+ // the reference count on the CDR message block, because this key
+ // will not outlive the request (or the message block).
+
+ CORBA::Long key_length = 0;
+ hdr_status = hdr_status && input.read_long (key_length);
+ if (hdr_status)
+ {
+ request.object_key ().replace (key_length, key_length,
+ (CORBA::Octet*)input.rd_ptr (),
+ 0);
+ input.skip_bytes (key_length);
+ }
+
+ ACE_CString operation_name;
+ if (input.char_translator () == 0)
+ {
+ CORBA::ULong length = 0;
+ hdr_status = hdr_status && input.read_ulong (length);
+ if (hdr_status)
+ {
+ // Do not include NULL character at the end.
+ // @@ This is not getting demarshaled using the codeset
+ // translators!
+ operation_name.set (input.rd_ptr (),
+ length - 1,
+ 0);
+ request.operation (operation_name);
+ hdr_status = input.skip_bytes (length);
+ }
+ }
+ else
+ {
+ // @@ We could optimize for this case too, i.e. do in-place
+ // demarshaling of the string... But there is an issue
+ // pending on the OMG as to whether the operation should be
+ // sent in the connection negotiated codeset or always in
+ // ISO8859-1.
+ CORBA::String_var tmp;
+ hdr_status = hdr_status && input.read_string (tmp.inout ());
+ operation_name.set (tmp._retn (), 1);
+ request.operation (operation_name);
+ }
+
+ if (hdr_status)
+ {
+ CORBA::Principal_var principal;
+
+ // Beware extra data copying
+ input >> principal.out ();
+
+ request.requesting_principal (principal.in ());
+
+ hdr_status = (CORBA::Boolean) input.good_bit ();
+ }
+
+ // Set the header length info and offset info
+ request.header_length (this->header_length ());
+ request.message_size_offset (this->offset_length ());
+
+ return hdr_status ? 0 : -1;
+}
+
+
+int
+TAO_GIOP_Acceptor_1_1::
+parse_locate_header (TAO_GIOP_Locate_Request_Header &request)
+{
+ // Get the stream
+ TAO_InputCDR &msg = request.incoming_stream ();
+
+ CORBA::Boolean hdr_status = 1;
+
+ // Get the request id
+ CORBA::ULong req_id = 0;
+ hdr_status = msg.read_ulong (req_id);
+
+ // Store it in the Locate request classes
+ request.request_id (req_id);
+
+ TAO_ObjectKey object_key;
+
+ // Note that here there are no unions and so no problems
+ hdr_status = hdr_status && (msg >> object_key);
+
+ // Get the underlying TargetAddress from the request class
+ GIOP::TargetAddress &target = request.target_address ();
+
+ // Put this object key in the target_adderss
+ target.object_key (object_key);
+
+ return hdr_status ? 0 : -1;
+}
+
+int
+TAO_GIOP_Acceptor_1_1::make_reply (const TAO_GIOP_Version &version,
+ TAO_GIOP_Message_Type t,
+ CORBA::ULong request_id,
+ TAO_OutputCDR &output)
+
+{
+ // Construct a REPLY header.
+ TAO_GIOP_Utils::start_message (version,
+ t,
+ output);
+
+
+ // create and write a dummy context
+ IOP::ServiceContextList resp_ctx;
+ resp_ctx.length (0);
+ output << resp_ctx;
+
+ // Write the request ID
+ output.write_ulong (request_id);
+
+
+
+ return 1;
+}
diff --git a/TAO/tao/GIOP_Message_Factory.cpp b/TAO/tao/GIOP_Message_Factory.cpp
index 2b62bc0b6be..d61251fa1a0 100644
--- a/TAO/tao/GIOP_Message_Factory.cpp
+++ b/TAO/tao/GIOP_Message_Factory.cpp
@@ -42,55 +42,129 @@
// reported.
#include "tao/GIOP_Message_Factory.h"
+#include "tao/GIOP_Utils.h"
#include "tao/Any.h"
+#include "tao/ORB_Core.h"
#if !defined (__ACE_INLINE__)
# include "tao/GIOP_Message_Factory.i"
#endif /* __ACE_INLINE__ */
-TAO_GIOP_Message_Factory::TAO_GIOP_Message_Factory (void)
+
+
+//
+// Client Side Message Factory Methods
+//
+
+TAO_GIOP_Client_Message_Factory::TAO_GIOP_Client_Message_Factory (void)
{
}
-TAO_GIOP_Message_Factory::~TAO_GIOP_Message_Factory (void)
+TAO_GIOP_Client_Message_Factory::~TAO_GIOP_Client_Message_Factory (void)
{
}
-/*CORBA::Boolean
-TAO_GIOP_Message_Factory::start_message (const TAO_GIOP_Version &version,
- TAO_GIOP_Message_Factory::Message_Type t,
- TAO_OutputCDR &msg)
+int
+TAO_GIOP_Client_Message_Factory::handle_input (TAO_Transport *transport,
+ TAO_ORB_Core */*orb_core*/,
+ TAO_Message_State_Factory &mesg_state,
+ ACE_Time_Value *max_wait_time)
{
- msg.reset ();
-
- static CORBA::Octet magic[] =
- {
- // The following works on non-ASCII platforms, such as MVS (which
- // uses EBCDIC).
- 0x47, // 'G'
- 0x49, // 'I'
- 0x4f, // 'O'
- 0x50, // 'P'
- };
-
- static int magic_size = sizeof (magic)/sizeof (magic[0]);
- msg.write_octet_array (magic, magic_size);
- msg.write_octet (version.major);
- msg.write_octet (version.minor);
- msg.write_octet (TAO_ENCAP_BYTE_ORDER);
- msg.write_octet ((CORBA::Octet) type);
-
- // Write a dummy <size> later it is set to the right value...
- CORBA::ULong size = 0;
- msg.write_ulong (size);
+ TAO_GIOP_Message_State *state =
+ ACE_dynamic_cast (TAO_GIOP_Message_State *,
+ &mesg_state);
- return 1;
+ if (state->header_received () == 0)
+ {
+ if (TAO_GIOP_Utils::read_bytes_input (transport,
+ state->cdr,
+ TAO_GIOP_HEADER_LEN,
+ max_wait_time) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Client_Message_Factory::handle_input"));
+ return -1;
+ }
+
+
+ if (this->parse_magic_bytes (state->cdr) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Client_Message_Factory::handle_input, parse_bytes"));
+ return -1;
+ }
+
+ // Read the rest of the stuff. That should be read by the
+ // corresponding states
+ if (this->parse_header (state) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Client_Message_Factory::handle_input"));
+ return -1;
+ }
+ }
+
+ size_t missing_data =
+ state->message_size - state->current_offset;
+
+
+ ssize_t n =
+ TAO_GIOP_Utils::read_buffer (transport,
+ state->cdr.rd_ptr () + state->current_offset,
+ missing_data,
+ max_wait_time);
+ if (n == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP_Client_Message_Factory::handle_input, read_buffer[1]"));
+ return -1;
+ }
+ else if (n == 0)
+ {
+ if (errno == EWOULDBLOCK)
+ return 0;
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP_Client_Message::handle_input, read_buffer[2]"));
+ return -1;
+ }
+
+ state->current_offset += n;
+
+ if (state->current_offset == state->message_size)
+ {
+ if (TAO_debug_level >= 4)
+ {
+ size_t header_len = TAO_GIOP_HEADER_LEN;
+
+ // Need to include GIOPlite too.
+
+ char *buf = state->cdr.rd_ptr ();
+ buf -= header_len;
+ size_t msg_len = state->cdr.length () + header_len;
+ TAO_GIOP_Utils::dump_msg ("recv",
+ ACE_reinterpret_cast (u_char *,
+ buf),
+ msg_len);
+ }
+ }
+
+ return state->is_complete ();
}
-*/
+
CORBA::Boolean
-TAO_GIOP_Message_Factory::write_request_header (const IOP::ServiceContextList& /*svc_ctx*/,
+TAO_GIOP_Client_Message_Factory::write_request_header (const IOP::ServiceContextList& /*svc_ctx*/,
CORBA::ULong request_id,
CORBA::Octet response_flags,
TAO_Stub */*stub*/,
@@ -105,7 +179,7 @@ TAO_GIOP_Message_Factory::write_request_header (const IOP::ServiceContextList& /
// First the request id
msg << request_id;
-
+
// Second the response flags
switch (response_flags)
{
@@ -134,9 +208,7 @@ TAO_GIOP_Message_Factory::write_request_header (const IOP::ServiceContextList& /
// specific to GIOP 1.2. So some of the services would start
// using this at some point of time and we will have them here
// naturally out of a need.
-
default:
- // Until more flags are defined by the OMG.
return 0;
}
@@ -145,97 +217,267 @@ TAO_GIOP_Message_Factory::write_request_header (const IOP::ServiceContextList& /
-
-TAO_GIOP_Message_Factory::send_message (TAO_Transport *transport,
- TAO_OutputCDR &stream,
- ACE_Time_Value *max_wait_time = 0,
- TAO_Stub *stub = 0)
+int
+TAO_GIOP_Client_Message_Factory::send_message (TAO_Transport *transport,
+ TAO_OutputCDR &stream,
+ ACE_Time_Value *max_wait_time,
+ TAO_Stub *stub)
{
- // TAO_FUNCTION_PP_TIMEPROBE (TAO_GIOP_SEND_MESSAGE_START);
-
- // Ptr to first buffer.
- char *buf = (char *) stream.buffer ();
-
- // Length of all buffers.
- size_t total_len =
- stream.total_length ();
-
- // NOTE: Here would also be a fine place to calculate a digital
- // signature for the message and place it into a preallocated slot
- // in the "ServiceContext". Similarly, this is a good spot to
- // encrypt messages (or just the message bodies) if that's needed in
- // this particular environment and that isn't handled by the
- // networking infrastructure (e.g., IPSEC).
-
// Get the header length
size_t header_len = this->get_header_len ();
// Get the message size offset
size_t offset = this->get_message_size_offset ();
+
+ return TAO_GIOP_Utils::send_message (transport,
+ stream,
+ header_len,
+ offset,
+ max_wait_time,
+ stub);
+}
+
+
+
+//
+// Server Side Message Factory Methods
+//
+
+
+TAO_GIOP_Message_Acceptor::TAO_GIOP_Message_Acceptor (void)
+{
+ // Initialised...
+ this->accept_states_ = &(this->available_states_.giop_1_1_);
+
+}
+
+TAO_GIOP_Message_Acceptor::~TAO_GIOP_Message_Acceptor (void)
+{
+ //no-op
+}
+
+int
+TAO_GIOP_Message_Acceptor::handle_input (TAO_Transport *transport,
+ TAO_ORB_Core */*orb_core*/,
+ TAO_Message_State_Factory &mesg_state,
+ ACE_Time_Value *max_wait_time)
+{
+ TAO_GIOP_Message_State *state =
+ ACE_dynamic_cast (TAO_GIOP_Message_State *,
+ &mesg_state);
- CORBA::ULong bodylen = total_len - header_len;
-
-#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
- *ACE_reinterpret_cast (CORBA::ULong *, buf + offset) = bodylen;
-#else
- if (!stream->do_byte_swap ())
- *ACE_reinterpret_cast (CORBA::ULong *,
- buf + offset) = bodylen;
- else
- ACE_CDR::swap_4 (ACE_reinterpret_cast (char *,
- &bodylen),
- buf + offset);
-#endif /* ACE_ENABLE_SWAP_ON_WRITE */
-
- // Strictly speaking, should not need to loop here because the
- // socket never gets set to a nonblocking mode ... some Linux
- // versions seem to need it though. Leaving it costs little.
- this->dump_msg ("send",
- ACE_reinterpret_cast (u_char *,
- buf),
- stream.length ());
-
- // This guarantees to send all data (bytes) or return an error.
- ssize_t n = transport->send (stub,
- stream.begin (),
- max_wait_time);
+ if (state->header_received () == 0)
+ {
+ if (TAO_GIOP_Utils::read_bytes_input (transport,
+ state->cdr,
+ TAO_GIOP_HEADER_LEN,
+ max_wait_time) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Message_Acceptor::handle_input"));
+ return -1;
+ }
+
+ if (this->parse_magic_bytes (state->cdr,
+ state) == -1)
+ {
+ this->accept_states_->send_error (transport);
+
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Message_Acceptor::handle_input, parse_bytes"));
+ return -1;
+ }
+
+ // Read the rest of the stuff. That should be read by the
+ // corresponding states
+ if (this->accept_states_->parse_header (state) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n"
+ "TAO_GIOP_Message_Acceptor::handle_input"));
+ return -1;
+ }
+ }
+
+ size_t missing_data =
+ state->message_size - state->current_offset;
+ ssize_t n =
+ TAO_GIOP_Utils::read_buffer (transport,
+ state->cdr.rd_ptr () + state->current_offset,
+ missing_data,
+ max_wait_time);
if (n == -1)
{
- if (TAO_orbdebug)
+ if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "TAO: (%P|%t) closing conn %d after fault %p\n",
- transport->handle (),
- "GIOP_Message_Factory::send_message ()"));
-
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP_Message_Acceptor::handle_input, read_buffer[1]"));
return -1;
}
-
- // EOF.
- if (n == 0)
+ else if (n == 0)
{
- if (TAO_orbdebug)
+ if (errno == EWOULDBLOCK)
+ return 0;
+ if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,
- "TAO: (%P|%t) GIOP::send_message () "
- "EOF, closing conn %d\n",
- transport->handle()));
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP_Message_Acceptor::handle_input, read_buffer[2]"));
return -1;
}
- return 1;
+ state->current_offset += n;
+
+ if (state->current_offset == state->message_size)
+ {
+ if (TAO_debug_level >= 4)
+ {
+ size_t header_len = TAO_GIOP_HEADER_LEN;
+
+ // Need to include GIOPlite too.
+
+ char *buf = state->cdr.rd_ptr ();
+ buf -= header_len;
+ size_t msg_len = state->cdr.length () + header_len;
+ TAO_GIOP_Utils::dump_msg ("recv",
+ ACE_reinterpret_cast (u_char *,
+ buf),
+ msg_len);
+ }
+ }
+
+ return state->is_complete ();
}
-void
-TAO_GIOP_Message_Factory::dump_msg (const char */*label*/,
- const u_char */*ptr*/,
- size_t /*len*/)
+
+int
+TAO_GIOP_Message_Acceptor::
+process_connector_messages (TAO_Transport *transport,
+ TAO_ORB_Core *orb_core,
+ TAO_InputCDR &input,
+ CORBA::Octet message_type)
{
- if (TAO_debug_level >= 5)
+ char repbuf[ACE_CDR::DEFAULT_BUFSIZE];
+
+#if defined(ACE_HAS_PURIFY)
+ (void) ACE_OS::memset (repbuf,
+ '\0',
+ sizeof repbuf);
+#endif /* ACE_HAS_PURIFY */
+
+ TAO_OutputCDR output (repbuf,
+ sizeof repbuf,
+ TAO_ENCAP_BYTE_ORDER,
+ orb_core->output_cdr_buffer_allocator (),
+ orb_core->output_cdr_dblock_allocator (),
+ orb_core->orb_params ()->cdr_memcpy_tradeoff (),
+ orb_core->to_iso8859 (),
+ orb_core->to_unicode ());
+
+ switch (message_type)
{
- // I will have to print out all the relevant debug messages!!
- // Let me not wory about that now. I will get back to that at a
- // later date!!
+ case TAO_GIOP_REQUEST:
+ // Should be taken care by the state specific invocations. They
+ // could raise an exception or write things in the output CDR
+ // stream
+ this->accept_states_->process_connector_request (transport,
+ orb_core,
+ input,
+ output);
+ break;
+ case TAO_GIOP_LOCATEREQUEST:
+ this->accept_states_->process_connector_locate (transport,
+ orb_core,
+ input,
+ output);
+ break;
+ case TAO_GIOP_MESSAGERROR:
+ case TAO_GIOP_REPLY:
+ case TAO_GIOP_LOCATEREPLY:
+ case TAO_GIOP_CLOSECONNECTION:
+ default:
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) Illegal message received by server\n"));
+ return this->accept_states_->send_error (transport);
+ break;
}
+
+ return 0;
}
+int
+TAO_GIOP_Message_Acceptor::parse_magic_bytes (TAO_InputCDR &input,
+ TAO_GIOP_Message_State *state)
+{
+ // Grab the read pointer
+ char *buf = input.rd_ptr ();
+
+ // The values are hard-coded to support non-ASCII platforms.
+ if (!(buf [0] == 0x47 // 'G'
+ && buf [1] == 0x49 // 'I'
+ && buf [2] == 0x4f // 'O'
+ && buf [3] == 0x50)) // 'P'
+ {
+ // Could be GIOPlite..
+ //...
+
+ // For the present...
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) bad header, magic word [%c%c%c%c]\n",
+ buf[0],
+ buf[1],
+ buf[2],
+ buf[3]));
+ return -1;
+ }
+ state->giop_version.major = buf[TAO_GIOP_VERSION_MAJOR_OFFSET];
+ state->giop_version.minor = buf[TAO_GIOP_VERSION_MINOR_OFFSET];
+
+ // An extra variable?? Huh?? Can be removed??
+ CORBA::Octet major = state->giop_version.major;
+ CORBA::Octet minor = state->giop_version.minor;
+
+ if ((this->available_states_.check_major (major) == -1) ||
+ (this->available_states_.check_minor (minor) == -1))
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) bad version <%d.%d>\n",
+ major, minor));
+ return -1;
+ }
+
+ // Set the appropriate state
+ if (this->set_state (state) == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%P|%t|%N|%l) Failure <error> in set_state ()\n"),
+ -1);
+ }
+ }
+
+ return 0;
+}
+
+
+int
+TAO_GIOP_Message_Acceptor::set_state (TAO_GIOP_Message_State * /*state*/)
+
+{
+ // Logic for selecting from a registry set should be here. Let me go
+ // first with normal stuff.
+ this->accept_states_ = &(this->available_states_.giop_1_1_);
+
+ return 1;
+}
+
diff --git a/TAO/tao/GIOP_Message_Invocation.cpp b/TAO/tao/GIOP_Message_Invocation.cpp
index b053a240ce0..b097b7a7a96 100644
--- a/TAO/tao/GIOP_Message_Invocation.cpp
+++ b/TAO/tao/GIOP_Message_Invocation.cpp
@@ -1,18 +1,21 @@
//$id$
-#include "tao/GIOP_Message_1_1.h"
+#include "tao/GIOP_Message_Invocation.h"
#include "tao/GIOPC.h"
#include "tao/Profile.h"
#include "tao/Stub.h"
#include "tao/Object_KeyC.h"
#include "tao/Principal.h"
+#include "tao/GIOP_Utils.h"
//$Id$
#if defined (__ACE_INLINE__)
-# include "tao/GIOP_Message_1_1.i"
+# include "tao/GIOP_Message_Invocation.i"
#endif /* __ACE_INLINE__ */
TAO_GIOP_Client_Message_1_1::TAO_GIOP_Client_Message_1_1 (void)
+ :our_major_version_ (1),
+ our_minor_version_ (1)
{
//no-op
}
@@ -23,6 +26,72 @@ TAO_GIOP_Client_Message_1_1::~TAO_GIOP_Client_Message_1_1 (void)
//no-op
}
+int
+TAO_GIOP_Client_Message_1_1::parse_header (TAO_GIOP_Message_State *state)
+{
+ if (TAO_GIOP_Utils::parse_giop_header (state,
+ state->cdr) == -1)
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "(%N|%l) Error in parsing headers \n"),
+ -1);
+ }
+ return -1;
+ }
+
+ if (state->cdr.grow (this->get_header_len () +
+ state->message_size) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) - %p\n",
+ "TAO_GIOP::handle_input, ACE_CDR::grow"));
+ return -1;
+ }
+
+ // Growing the buffer may have reset the rd_ptr(), but we want
+ // to leave it just after the GIOP header (that was parsed
+ // already);
+ state->cdr.skip_bytes (this->get_header_len ());
+
+ return 1;
+}
+
+int
+TAO_GIOP_Client_Message_1_1::parse_magic_bytes (TAO_InputCDR &input)
+{
+ // Grab the read pointer
+ char *buf = input.rd_ptr ();
+
+ // The values are hard-coded to support non-ASCII platforms.
+ if (!(buf [0] == 0x47 // 'G'
+ && buf [1] == 0x49 // 'I'
+ && buf [2] == 0x4f // 'O'
+ && buf [3] == 0x50)) // 'P'
+ {
+ // Could be GIOPlite..
+ //...
+
+ // For the present...
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) bad header, magic word [%c%c%c%c]\n",
+ buf[0],
+ buf[1],
+ buf[2],
+ buf[3]));
+ return -1;
+ }
+
+ if ((buf[TAO_GIOP_VERSION_MAJOR_OFFSET] != this->our_major_version_) ||
+ (buf[TAO_GIOP_VERSION_MINOR_OFFSET] != this->our_minor_version_))
+ return -1;
+
+ return 1;
+}
+
CORBA::Boolean
TAO_GIOP_Client_Message_1_1::write_request_header (const IOP::ServiceContextList& svc_ctx,
CORBA::ULong request_id,
@@ -37,13 +106,13 @@ TAO_GIOP_Client_Message_1_1::write_request_header (const IOP::ServiceContextList
// Let us call our parent class to check what he can do for
// us.
- TAO_GIOP_Message_Factory::write_request_header (svc_ctx,
- request_id,
- response_flags,
- stub,
- address_disposition,
- opname,
- msg);
+ TAO_GIOP_Client_Message_Factory::write_request_header (svc_ctx,
+ request_id,
+ response_flags,
+ stub,
+ address_disposition,
+ opname,
+ msg);
// In this case we cannot recognise anything other than the Object
// key as the address disposition variable. But we do a sanity check
@@ -51,6 +120,7 @@ TAO_GIOP_Client_Message_1_1::write_request_header (const IOP::ServiceContextList
if (address_disposition == GIOP::KeyAddr)
{
// Put in the object key
+ // Not the right way.. Will blow if Messaging is defined..
TAO_Profile *profile =
stub->profile_in_use ();
@@ -93,6 +163,7 @@ write_locate_request_header (CORBA::ULong request_id,
if (address_disposition == GIOP::KeyAddr)
{
// Put in the object key
+ // Not the right way.. Will blow if Messaging is defined..
TAO_Profile *profile =
stub->profile_in_use ();
@@ -116,17 +187,130 @@ write_locate_request_header (CORBA::ULong request_id,
const size_t
TAO_GIOP_Client_Message_1_1::get_header_len (void)
{
- return TAO_GIOP_1_1_HEADER_LEN;
+ return TAO_GIOP_HEADER_LEN;
}
const size_t
TAO_GIOP_Client_Message_1_1::get_message_size_offset (void)
{
- return TAO_GIOP_1_1_MESSAGE_SIZE_OFFSET;
+ return TAO_GIOP_MESSAGE_SIZE_OFFSET;
}
-//
-// Server Side methods for GIOP 1.1
-//
+CORBA::Boolean
+TAO_GIOP_Client_Message_1_1::start_message (TAO_Pluggable_Message_Type t,
+ TAO_OutputCDR &msg)
+{
+
+ TAO_GIOP_Version version (this->our_major_version_,
+ this->our_minor_version_);
+
+ TAO_GIOP_Message_Type type = TAO_GIOP_REQUEST;
+ switch (t)
+ {
+ case (TAO_MESSAGE_REQUEST):
+ type = TAO_GIOP_REQUEST;
+ break;
+ case (TAO_MESSAGE_REPLY):
+ type = TAO_GIOP_REPLY;
+ break;
+ case (TAO_MESSAGE_CANCELREQUEST):
+ type = TAO_GIOP_CANCELREQUEST;
+ break;
+ case (TAO_MESSAGE_LOCATEREQUEST):
+ type = TAO_GIOP_LOCATEREQUEST;
+ break;
+ case (TAO_MESSAGE_LOCATEREPLY):
+ type = TAO_GIOP_LOCATEREPLY;
+ break;
+ case (TAO_MESSAGE_CLOSECONNECTION):
+ type = TAO_GIOP_CLOSECONNECTION;
+ break;
+ case (TAO_MESSAGE_MESSAGERROR):
+ type = TAO_GIOP_MESSAGERROR;
+ break;
+ case (TAO_MESSAGE_FRAGMENT):
+ type = TAO_GIOP_FRAGMENT;
+ break;
+ }
+
+ return TAO_GIOP_Utils::start_message (version,
+ type,
+ msg);
+}
+
+int
+TAO_GIOP_Client_Message_1_1::parse_reply (TAO_Transport */*transport*/,
+ TAO_Message_State_Factory &mesg_state,
+ IOP::ServiceContextList& reply_ctx,
+ CORBA::ULong &request_id,
+ CORBA::ULong &reply_status)
+{
+ // Cast to the GIOP Message state
+ TAO_GIOP_Message_State *state = ACE_dynamic_cast (TAO_GIOP_Message_State *,
+ &mesg_state);
+
+ switch (state->message_type)
+ {
+ case TAO_GIOP_REQUEST:
+ // In GIOP 1.0 and GIOP 1.1 this is an error,
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "TAO (%P|%t) %N:%l TAO_GIOP::parse_reply: "
+ "request.\n"),
+ -1);
+
+ case TAO_GIOP_CANCELREQUEST:
+ case TAO_GIOP_LOCATEREQUEST:
+ // Errors
+ case TAO_GIOP_CLOSECONNECTION:
+ // I am not sure why we are not handling this here.. by Bala
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "TAO (%P|%t) %N:%l TAO_GIOP::parse_reply: "
+ "wrong message.\n"),
+ -1);
+ break;
+ case TAO_GIOP_LOCATEREPLY:
+ // Handle after the switch
+ break;
+ case TAO_GIOP_REPLY:
+ if ((state->cdr >> reply_ctx) == 0)
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) TAO_GIOP_Client_Message_1_1::parse_reply, "
+ "extracting context\n"));
+ return -1;
+ }
+ // Rest of the stuff after the switch
+ break;
+ case TAO_GIOP_FRAGMENT:
+ // Never happens: why??
+ break;
+ }
+
+
+ // Read the request id
+ if (!state->cdr.read_ulong (request_id))
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) : TAO_GIOP::parse_reply, "
+ "extracting request id"));
+ return -1;
+ }
+ // and the reply status type. status can be NO_EXCEPTION,
+ // SYSTEM_EXCEPTION, USER_EXCEPTION, LOCATION_FORWARD
+ // CAnnot handle LOCATION_FORWARD_PERM here
+ if (!state->cdr.read_ulong (reply_status))
+ {
+ if (TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) : TAO_GIOP::parse_reply, "
+ "extracting reply status\n"));
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tao/GIOP_Server_Request.cpp b/TAO/tao/GIOP_Server_Request.cpp
index 34748cfd470..ea0a22e0594 100644
--- a/TAO/tao/GIOP_Server_Request.cpp
+++ b/TAO/tao/GIOP_Server_Request.cpp
@@ -46,9 +46,8 @@ TAO_GIOP_ServerRequest::
TAO_GIOP_ServerRequest (TAO_InputCDR &input,
TAO_OutputCDR &output,
TAO_ORB_Core *orb_core,
- const TAO_GIOP_Version &version,
- int &parse_error)
- : incoming_ (&input),
+ const TAO_GIOP_Version &version)
+ : incoming_ (&input),
outgoing_ (&output),
response_expected_ (0),
lazy_evaluation_ (0),
@@ -71,152 +70,7 @@ TAO_GIOP_ServerRequest::
{
ACE_FUNCTION_TIMEPROBE (TAO_SERVER_REQUEST_START);
- parse_error = this->parse_header ();
-}
-
-int
-TAO_GIOP_ServerRequest::parse_header_std (void)
-{
- // Tear out the service context ... we currently ignore it, but it
- // should probably be passed to each ORB service as appropriate
- // (e.g. transactions, security).
- //
- // NOTE: As security support kicks in, this is a good place to
- // verify a digital signature, if that is required in this security
- // environment. It may be required even when using IPSEC security
- // infrastructure.
-
- TAO_InputCDR& input = *this->incoming_;
-
- input >> this->service_info_;
- CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit ();
-
- // Get the rest of the request header ...
-
- hdr_status = hdr_status && input.read_ulong (this->request_id_);
-
- CORBA::Octet response_flags;
- hdr_status = hdr_status && input.read_octet (response_flags);
- this->response_expected_ = (response_flags != 0);
- this->sync_with_server_ = (response_flags == 1);
-
- // We use ad-hoc demarshalling here: there is no need to increase
- // the reference count on the CDR message block, because this key
- // will not outlive the request (or the message block).
-
- CORBA::Long key_length = 0;
- hdr_status = hdr_status && input.read_long (key_length);
- if (hdr_status)
- {
- this->object_key_.replace (key_length, key_length,
- (CORBA::Octet*)input.rd_ptr (),
- 0);
- input.skip_bytes (key_length);
- }
-
- if (input.char_translator () == 0)
- {
- CORBA::ULong length = 0;
- hdr_status = hdr_status && input.read_ulong (length);
- if (hdr_status)
- {
- // Do not include NULL character at the end.
- // @@ This is not getting demarshaled using the codeset
- // translators!
- this->operation_.set (input.rd_ptr (),
- length - 1,
- 0);
- hdr_status = input.skip_bytes (length);
- }
- }
- else
- {
- // @@ We could optimize for this case too, i.e. do in-place
- // demarshaling of the string... But there is an issue
- // pending on the OMG as to whether the operation should be
- // sent in the connection negotiated codeset or always in
- // ISO8859-1.
- CORBA::String_var tmp;
- hdr_status = hdr_status && input.read_string (tmp.inout ());
- this->operation_.set (tmp._retn (), 1);
- }
-
- if (hdr_status)
- {
- input >> this->requesting_principal_.out ();
- hdr_status = (CORBA::Boolean) input.good_bit ();
- }
-
- return hdr_status ? 0 : -1;
-}
-
-int
-TAO_GIOP_ServerRequest::parse_header_lite (void)
-{
- TAO_InputCDR& input = *this->incoming_;
-
- CORBA::Boolean hdr_status = (CORBA::Boolean) input.good_bit ();
-
- // Get the rest of the request header ...
-
- hdr_status = hdr_status && input.read_ulong (this->request_id_);
-
- CORBA::Octet response_flags;
- hdr_status = hdr_status && input.read_octet (response_flags);
- this->response_expected_ = (response_flags != 0);
- this->sync_with_server_ = (response_flags == 1);
-
- // We use ad-hoc demarshalling here: there is no need to increase
- // the reference count on the CDR message block, because this key
- // will not outlive the request (or the message block).
-
- CORBA::Long key_length = 0;
- hdr_status = hdr_status && input.read_long (key_length);
- if (hdr_status)
- {
- this->object_key_.replace (key_length, key_length,
- (CORBA::Octet*)input.rd_ptr (),
- 0);
- input.skip_bytes (key_length);
- }
-
- if (input.char_translator () == 0)
- {
- CORBA::ULong length = 0;
- hdr_status = hdr_status && input.read_ulong (length);
- if (hdr_status)
- {
- // Do not include NULL character at the end.
- // @@ This is not getting demarshaled using the codeset
- // translators!
- this->operation_.set (input.rd_ptr (),
- length - 1,
- 0);
- hdr_status = input.skip_bytes (length);
- }
- }
- else
- {
- // @@ We could optimize for this case too, i.e. do in-place
- // demarshaling of the string... But there is an issue
- // pending on the OMG as to whether the operation should be
- // sent in the connection negotiated codeset or always in
- // ISO8859-1.
- CORBA::String_var tmp;
- hdr_status = hdr_status && input.read_string (tmp.inout ());
- this->operation_.set (tmp._retn (), 1);
- }
-
- return hdr_status ? 0 : -1;
-}
-
-int
-TAO_GIOP_ServerRequest::parse_header (void)
-{
- if (this->orb_core_->orb_params ()->use_lite_protocol ())
- return this->parse_header_lite ();
- else
- return this->parse_header_std ();
+ // parse_error = this->parse_header ();
}
// This constructor is used, by the locate request code
@@ -556,10 +410,9 @@ void
TAO_GIOP_ServerRequest::init_reply (CORBA::Environment &ACE_TRY_ENV)
{
// Construct a REPLY header.
- TAO_GIOP::start_message (this->version_,
- TAO_GIOP::Reply,
- *this->outgoing_,
- this->orb_core_);
+ TAO_GIOP_Utils::start_message (this->version_,
+ TAO_GIOP_REPLY,
+ *this->outgoing_);
#if defined (TAO_HAS_MINIMUM_CORBA)
*this->outgoing_ << this->service_info_;
@@ -719,10 +572,9 @@ TAO_GIOP_ServerRequest::exception_type (void)
void
TAO_GIOP_ServerRequest::send_no_exception_reply (TAO_Transport *transport)
{
- TAO_GIOP::start_message (this->version_,
- TAO_GIOP::Reply,
- *this->outgoing_,
- this->orb_core_);
+ TAO_GIOP_Utils::start_message (this->version_,
+ TAO_GIOP_REPLY,
+ *this->outgoing_);
IOP::ServiceContextList resp_ctx;
resp_ctx.length (0);
@@ -731,9 +583,11 @@ TAO_GIOP_ServerRequest::send_no_exception_reply (TAO_Transport *transport)
this->outgoing_->write_ulong (this->request_id_);
this->outgoing_->write_ulong (TAO_GIOP_NO_EXCEPTION);
- int result = TAO_GIOP::send_message (transport,
- *this->outgoing_,
- this->orb_core_);
+ int result = TAO_GIOP_Utils::send_message (transport,
+ *this->outgoing_,
+ this->header_len_,
+ this->message_size_offset_);
+
if (result == -1)
{
diff --git a/TAO/tao/GIOP_Utils.cpp b/TAO/tao/GIOP_Utils.cpp
index ae0570b430c..652a2b275c7 100644
--- a/TAO/tao/GIOP_Utils.cpp
+++ b/TAO/tao/GIOP_Utils.cpp
@@ -26,6 +26,11 @@ TAO_GIOP_Message_State::TAO_GIOP_Message_State (TAO_ORB_Core* orb_core)
//giop_version.minor = TAO_DEF_GIOP_MINOR;
}
+TAO_GIOP_Message_State::~TAO_GIOP_Message_State (void)
+{
+ //no-op
+}
+
int
TAO_GIOP_Message_State::is_complete ()
{
@@ -120,7 +125,7 @@ TAO_GIOP_Utils::dump_msg (const char */*label*/,
CORBA::Boolean
TAO_GIOP_Utils::start_message (const TAO_GIOP_Version &version,
- TAO_Pluggable_Message_Type t,
+ TAO_GIOP_Message_Type t,
TAO_OutputCDR &msg)
{
static CORBA::Octet magic[] =
@@ -140,42 +145,224 @@ TAO_GIOP_Utils::start_message (const TAO_GIOP_Version &version,
msg.write_octet (version.minor);
msg.write_octet (TAO_ENCAP_BYTE_ORDER);
- CORBA::Octet type = 0;
+ msg.write_octet ((CORBA::Octet) t);
+
+ // Write a dummy <size> later it is set to the right value...
+ CORBA::ULong size = 0;
+ msg.write_ulong (size);
+
+ return 1;
+}
+
+
+int
+TAO_GIOP_Utils::send_message (TAO_Transport *transport,
+ TAO_OutputCDR &stream,
+ size_t header_len,
+ size_t offset,
+ ACE_Time_Value *max_wait_time,
+ TAO_Stub *stub)
+{
+ // Ptr to first buffer.
+ char *buf = (char *) stream.buffer ();
+
+ // Length of all buffers.
+ size_t total_len =
+ stream.total_length ();
+
+ // NOTE: Here would also be a fine place to calculate a digital
+ // signature for the message and place it into a preallocated slot
+ // in the "ServiceContext". Similarly, this is a good spot to
+ // encrypt messages (or just the message bodies) if that's needed in
+ // this particular environment and that isn't handled by the
+ // networking infrastructure (e.g., IPSEC).
+
+ CORBA::ULong bodylen = total_len - header_len;
+
+#if !defined (ACE_ENABLE_SWAP_ON_WRITE)
+ *ACE_reinterpret_cast (CORBA::ULong *, buf + offset) = bodylen;
+#else
+ if (!stream->do_byte_swap ())
+ *ACE_reinterpret_cast (CORBA::ULong *,
+ buf + offset) = bodylen;
+ else
+ ACE_CDR::swap_4 (ACE_reinterpret_cast (char *,
+ &bodylen),
+ buf + offset);
+#endif /* ACE_ENABLE_SWAP_ON_WRITE */
+
+ // Strictly speaking, should not need to loop here because the
+ // socket never gets set to a nonblocking mode ... some Linux
+ // versions seem to need it though. Leaving it costs little.
+ TAO_GIOP_Utils::dump_msg ("send",
+ ACE_reinterpret_cast (u_char *,
+ buf),
+ stream.length ());
+
+ // This guarantees to send all data (bytes) or return an error.
+ ssize_t n = transport->send (stub,
+ stream.begin (),
+ max_wait_time);
- // Conversion from the Pluggable Message types to the GIOP types.
- switch (t)
+ if (n == -1)
{
- case (TAO_MESSAGE_REQUEST):
- type = TAO_GIOP_REQUEST;
- break;
- case (TAO_MESSAGE_REPLY):
- type = TAO_GIOP_REPLY;
- break;
- case (TAO_MESSAGE_CANCELREQUEST):
- type = TAO_GIOP_CANCELREQUEST;
- break;
- case (TAO_MESSAGE_LOCATEREQUEST):
- type = TAO_GIOP_LOCATEREQUEST;
- break;
- case (TAO_MESSAGE_LOCATEREPLY):
- type = TAO_GIOP_LOCATEREPLY;
- break;
- case (TAO_MESSAGE_CLOSECONNECTION):
- type = TAO_GIOP_CLOSECONNECTION;
- break;
- case (TAO_MESSAGE_MESSAGERROR):
- type = TAO_GIOP_MESSAGERROR;
- break;
- case (TAO_MESSAGE_FRAGMENT):
- type = TAO_GIOP_FRAGMENT;
- break;
+ if (TAO_orbdebug)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO: (%P|%t) closing conn %d after fault %p\n",
+ transport->handle (),
+ "GIOP_Message_Factory::send_message ()"));
+
+ return -1;
+ }
+
+ // EOF.
+ if (n == 0)
+ {
+ if (TAO_orbdebug)
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO: (%P|%t) GIOP::send_message () "
+ "EOF, closing conn %d\n",
+ transport->handle()));
+ return -1;
}
+
+ return 1;
+}
+
+
+
+int
+TAO_GIOP_Utils::read_bytes_input (TAO_Transport *transport,
+ TAO_InputCDR &input,
+ CORBA::ULong read_size,
+ ACE_Time_Value *max_wait_time)
+{
+ //@@ Need to do something here for GIOPlite.
+
+ // Grow the size of CDR stream
+ if (input.grow (read_size) == -1)
+ return -1;
- msg.write_octet ((CORBA::Octet) type);
+ // Read until all the header is received. There should be no
+ // problems with locking, the header is only a few bytes so they
+ // should all be available on the socket, otherwise there is a
+ // problem with the underlying transport, in which case we have more
+ // problems than just this small loop.
+ char *buf = input.rd_ptr ();
+ ssize_t n = 0;
- // Write a dummy <size> later it is set to the right value...
- CORBA::ULong size = 0;
- msg.write_ulong (size);
+ for (int t = read_size;
+ t != 0;
+ t -= n)
+ {
+ n = transport->recv (buf, t, max_wait_time);
+ if (n == -1)
+ return -1;
+ else if (n == 0) // @@ TODO && errno != EWOULDBLOCK)
+ return -1;
+ buf += n;
+ }
return 1;
}
+
+
+int
+TAO_GIOP_Utils::parse_giop_header (TAO_GIOP_Message_State *state,
+ TAO_InputCDR &input)
+{
+ char *buf = input.rd_ptr ();
+
+ // Let us be specific that it is for 1.0
+ if (state->giop_version.minor == 0 &&
+ state->giop_version.major == 1)
+ {
+ state->byte_order = buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET];
+ if (TAO_debug_level > 2
+ && state->byte_order != 0 && state->byte_order != 1)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) invalid byte order <%d>"
+ " for version <1.0>\n",
+ state->byte_order));
+ return -1;
+ }
+ }
+ // Other revisions
+ else
+ {
+ state->byte_order =
+ (CORBA::Octet)(buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x01);
+ state->more_fragments =
+ (CORBA::Octet) (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET]& 0x02);
+
+ if (TAO_debug_level > 2
+ && (buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET] & ~0x3) != 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) invalid flags for <%d>"
+ " for version <%d %d> \n",
+ buf[TAO_GIOP_MESSAGE_FLAGS_OFFSET],
+ state->giop_version.major,
+ state->giop_version.minor));
+ return -1;
+ }
+
+ }
+
+ // Get the message type
+ state->message_type = buf[TAO_GIOP_MESSAGE_TYPE_OFFSET];
+
+ // Reset our input CDR stream
+ input.reset_byte_order (state->byte_order);
+
+
+ input.skip_bytes (TAO_GIOP_MESSAGE_SIZE_OFFSET);
+ input.read_ulong (state->message_size);
+
+ if (TAO_debug_level > 2)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "TAO (%P|%t) Parsed header = <%d,%d,%d,%d,%d>\n",
+ state->giop_version.major,
+ state->giop_version.minor,
+ state->byte_order,
+ state->message_type,
+ state->message_size));
+ }
+
+ return 1;
+}
+
+ssize_t
+TAO_GIOP_Utils::read_buffer (TAO_Transport *transport,
+ char *buf,
+ size_t len,
+ ACE_Time_Value *max_wait_time)
+{
+ ssize_t bytes_read = transport->recv (buf, len, max_wait_time);
+
+ if (bytes_read <= 0 && TAO_debug_level > 0)
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("TAO (%P|%t) - %p,\n")
+ ASYS_TEXT (" transport = %d, ")
+ ASYS_TEXT ("bytes = %d, len = %d\n"),
+ ASYS_TEXT ("TAO_GIOP::read_buffer"),
+ transport->handle (),
+ bytes_read,
+ len));
+
+ if (bytes_read == -1 && errno == ECONNRESET)
+ {
+ // @@ Is this OK??
+
+ // We got a connection reset (TCP RSET) from the other side,
+ // i.e., they didn't initiate a proper shutdown.
+ //
+ // Make it look like things are OK to the upper layer.
+ bytes_read = 0;
+ errno = 0;
+ }
+
+ return bytes_read;
+}
diff --git a/TAO/tao/IIOP_Acceptor.cpp b/TAO/tao/IIOP_Acceptor.cpp
index f9c8d5eb89a..380259e5438 100644
--- a/TAO/tao/IIOP_Acceptor.cpp
+++ b/TAO/tao/IIOP_Acceptor.cpp
@@ -6,7 +6,6 @@
#include "tao/MProfile.h"
#include "tao/ORB_Core.h"
#include "tao/Server_Strategy_Factory.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
#if !defined(__ACE_INLINE__)
diff --git a/TAO/tao/IIOP_Connect.cpp b/TAO/tao/IIOP_Connect.cpp
index 3e1037ba6cc..3c166494dad 100644
--- a/TAO/tao/IIOP_Connect.cpp
+++ b/TAO/tao/IIOP_Connect.cpp
@@ -7,7 +7,6 @@
#include "tao/ORB_Core.h"
#include "tao/ORB.h"
#include "tao/CDR.h"
-#include "tao/GIOP.h"
#if !defined (__ACE_INLINE__)
# include "tao/IIOP_Connect.i"
@@ -87,6 +86,12 @@ TAO_IIOP_Server_Connection_Handler::TAO_IIOP_Server_Connection_Handler (TAO_ORB_
tss_resources_ (orb_core->get_tss_resources ()),
refcount_ (1)
{
+ // OK, Here is a small twist. By now the all the objecs cached in
+ // this class would have been constructed. But we would like to make
+ // the one of the objects, precisely the transport object a pointer
+ // to the Messaging object. So, we set this up properly by calling
+ // the messaging_init method on the transport.
+ this->transport_.messaging_init (& this->acceptor_factory_);
}
TAO_IIOP_Server_Connection_Handler::~TAO_IIOP_Server_Connection_Handler (void)
@@ -264,10 +269,10 @@ TAO_IIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE,
{
this->refcount_++;
- int result = TAO_GIOP::handle_input (this->transport (),
- this->orb_core_,
- this->transport_.message_state_,
- max_wait_time);
+ int result = this->acceptor_factory_.handle_input (this->transport (),
+ this->orb_core_,
+ this->transport_.message_state_,
+ max_wait_time);
if (result == -1 && TAO_debug_level > 0)
{
@@ -308,11 +313,12 @@ TAO_IIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE,
// Reset the message state.
this->transport_.message_state_.reset (0);
- result = TAO_GIOP::process_server_message (this->transport (),
- this->orb_core_,
- input_cdr,
- message_type,
- giop_version);
+ result =
+ this->acceptor_factory_.process_connector_messages (this->transport (),
+ this->orb_core_,
+ input_cdr,
+ message_type);
+
if (result != -1)
result = 0;
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp
index e5b76be354b..3c759328dba 100644
--- a/TAO/tao/IIOP_Connector.cpp
+++ b/TAO/tao/IIOP_Connector.cpp
@@ -3,7 +3,6 @@
#include "tao/IIOP_Connector.h"
#include "tao/IIOP_Profile.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
#include "tao/Client_Strategy_Factory.h"
diff --git a/TAO/tao/IIOP_Profile.cpp b/TAO/tao/IIOP_Profile.cpp
index 95a3abf3391..0d35b7c28c9 100644
--- a/TAO/tao/IIOP_Profile.cpp
+++ b/TAO/tao/IIOP_Profile.cpp
@@ -5,7 +5,6 @@
#include "tao/IIOP_Profile.h"
#include "tao/IIOP_Connect.h"
-#include "tao/GIOP.h"
#include "tao/CDR.h"
#include "tao/Environment.h"
#include "tao/ORB.h"
diff --git a/TAO/tao/IIOP_Transport.cpp b/TAO/tao/IIOP_Transport.cpp
index 44cb47c278b..0b0c132ad6e 100644
--- a/TAO/tao/IIOP_Transport.cpp
+++ b/TAO/tao/IIOP_Transport.cpp
@@ -94,11 +94,7 @@ TAO_IIOP_Transport::event_handler (void)
return this->handler_;
}
-void
-TAO_IIOP_Transport::messaging_init (TAO_Pluggable_Message_Factory *mesg)
-{
- this->giop_factory_ = mesg;
-}
+
// ****************************************************************
TAO_IIOP_Server_Transport::
@@ -114,6 +110,13 @@ TAO_IIOP_Server_Transport::~TAO_IIOP_Server_Transport (void)
{
}
+void
+TAO_IIOP_Server_Transport::messaging_init (TAO_Pluggable_Server_Message_Factory *mesg)
+{
+ this->server_mesg_factory_ = mesg;
+}
+
+
// ****************************************************************
TAO_IIOP_Client_Transport::
@@ -129,6 +132,8 @@ TAO_IIOP_Client_Transport::~TAO_IIOP_Client_Transport (void)
{
}
+
+
TAO_IIOP_Client_Connection_Handler *
TAO_IIOP_Client_Transport::client_handler (void)
{
@@ -136,15 +141,15 @@ TAO_IIOP_Client_Transport::client_handler (void)
}
void
-TAO_IIOP_Client_Transport::start_request (TAO_ORB_Core *orb_core,
- const TAO_Profile* pfile,
+TAO_IIOP_Client_Transport::start_request (TAO_ORB_Core */*orb_core*/,
+ TAO_Stub * /*stub*/,
TAO_OutputCDR &output,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_FUNCTION_PP_TIMEPROBE (TAO_IIOP_CLIENT_TRANSPORT_START_REQUEST_START);
- const TAO_IIOP_Profile* profile =
+ /*const TAO_IIOP_Profile* profile =
ACE_dynamic_cast(const TAO_IIOP_Profile*, pfile);
// @@ This should be implemented in the transport object, which
@@ -152,36 +157,42 @@ TAO_IIOP_Client_Transport::start_request (TAO_ORB_Core *orb_core,
if (TAO_GIOP::start_message (profile->version (),
TAO_GIOP::Request,
output,
- orb_core) == 0)
+ orb_core) == 0)*/
+ if (this->client_mesg_factory_->start_message (TAO_MESSAGE_REQUEST,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
}
void
-TAO_IIOP_Client_Transport::start_locate (TAO_ORB_Core *orb_core,
- const TAO_Profile* pfile,
+TAO_IIOP_Client_Transport::start_locate (TAO_ORB_Core */*orb_core*/,
+ TAO_Stub *stub,
+ const short address_disposition,
CORBA::ULong request_id,
TAO_OutputCDR &output,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- const TAO_IIOP_Profile* profile =
- ACE_dynamic_cast(const TAO_IIOP_Profile*, pfile);
+ /* const TAO_IIOP_Profile* profile =
+ ACE_dynamic_cast(const TAO_IIOP_Profile*, pfile); */
// Obtain object key.
- const TAO_ObjectKey& key = profile->object_key ();
+ //const TAO_ObjectKey& key = profile->object_key ();
// @@ This should be implemented in the transport object, which
// would query the profile to obtain the version...
- if (TAO_GIOP::start_message (profile->version (),
+ /*if (TAO_GIOP::start_message (profile->version (),
TAO_GIOP::LocateRequest,
output,
- orb_core) == 0)
+ orb_core) == 0)*/
+ if (this->client_mesg_factory_->start_message (TAO_MESSAGE_LOCATEREQUEST,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
-
-
- if (TAO_GIOP::write_locate_request_header (request_id,
- key,
- output) == 0)
+
+
+ if (this->client_mesg_factory_->write_locate_request_header (request_id,
+ stub,
+ address_disposition,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
}
@@ -196,11 +207,10 @@ TAO_IIOP_Client_Transport::send_request (TAO_Stub *stub,
two_way) == -1)
return -1;
- if (TAO_GIOP::send_message (this,
- stream,
- orb_core,
- max_wait_time,
- stub) == -1)
+ if (this->client_mesg_factory_->send_message (this,
+ stream,
+ max_wait_time,
+ stub) == -1)
return -1;
return this->idle_after_send ();
@@ -231,10 +241,10 @@ TAO_IIOP_Client_Transport::handle_client_input (int /* block */,
return -1;
}
- int result = TAO_GIOP::handle_input (this,
- this->orb_core_,
- *message_state,
- max_wait_time);
+ int result = this->client_mesg_factory_->handle_input (this,
+ this->orb_core_,
+ *message_state,
+ max_wait_time);
if (result == -1)
{
if (TAO_debug_level > 0)
@@ -252,12 +262,11 @@ TAO_IIOP_Client_Transport::handle_client_input (int /* block */,
CORBA::ULong request_id;
CORBA::ULong reply_status;
- result = TAO_GIOP::parse_reply (this,
- this->orb_core_,
- *message_state,
- reply_ctx,
- request_id,
- reply_status);
+ result = this->client_mesg_factory_->parse_reply (this,
+ *message_state,
+ reply_ctx,
+ request_id,
+ reply_status);
if (result == -1)
{
if (TAO_debug_level > 0)
@@ -312,6 +321,36 @@ TAO_IIOP_Client_Transport::register_handler (void)
ACE_Event_Handler::READ_MASK);
}
+void
+TAO_IIOP_Client_Transport::messaging_init (TAO_Pluggable_Client_Message_Factory *mesg)
+{
+ this->client_mesg_factory_ = mesg;
+}
+
+CORBA::Boolean
+TAO_IIOP_Client_Transport::send_request_header (const IOP::ServiceContextList & svc_ctx,
+ CORBA::ULong request_id,
+ CORBA::Octet response_flags,
+ TAO_Stub *stub,
+ const CORBA::Short address_disposition,
+ const char* opname,
+ TAO_OutputCDR & msg)
+{
+ // We are going to pass on this request to the underlying messaging
+ // layer. It should take care of this request
+ CORBA::Boolean retval =
+ this->client_mesg_factory_->write_request_header (svc_ctx,
+ request_id,
+ response_flags,
+ stub,
+ address_disposition,
+ opname,
+ msg);
+
+ return retval;
+}
+
+
// *********************************************************************
ssize_t
@@ -382,26 +421,17 @@ TAO_IIOP_Transport::send_request (TAO_Stub *,
return -1;
}
+
+
CORBA::Boolean
-TAO_IIOP_Transport::send_request_header (const IOP::ServiceContextList & svc_ctx,
- CORBA::ULong request_id,
- CORBA::Octet response_flags,
- TAO_Stub *stub,
- const CORBA::Short address_disposition,
- const char* opname,
- TAO_OutputCDR & msg)
+TAO_IIOP_Transport::send_request_header (const IOP::ServiceContextList & /*svc_ctx*/,
+ CORBA::ULong /*request_id*/,
+ CORBA::Octet /*response_flags*/,
+ TAO_Stub * /*stub*/,
+ const CORBA::Short /*address_disposition*/,
+ const char* /*opname*/,
+ TAO_OutputCDR & /*msg*/)
{
- // We are going to pass on this request to the underlying messaging
- // layer. It should take care of this request
- CORBA::Boolean retval =
- this->giop_factory_->write_request_header (svc_ctx,
- request_id,
- response_flags,
- stub,
- address_disposition,
- opname,
- msg);
-
- return retval;
+ // We should never be here. So return an error.
+ return 0;
}
-
diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp
index 395e3394f7d..bac5d6e0bb6 100644
--- a/TAO/tao/Invocation.cpp
+++ b/TAO/tao/Invocation.cpp
@@ -551,7 +551,7 @@ TAO_GIOP_Twoway_Invocation::start (CORBA::Environment &ACE_TRY_ENV)
ACE_CHECK;
this->transport_->start_request (this->orb_core_,
- this->profile_,
+ this->stub_,
this->out_stream_,
ACE_TRY_ENV);
}
@@ -944,7 +944,7 @@ TAO_GIOP_Oneway_Invocation::start (CORBA::Environment &ACE_TRY_ENV)
ACE_CHECK;
this->transport_->start_request (this->orb_core_,
- this->profile_,
+ this->stub_,
this->out_stream_,
ACE_TRY_ENV);
}
@@ -1145,7 +1145,8 @@ TAO_GIOP_Locate_Request_Invocation::start (CORBA::Environment &ACE_TRY_ENV)
ACE_CHECK;
this->transport_->start_locate (this->orb_core_,
- this->profile_,
+ this->stub_,
+ TAO_GIOP_Invocation::Key_Addr,
this->request_id_,
this->out_stream_,
ACE_TRY_ENV);
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 3726cf64f2f..ec2c6aeac58 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -27,7 +27,6 @@
#include "tao/CDR.h"
#include "tao/Marshal.h"
#include "tao/IOR_LookupTable.h"
-#include "tao/GIOP.h"
#include "tao/Object_Adapter.h"
#include "tao/POA.h"
#include "tao/Request.h"
diff --git a/TAO/tao/Object.cpp b/TAO/tao/Object.cpp
index 76e93af55dc..896f7880790 100644
--- a/TAO/tao/Object.cpp
+++ b/TAO/tao/Object.cpp
@@ -11,7 +11,6 @@
#include "tao/Servant_Base.h"
#include "tao/Request.h"
#include "tao/varout.h"
-#include "tao/GIOP.h"
#include "tao/ORB_Core.h"
#include "tao/Invocation.h"
#include "tao/Connector_Registry.h"
diff --git a/TAO/tao/Pluggable.cpp b/TAO/tao/Pluggable.cpp
index 91e70d2bf07..07a64104264 100644
--- a/TAO/tao/Pluggable.cpp
+++ b/TAO/tao/Pluggable.cpp
@@ -3,7 +3,6 @@
#include "tao/Pluggable.h"
#include "tao/Stub.h"
#include "tao/Environment.h"
-#include "tao/GIOP.h"
#include "tao/ORB_Core.h"
#include "tao/Client_Strategy_Factory.h"
#include "tao/Wait_Strategy.h"
@@ -218,7 +217,7 @@ TAO_Transport::leader_follower_condition_variable (void)
void
TAO_Transport::start_request (TAO_ORB_Core *,
- const TAO_Profile *,
+ TAO_Stub * ,
TAO_OutputCDR &,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
@@ -228,7 +227,8 @@ TAO_Transport::start_request (TAO_ORB_Core *,
void
TAO_Transport::start_locate (TAO_ORB_Core *,
- const TAO_Profile *,
+ TAO_Stub * /*stub*/,
+ const short ,
CORBA::ULong,
TAO_OutputCDR &,
CORBA::Environment &ACE_TRY_ENV)
diff --git a/TAO/tao/Pluggable_Messaging.cpp b/TAO/tao/Pluggable_Messaging.cpp
index 8d3ef8f54b2..e5e99dd9dc9 100644
--- a/TAO/tao/Pluggable_Messaging.cpp
+++ b/TAO/tao/Pluggable_Messaging.cpp
@@ -1,6 +1,8 @@
-#include "Pluggable_Messaging.h"
//$Id$
-#if defined (__ACE_INLINE__)
+
+#include "Pluggable_Messaging.h"
+
+#if !defined (__ACE_INLINE__)
# include "tao/Pluggable_Messaging.i"
#endif /* __ACE_INLINE__ */
@@ -10,25 +12,14 @@
// Methods for the Pluugable Messaging stuff
/////////////////////////////////////////////////////////////////////////
-TAO_Pluggable_Client_Message_Factory::TAO_Pluggable_Client_Message_Factory (void)
-{
- //no-op
-}
-
-
TAO_Pluggable_Client_Message_Factory::~TAO_Pluggable_Client_Message_Factory (void)
{
- //no-op
}
-TAO_Pluggable_Server_Message_Factory::TAO_Pluggable_Server_Message_Factory (void)
+TAO_Pluggable_Server_Message_Factory::~TAO_Pluggable_Server_Message_Factory (void)
{
- //no-op
}
-
-TAO_Pluggable_Server_Message_Factory::~TAO_Pluggable_Server_Message_Factory (void)
+TAO_Message_State_Factory::~TAO_Message_State_Factory (void)
{
- //no-op
}
-
diff --git a/TAO/tao/Request.cpp b/TAO/tao/Request.cpp
index fa214e0d859..61ca8ba1ddb 100644
--- a/TAO/tao/Request.cpp
+++ b/TAO/tao/Request.cpp
@@ -1,12 +1,12 @@
// $Id$
#include "tao/Request.h"
+#include "tao/GIOP_Utils.h"
#if !defined (TAO_HAS_MINIMUM_CORBA)
#include "tao/Object.h"
#include "tao/Stub.h"
-#include "tao/GIOP.h"
#if !defined (__ACE_INLINE__)
# include "tao/Request.i"
diff --git a/TAO/tao/Stub.cpp b/TAO/tao/Stub.cpp
index 311dca5ec6c..88181b3286a 100644
--- a/TAO/tao/Stub.cpp
+++ b/TAO/tao/Stub.cpp
@@ -13,7 +13,6 @@
#include "tao/Stub.h"
#include "tao/Sequence.h"
#include "tao/Object.h"
-#include "tao/GIOP.h"
#include "tao/NVList.h"
#include "tao/Invocation.h"
#include "tao/Asynch_Invocation.h"
diff --git a/TAO/tao/Typecode_Constants.cpp b/TAO/tao/Typecode_Constants.cpp
index 640d27bd2b9..ed7a1f23586 100644
--- a/TAO/tao/Typecode_Constants.cpp
+++ b/TAO/tao/Typecode_Constants.cpp
@@ -28,7 +28,7 @@
#include "tao/Typecode.h"
#include "tao/ORB.h"
-#include "tao/GIOP.h"
+//#include "tao/GIOP.h"
#include "tao/Object.h"
#include "tao/Object_KeyC.h"
#include "tao/PolicyC.h"
diff --git a/TAO/tao/UIOP_Acceptor.cpp b/TAO/tao/UIOP_Acceptor.cpp
index f58eedcd1b4..c5ceb7b0a3c 100644
--- a/TAO/tao/UIOP_Acceptor.cpp
+++ b/TAO/tao/UIOP_Acceptor.cpp
@@ -23,7 +23,6 @@
#include "tao/UIOP_Profile.h"
#include "tao/MProfile.h"
#include "tao/ORB_Core.h"
-#include "tao/GIOP.h"
#include "tao/Server_Strategy_Factory.h"
#include "tao/debug.h"
diff --git a/TAO/tao/UIOP_Connect.cpp b/TAO/tao/UIOP_Connect.cpp
index b169fc906bf..2da73ae0504 100644
--- a/TAO/tao/UIOP_Connect.cpp
+++ b/TAO/tao/UIOP_Connect.cpp
@@ -5,7 +5,6 @@
#if defined (TAO_HAS_UIOP)
#include "tao/UIOP_Transport.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
#include "tao/ORB.h"
@@ -90,6 +89,12 @@ TAO_UIOP_Server_Connection_Handler::TAO_UIOP_Server_Connection_Handler (TAO_ORB_
tss_resources_ (orb_core->get_tss_resources ()),
refcount_ (1)
{
+ // OK, Here is a small twist. By now the all the objects cached in
+ // this class would have been constructed. But we would like to make
+ // the one of the objects, precisely the transport object a pointer
+ // to the Messaging object. So, we set this up properly by calling
+ // the messaging_init method on the transport.
+ this->transport_.messaging_init (& this->acceptor_factory_);
}
TAO_UIOP_Server_Connection_Handler::~TAO_UIOP_Server_Connection_Handler (void)
@@ -248,10 +253,11 @@ TAO_UIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE,
{
this->refcount_++;
- int result = TAO_GIOP::handle_input (this->transport (),
- this->orb_core_,
- this->transport_.message_state_,
- max_wait_time);
+ int result =
+ this->acceptor_factory_.handle_input (this->transport (),
+ this->orb_core_,
+ this->transport_.message_state_,
+ max_wait_time);
if (result == -1 && TAO_debug_level > 0)
{
@@ -292,11 +298,12 @@ TAO_UIOP_Server_Connection_Handler::handle_input_i (ACE_HANDLE,
// Reset the message state.
this->transport_.message_state_.reset (0);
- result = TAO_GIOP::process_server_message (this->transport (),
- this->orb_core_,
- input_cdr,
- message_type,
- giop_version);
+ result =
+ this->acceptor_factory_.process_connector_messages (this->transport (),
+ this->orb_core_,
+ input_cdr,
+ message_type);
+
if (result != -1)
result = 0;
@@ -316,6 +323,12 @@ TAO_UIOP_Client_Connection_Handler (ACE_Thread_Manager *t,
transport_ (this, orb_core),
orb_core_ (orb_core)
{
+ // OK, Here is a small twist. By now the all the objecs cached in
+ // this class would have been constructed. But we would like to make
+ // the one of the objects, precisely the transport object a pointer
+ // to the Messaging object. So, we set this up properly by calling
+ // the messaging_init method on the transport.
+ this->transport_.messaging_init (& this->message_factory_);
}
TAO_UIOP_Client_Connection_Handler::~TAO_UIOP_Client_Connection_Handler (void)
diff --git a/TAO/tao/UIOP_Connector.cpp b/TAO/tao/UIOP_Connector.cpp
index 4d2a04e344b..0ef939813a6 100644
--- a/TAO/tao/UIOP_Connector.cpp
+++ b/TAO/tao/UIOP_Connector.cpp
@@ -5,7 +5,6 @@
#if defined (TAO_HAS_UIOP)
#include "tao/UIOP_Profile.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
#include "tao/ORB_Core.h"
#include "tao/Environment.h"
diff --git a/TAO/tao/UIOP_Profile.cpp b/TAO/tao/UIOP_Profile.cpp
index d504d07ea64..fe4c8a2296b 100644
--- a/TAO/tao/UIOP_Profile.cpp
+++ b/TAO/tao/UIOP_Profile.cpp
@@ -5,7 +5,6 @@
#if defined (TAO_HAS_UIOP)
-#include "tao/GIOP.h"
#include "tao/CDR.h"
#include "tao/Environment.h"
#include "tao/ORB.h"
diff --git a/TAO/tao/UIOP_Transport.cpp b/TAO/tao/UIOP_Transport.cpp
index 6fe5104caa0..581ec29a25b 100644
--- a/TAO/tao/UIOP_Transport.cpp
+++ b/TAO/tao/UIOP_Transport.cpp
@@ -96,11 +96,6 @@ TAO_UIOP_Transport::event_handler (void)
return this->handler_;
}
-void
-TAO_UIOP_Transport::messaging_init (TAO_Pluggable_Message_Factory *mesg)
-{
- this->giop_factory_ = mesg;
-}
// ****************************************************************
TAO_UIOP_Server_Transport::
@@ -117,6 +112,12 @@ TAO_UIOP_Server_Transport::~TAO_UIOP_Server_Transport (void)
{
}
+void
+TAO_UIOP_Server_Transport::messaging_init (TAO_Pluggable_Server_Message_Factory *mesg)
+{
+ this->server_mesg_factory_ = mesg;
+}
+
// ****************************************************************
TAO_UIOP_Client_Transport::
@@ -138,52 +139,50 @@ TAO_UIOP_Client_Transport::client_handler (void)
}
void
-TAO_UIOP_Client_Transport::start_request (TAO_ORB_Core *orb_core,
- const TAO_Profile* pfile,
+TAO_UIOP_Client_Transport::start_request (TAO_ORB_Core */*orb_core*/,
+ const TAO_Profile* /*pfile*/,
TAO_OutputCDR &output,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
TAO_FUNCTION_PP_TIMEPROBE (TAO_UIOP_CLIENT_TRANSPORT_START_REQUEST_START);
- const TAO_UIOP_Profile* profile =
- ACE_dynamic_cast(const TAO_UIOP_Profile*, pfile);
+ /*const TAO_UIOP_Profile* profile =
+ ACE_dynamic_cast(const TAO_UIOP_Profile*, pfile);*/
// @@ This should be implemented in the transport object, which
// would query the profile to obtain the version...
- if (TAO_GIOP::start_message (profile->version (),
- TAO_GIOP::Request,
- output,
- orb_core) == 0)
+ if (this->client_mesg_factory_->start_message (TAO_MESSAGE_REQUEST,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
}
void
-TAO_UIOP_Client_Transport::start_locate (TAO_ORB_Core *orb_core,
- const TAO_Profile* pfile,
+TAO_UIOP_Client_Transport::start_locate (TAO_ORB_Core * /*orb_core*/,
+ TAO_Stub *stub,
+ const short add_dis,
CORBA::ULong request_id,
TAO_OutputCDR &output,
CORBA::Environment &ACE_TRY_ENV)
ACE_THROW_SPEC ((CORBA::SystemException))
{
- const TAO_UIOP_Profile* profile =
- ACE_dynamic_cast(const TAO_UIOP_Profile*, pfile);
+ //const TAO_UIOP_Profile* profile =
+ // ACE_dynamic_cast(const TAO_UIOP_Profile*, pfile);
// Obtain object key.
- const TAO_ObjectKey& key = profile->object_key ();
+ //const TAO_ObjectKey& key = profile->object_key ();
// @@ This should be implemented in the transport object, which
// would query the profile to obtain the version...
- if (TAO_GIOP::start_message (profile->version (),
- TAO_GIOP::LocateRequest,
- output,
- orb_core) == 0)
+ if (this->client_mesg_factory_->start_message (TAO_MESSAGE_LOCATEREQUEST,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
- if (TAO_GIOP::write_locate_request_header (request_id,
- key,
- output) == 0)
+ if (this->client_mesg_factory_->write_locate_request_header (request_id,
+ stub,
+ add_dis,
+ output) == 0)
ACE_THROW (CORBA::MARSHAL ());
}
@@ -198,11 +197,10 @@ TAO_UIOP_Client_Transport::send_request (TAO_Stub *stub,
two_way) == -1)
return -1;
- if (TAO_GIOP::send_message (this,
- stream,
- orb_core,
- max_wait_time,
- stub) == -1)
+ if (this->client_mesg_factory_->send_message (this,
+ stream,
+ max_wait_time,
+ stub) == -1)
return -1;
return this->idle_after_send ();
@@ -233,10 +231,10 @@ TAO_UIOP_Client_Transport::handle_client_input (int /* block */,
return -1;
}
- int result = TAO_GIOP::handle_input (this,
- this->orb_core_,
- *message_state,
- max_wait_time);
+ int result = this->client_mesg_factory_->handle_input (this,
+ this->orb_core_,
+ *message_state,
+ max_wait_time);
if (result == -1)
{
if (TAO_debug_level > 0)
@@ -254,12 +252,11 @@ TAO_UIOP_Client_Transport::handle_client_input (int /* block */,
CORBA::ULong request_id;
CORBA::ULong reply_status;
- result = TAO_GIOP::parse_reply (this,
- this->orb_core_,
- *message_state,
- reply_ctx,
- request_id,
- reply_status);
+ result = this->client_mesg_factory_->parse_reply (this,
+ *message_state,
+ reply_ctx,
+ request_id,
+ reply_status);
if (result == -1)
{
if (TAO_debug_level > 0)
@@ -315,6 +312,35 @@ TAO_UIOP_Client_Transport::register_handler (void)
ACE_Event_Handler::READ_MASK);
}
+
+void
+TAO_UIOP_Client_Transport::messaging_init (TAO_Pluggable_Client_Message_Factory *mesg)
+{
+ this->client_mesg_factory_ = mesg;
+}
+
+CORBA::Boolean
+TAO_UIOP_Client_Transport::send_request_header (const IOP::ServiceContextList & svc_ctx,
+ CORBA::ULong request_id,
+ CORBA::Octet response_flags,
+ TAO_Stub *stub,
+ const CORBA::Short address_disposition,
+ const char* opname,
+ TAO_OutputCDR & msg)
+{
+ // We are going to pass on this request to the underlying messaging
+ // layer. It should take care of this request
+ CORBA::Boolean retval =
+ this->client_mesg_factory_->write_request_header (svc_ctx,
+ request_id,
+ response_flags,
+ stub,
+ address_disposition,
+ opname,
+ msg);
+ return retval;
+}
+
// ****************************************************************
ssize_t
@@ -385,25 +411,16 @@ TAO_UIOP_Transport::send_request (TAO_Stub *,
}
CORBA::Boolean
-TAO_UIOP_Transport::send_request_header (const IOP::ServiceContextList & svc_ctx,
- CORBA::ULong request_id,
- CORBA::Octet response_flags,
- TAO_Stub *stub,
- const CORBA::Short address_disposition,
- const char* opname,
- TAO_OutputCDR & msg)
+TAO_UIOP_Transport::send_request_header (const IOP::ServiceContextList & /*svc_ctx*/,
+ CORBA::ULong /*request_id*/,
+ CORBA::Octet /*response_flags*/,
+ TAO_Stub * /*stub*/,
+ const CORBA::Short /*address_disposition*/,
+ const char* /*opname*/,
+ TAO_OutputCDR & /*msg*/)
{
- // We are going to pass on this request to the underlying messaging
- // layer. It should take care of this request
- CORBA::Boolean retval =
- this->giop_factory_->write_request_header (svc_ctx,
- request_id,
- response_flags,
- stub,
- address_disposition,
- opname,
- msg);
-
- return retval;
+ // We should never be here. So return an error.
+ return 0;
}
+
#endif /* TAO_HAS_UIOP */
diff --git a/TAO/tao/append.cpp b/TAO/tao/append.cpp
index aaaeefb9bb0..00a30db321c 100644
--- a/TAO/tao/append.cpp
+++ b/TAO/tao/append.cpp
@@ -23,7 +23,6 @@
#include "tao/CDR.h"
#include "tao/Environment.h"
#include "tao/Any.h"
-#include "tao/GIOP.h"
#include "tao/debug.h"
ACE_RCSID(tao, append, "$Id$")
diff --git a/TAO/tao/decode.cpp b/TAO/tao/decode.cpp
index b5f1ec542ee..06793f40c6b 100644
--- a/TAO/tao/decode.cpp
+++ b/TAO/tao/decode.cpp
@@ -26,7 +26,6 @@
#include "tao/Marshal.h"
#include "tao/CDR.h"
#include "tao/Environment.h"
-#include "tao/GIOP.h"
#include "tao/Any.h"
#include "tao/Principal.h"
#include "tao/MProfile.h"
diff --git a/TAO/tao/skip.cpp b/TAO/tao/skip.cpp
index e90366adb7d..086b0e41051 100644
--- a/TAO/tao/skip.cpp
+++ b/TAO/tao/skip.cpp
@@ -21,7 +21,6 @@
#include "tao/Marshal.h"
#include "tao/CDR.h"
-#include "tao/GIOP.h"
#include "tao/Any.h"
#include "tao/Environment.h"
#include "tao/debug.h"