From a35ad6a95dcda0a7134e283674628a375fb29ea5 Mon Sep 17 00:00:00 2001 From: bala Date: Sun, 16 Jan 2000 00:08:33 +0000 Subject: *** empty log message *** --- TAO/tao/GIOP_Message_Accept_State.cpp | 9 +- TAO/tao/GIOP_Message_Base.cpp | 88 +++++++++--- TAO/tao/GIOP_Message_Base.h | 21 +-- TAO/tao/GIOP_Message_Connectors.cpp | 52 +++---- TAO/tao/GIOP_Utils.cpp | 255 ---------------------------------- TAO/tao/GIOP_Utils.h | 49 +------ TAO/tao/TAOC.cpp | 8 ++ TAO/tao/TAOC.h | 7 +- 8 files changed, 127 insertions(+), 362 deletions(-) diff --git a/TAO/tao/GIOP_Message_Accept_State.cpp b/TAO/tao/GIOP_Message_Accept_State.cpp index faba9aa9c70..250adc7740a 100644 --- a/TAO/tao/GIOP_Message_Accept_State.cpp +++ b/TAO/tao/GIOP_Message_Accept_State.cpp @@ -13,7 +13,7 @@ int TAO_GIOP_Message_Accept_State_11:: parse_request_header (TAO_GIOP_ServerRequest &request) { - // Tear out the service context ... we currently ignore it, but it + // 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). // @@ -44,7 +44,12 @@ TAO_GIOP_Message_Accept_State_11:: 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)); + + // The high bit of the octet has been set if the SyncScope policy + // value is SYNC_WITH_SERVER. This is a temporary hack until all + // of GIOP 1.2 is in place. Then we can check the version in the + // message header instead. + request.sync_with_server ((response_flags == 129)); // We use ad-hoc demarshalling here: there is no need to increase // the reference count on the CDR message block, because this key diff --git a/TAO/tao/GIOP_Message_Base.cpp b/TAO/tao/GIOP_Message_Base.cpp index 72122e8d97a..c2dcb7f17c5 100644 --- a/TAO/tao/GIOP_Message_Base.cpp +++ b/TAO/tao/GIOP_Message_Base.cpp @@ -168,11 +168,11 @@ TAO_GIOP_Message_Base::send_message (TAO_Transport *transport, // 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->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, two_way, @@ -306,16 +306,72 @@ TAO_GIOP_Message_Base:: 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); + this->dump_msg ("recv", + ACE_reinterpret_cast (u_char *, + buf), + msg_len); } } return state->is_complete (); } +void +TAO_GIOP_Message_Base::dump_msg (const char *label, + const u_char *ptr, + size_t len) +{ + static const char digits [] = "0123456789ABCD"; + static const char *names [] = + { + "Request", + "Reply", + "CancelRequest", + "LocateRequest", + "LocateReply", + "CloseConnection", + "MessageError" + "Fragment" + }; + + if (TAO_debug_level >= 5) + { + // Message name. + const char *message_name = "UNKNOWN MESSAGE"; + u_long slot = ptr[this->message_type_offset ()]; + if (slot < sizeof (names)/sizeof(names[0])) + message_name = names [slot]; + + // Byte order. + int byte_order = ptr[this->flags_offset ()] & 0x01; + + // request/reply id. + CORBA::ULong tmp = 0; + CORBA::ULong *id = &tmp; + + if (ptr[this->message_type_offset ()] == TAO_GIOP_REQUEST || + ptr[this->message_type_offset ()] == TAO_GIOP_REPLY) + { + // @@ Only works if ServiceContextList is empty.... + id = ACE_reinterpret_cast (CORBA::ULong *, + (char * ) (ptr + this->header_len () + 4)); + } + + // Print. + ACE_DEBUG ((LM_DEBUG, + ASYS_TEXT ("(%P | %t):%s GIOP v%c.%c msg, ") + ASYS_TEXT ("%d data bytes, %s endian, %s = %d\n"), + label, + digits[ptr[this->major_version_offset ()]], + digits[ptr[this->minor_version_offset ()]], + len - this->header_len (), + (byte_order == TAO_ENCAP_BYTE_ORDER) ? "my" : "other", + message_name, + *id)); + + + } +} int TAO_GIOP_Message_Base::read_bytes_input (TAO_Transport *transport, @@ -512,10 +568,10 @@ TAO_GIOP_Message_Base::send_error (TAO_Transport *transport) // @@ Q: How does this works with GIOP lite? // A: It doesn't - TAO_GIOP_Utils::dump_msg ("send_error", - (const u_char *) error_message, - this->header_len ()); - + this->dump_msg ("send_error", + (const u_char *) error_message, + this->header_len ()); + ACE_HANDLE which = transport->handle (); int result = transport->send ((const u_char *)error_message, @@ -577,9 +633,9 @@ TAO_GIOP_Message_Base:: // @@ 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); + this->dump_msg ("send_close_connection", + (const u_char *) close_message, + TAO_GIOP_HEADER_LEN); ACE_HANDLE which = transport->handle (); if (which == ACE_INVALID_HANDLE) diff --git a/TAO/tao/GIOP_Message_Base.h b/TAO/tao/GIOP_Message_Base.h index b284df40f28..9df4a5e1c28 100644 --- a/TAO/tao/GIOP_Message_Base.h +++ b/TAO/tao/GIOP_Message_Base.h @@ -78,31 +78,27 @@ public: // passed on to the appropriate states. protected: - virtual const size_t header_len (void); + const size_t header_len (void); // This will give the size of the header for different versions of // GIOP. - virtual const size_t message_size_offset (void); + const size_t message_size_offset (void); // This will give the message_size offset as specified by different // versions of GIOP - virtual const size_t major_version_offset (void); + const size_t major_version_offset (void); // This will give the major_version offset as specified by different // versions of GIOP - virtual const size_t minor_version_offset (void); + const size_t minor_version_offset (void); // This will give the minor_version offset as specified by different // versions of GIOP - virtual const size_t flags_offset (void); + const size_t flags_offset (void); // This will give the flags offset as specified by different // versions of GIOP - // virtual const size_t message_size_offset (void); - // This will give the message size offset as specified by different - // versions of GIOP - - virtual const size_t message_type_offset (void); + const size_t message_type_offset (void); // This will give the message type offset as specified by different // versions of GIOP // @@The above methods may not be required. But we have it for a @@ -111,6 +107,11 @@ protected: int send_error (TAO_Transport *transport); // Send error messages + void dump_msg (const char *label, + const u_char *ptr, + size_t len); + // Print out a debug messages.. + private: virtual CORBA::Octet major_version (void) = 0; virtual CORBA::Octet minor_version (void) = 0; diff --git a/TAO/tao/GIOP_Message_Connectors.cpp b/TAO/tao/GIOP_Message_Connectors.cpp index 8203d7e3756..c4d6a4d9f1f 100644 --- a/TAO/tao/GIOP_Message_Connectors.cpp +++ b/TAO/tao/GIOP_Message_Connectors.cpp @@ -3,6 +3,7 @@ #include "tao/Any.h" #include "tao/debug.h" #include "tao/Principal.h" +#include "tao/TAOC.h" #if !defined (__ACE_INLINE__) # include "tao/GIOP_Message_Connectors.i" @@ -26,36 +27,27 @@ TAO_GIOP_Message_Connectors:: msg << request_id; // Second the response flags - switch (response_flags) - { - // We have to use magic numbers as the actual variables are - // declared as const short. They cannot be used in switch case - // statements. Probably what we can do is to add them as an - // definitions in this class or in the parent and then use the - // definitions. Hmm. Good idea.. But we will live with this for - // the time being. - case 0: // SYNC_NONE - case 1: // SYNC_WITH_TRANSPORT - case 4: // This one corresponds to the TAO extension SYNC_FLUSH. - // No response required. - msg << CORBA::Any::from_octet (0); - break; - case 2: // SYNC_WITH_SERVER - // Return before dispatching servant. - msg << CORBA::Any::from_octet (1); - break; - case 3: // SYNC_WITH_TARGET - // Return after dispatching servant. - msg << CORBA::Any::from_octet (3); - break; - // Some cases for the DII are missing here. We can add that once - // our IDL compiler starts supporting those stuff. This is - // 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: - return 0; - } + // Sync scope - ignored by server if request is not oneway. + if (response_flags == CORBA::Octet (TAO::SYNC_WITH_TRANSPORT) || + response_flags == CORBA::Octet (TAO::SYNC_NONE) || + response_flags == CORBA::Octet (TAO::SYNC_EAGER_BUFFERING) || + response_flags == CORBA::Octet (TAO::SYNC_DELAYED_BUFFERING)) + // No response required. + msg << CORBA::Any::from_octet (0); + + else if (response_flags == CORBA::Octet (TAO::SYNC_WITH_SERVER)) + // Return before dispatching servant. We're also setting the high + // bit here. This is a temporary fix until the rest of GIOP 1.2 is + // implemented in TAO. + msg << CORBA::Any::from_octet (129); + + else if (response_flags == CORBA::Octet (TAO::SYNC_WITH_TARGET)) + // Return after dispatching servant. + msg << CORBA::Any::from_octet (3); + + else + // Until more flags are defined by the OMG. + return 0; return 1; } diff --git a/TAO/tao/GIOP_Utils.cpp b/TAO/tao/GIOP_Utils.cpp index e1bd248523f..7e8516e98e0 100644 --- a/TAO/tao/GIOP_Utils.cpp +++ b/TAO/tao/GIOP_Utils.cpp @@ -110,259 +110,4 @@ TAO_GIOP_Message_State::append_fragment (ACE_Message_Block* current) } -void -TAO_GIOP_Utils::dump_msg (const char * /*label*/, - const u_char * /*ptr*/, - size_t /*len*/) -{ - if (TAO_debug_level >= 5) - { - // 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!! - } -} -//CORBA::Boolean -//TAO_GIOP_Utils::start_message (const TAO_GIOP_Version &version, -// TAO_GIOP_Message_Type t, -// TAO_OutputCDR &msg) -//{ -// 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) t); -// -// // Write a dummy 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); -// -// if (n == -1) -// { -// 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; -// -// // 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; -// -// 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/GIOP_Utils.h b/TAO/tao/GIOP_Utils.h index 776909cd8c0..8390a59419d 100644 --- a/TAO/tao/GIOP_Utils.h +++ b/TAO/tao/GIOP_Utils.h @@ -10,7 +10,7 @@ // GIOP_Message.h // // = DESCRIPTION -// Interface for the GIOP messaging protocol +// GIOP utility definitions // // = AUTHOR // Balachandran Natarajan @@ -237,53 +237,6 @@ private: -class TAO_Export TAO_GIOP_Utils -{ - // = TITLE - // Some utility methods for GIOP independent of versions of GIOP - // - // = DESCRIPTION - // Utility methods that would be used by both the Client and - // Server side methods in GIOP factory - -public: - - static void dump_msg (const char *label, - const u_char *ptr, - size_t len); - // Print out a debug messages.. - -// static CORBA::Boolean start_message (const TAO_GIOP_Version &version, -// TAO_GIOP_Message_Type t, -// TAO_OutputCDR &msg); -// -// // Build the header for a message of type into stream . -// -// -// static int send_message (TAO_Transport *transport, -// TAO_OutputCDR &output, -// const size_t header_len, -// const size_t message_offset, -// ACE_Time_Value *max_wait_time = 0, -// TAO_Stub *stub = 0); -// // Send the message on the wire using the right transport. -// -// static int read_bytes_input (TAO_Transport *transport, -// TAO_InputCDR &input, -// CORBA::ULong read_size, -// ACE_Time_Value *max_wait_time); -// -// static int parse_giop_header (TAO_GIOP_Message_State *state, -// TAO_InputCDR &input); -// -// static ssize_t read_buffer (TAO_Transport *transport, -// char *buf, -// size_t len, -// ACE_Time_Value *max_wait_time); -}; - - - #if defined (__ACE_INLINE__) # include "tao/GIOP_Utils.i" #endif /* __ACE_INLINE__ */ diff --git a/TAO/tao/TAOC.cpp b/TAO/tao/TAOC.cpp index 906027c5c04..5481a52e65a 100644 --- a/TAO/tao/TAOC.cpp +++ b/TAO/tao/TAOC.cpp @@ -547,3 +547,11 @@ TAO_NAMESPACE_TYPE (const CORBA::Short) TAO_NAMESPACE_BEGIN (TAO) TAO_NAMESPACE_DEFINE (const CORBA::Short, SYNC_WITH_TARGET, 3) TAO_NAMESPACE_END +TAO_NAMESPACE_TYPE (const CORBA::Short) +TAO_NAMESPACE_BEGIN (TAO) +TAO_NAMESPACE_DEFINE (const CORBA::Short, SYNC_EAGER_BUFFERING, 0) +TAO_NAMESPACE_END +TAO_NAMESPACE_TYPE (const CORBA::Short) +TAO_NAMESPACE_BEGIN (TAO) +TAO_NAMESPACE_DEFINE (const CORBA::Short, SYNC_DELAYED_BUFFERING, -1) +TAO_NAMESPACE_END diff --git a/TAO/tao/TAOC.h b/TAO/tao/TAOC.h index c0daffa336d..3f8b1fdecbf 100644 --- a/TAO/tao/TAOC.h +++ b/TAO/tao/TAOC.h @@ -1,6 +1,5 @@ /* -*- C++ -*- $Id$ */ - // ****** Code generated by the The ACE ORB (TAO) IDL Compiler ******* // TAO and the TAO IDL Compiler have been developed by the Center for // Distributed Object Computing at Washington University, St. Louis. @@ -411,6 +410,12 @@ class TAO_Export BufferingConstraintPolicy: public virtual CORBA::Policy TAO_NAMESPACE_STORAGE_CLASS const CORBA::Short SYNC_WITH_SERVER; TAO_NAMESPACE_STORAGE_CLASS const CORBA::Short SYNC_WITH_TARGET; + + // = TAO specific. + TAO_NAMESPACE_STORAGE_CLASS const CORBA::Short SYNC_EAGER_BUFFERING; + + TAO_NAMESPACE_STORAGE_CLASS const CORBA::Short SYNC_DELAYED_BUFFERING; + } TAO_NAMESPACE_CLOSE // module TAO -- cgit v1.2.1