diff options
Diffstat (limited to 'TAO/tao/GIOP.cpp')
-rw-r--r-- | TAO/tao/GIOP.cpp | 254 |
1 files changed, 123 insertions, 131 deletions
diff --git a/TAO/tao/GIOP.cpp b/TAO/tao/GIOP.cpp index e6ac6fd445a..ed04e369ec8 100644 --- a/TAO/tao/GIOP.cpp +++ b/TAO/tao/GIOP.cpp @@ -64,35 +64,35 @@ ACE_RCSID(tao, GIOP, "$Id$") #if defined (ACE_ENABLE_TIMEPROBES) static const char *TAO_GIOP_Timeprobe_Description[] = - { - "GIOP::send_request - start", - "GIOP::send_request - end", +{ + "GIOP::send_request - start", + "GIOP::send_request - end", - "GIOP::recv_request - start", - "GIOP::recv_request - end", + "GIOP::recv_request - start", + "GIOP::recv_request - end", - "GIOP::read_buffer - start", - "GIOP::read_buffer - end", + "GIOP::read_buffer - start", + "GIOP::read_buffer - end", - "GIOP::LocateRequestHeader_init - start", - "GIOP::LocateRequestHeader_init - end" - }; + "GIOP::LocateRequestHeader_init - start", + "GIOP::LocateRequestHeader_init - end" +}; enum - { - // Timeprobe description table start key - TAO_GIOP_SEND_REQUEST_START = 100, - TAO_GIOP_SEND_REQUEST_END, +{ + // Timeprobe description table start key + TAO_GIOP_SEND_REQUEST_START = 100, + TAO_GIOP_SEND_REQUEST_END, - TAO_GIOP_RECV_REQUEST_START, - TAO_GIOP_RECV_REQUEST_END, + TAO_GIOP_RECV_REQUEST_START, + TAO_GIOP_RECV_REQUEST_END, - TAO_GIOP_READ_BUFFER_START, - TAO_GIOP_READ_BUFFER_END, + TAO_GIOP_READ_BUFFER_START, + TAO_GIOP_READ_BUFFER_END, - TAO_GIOP_LOCATE_REQUEST_HEADER_INIT_START, - TAO_GIOP_LOCATE_REQUEST_HEADER_INIT_END - }; + TAO_GIOP_LOCATE_REQUEST_HEADER_INIT_START, + TAO_GIOP_LOCATE_REQUEST_HEADER_INIT_END +}; // Setup Timeprobes ACE_TIMEPROBE_EVENT_DESCRIPTIONS (TAO_GIOP_Timeprobe_Description, @@ -133,7 +133,7 @@ TAO_GIOP::dump_msg (const char *label, ACE_HEX_DUMP ((LM_DEBUG, (const char*)ptr, len, - "\n")); + "(%P|%t) data bytes\n")); } } @@ -201,7 +201,7 @@ TAO_GIOP::send_request (TAO_Transport *transport, TAO_ORB_Core *orb_core) { - TAO_FUNCTION_PP_TIMEPROBE (TAO_GIOP_SEND_REQUEST_START); + ACE_FUNCTION_TIMEPROBE (TAO_GIOP_SEND_REQUEST_START); char *buf = (char *) stream.buffer (); // ptr to first buffer size_t total_len = stream.total_length (); // length of all buffers @@ -219,6 +219,13 @@ TAO_GIOP::send_request (TAO_Transport *transport, // networking infrastructure (e.g., IPSEC). size_t header_len = TAO_GIOP_HEADER_LEN; + // @@ Ug, not sure what to do with this IIOP specific code! + // An idea would be to change this to ->use_lite_protocol + // that way it is not IIOP specific. fredk + // + // Fred: actually this is not IIOP specific; a better name would be + // "GIOP lite".... Carlos + // // Fred: this is actually a good start to think about pluggable // "messaging protocols" (maybe this is a bad name, but I want // to stress the difference with the pluggable "transport @@ -232,8 +239,8 @@ TAO_GIOP::send_request (TAO_Transport *transport, size_t offset = TAO_GIOP_MESSAGE_SIZE_OFFSET; if (orb_core->orb_params ()->use_lite_protocol ()) { - header_len = TAO_GIOP_LITE_HEADER_LEN; - offset = TAO_GIOP_LITE_MESSAGE_SIZE_OFFSET; + header_len = TAO_IIOP_LITE_HEADER_LEN; + offset = TAO_IIOP_LITE_MESSAGE_SIZE_OFFSET; } CORBA::ULong bodylen = total_len - header_len; @@ -245,48 +252,45 @@ TAO_GIOP::send_request (TAO_Transport *transport, *ACE_reinterpret_cast (CORBA::ULong *, buf + offset) = bodylen; else - ACE_CDR::swap_4 (ACE_reinterpret_cast (char *, - &bodylen), - buf + offset); + 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. +#if 0 TAO_GIOP::dump_msg ("send", ACE_reinterpret_cast (u_char *, buf), - stream.length ()); + total_len); +#endif // this guarantees to send all data (bytes) or return an error ssize_t n = transport->send (stream.begin ()); - if (n == -1) - { - if (TAO_orbdebug) - { - ACE_DEBUG ((LM_DEBUG, - "TAO: (%P|%t) closing conn %d after fault %p\n", - transport->handle (), - "GIOP::send_request ()")); - } - transport->close_connection (); - return 0; + if (n == -1) { + if (TAO_orbdebug) { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) closing conn %d after fault %p\n", + transport->handle (), "GIOP::send_request ()")); + } + transport->close_conn (); + return 0 ; } - // @@ Don't know about this one, when will we get a 0 from the write - // if we assume that there is data to write. I would only expect - // a 0 if there was nothing to send or if nonblocking. + // @@ Don't know about this one, when will we get a 0 from the write if we + // assume that there is data to write. I would only expect a 0 if there + // was nothing to send or if nonblocking. if (n == 0) { if (TAO_orbdebug) { ACE_DEBUG ((LM_DEBUG, - "TAO: (%P|%t) GIOP::send_request () " - "EOF, closing conn %d\n", - transport->handle())); + "(%P|%t) GIOP::send_request (): ", + "EOF, closing conn %d\n", transport->handle())); } - transport->close_connection (); + transport->close_conn(); return 0; } @@ -311,8 +315,7 @@ TAO_GIOP::send_request (TAO_Transport *transport, // static CORBA::Octet static const char close_message [TAO_GIOP_HEADER_LEN] = { - // 'G', 'I', 'O', 'P', - 0x47, 0x49, 0x4f, 0x50, // work on non-ASCII platforms... + 'G', 'I', 'O', 'P', TAO_GIOP_MessageHeader::MY_MAJOR, TAO_GIOP_MessageHeader::MY_MINOR, TAO_ENCAP_BYTE_ORDER, @@ -343,7 +346,7 @@ TAO_GIOP::close_connection (TAO_Transport *transport, void *) which)); } - transport->close_connection (); + transport->close_conn (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) shut down transport, handle %d\n", which)); } @@ -357,8 +360,7 @@ TAO_GIOP::close_connection (TAO_Transport *transport, void *) static const char error_message [TAO_GIOP_HEADER_LEN] = { - // 'G', 'I', 'O', 'P', - 0x47, 0x49, 0x4f, 0x50, // work on non-ASCII platforms... + 'G', 'I', 'O', 'P', TAO_GIOP_MessageHeader::MY_MAJOR, TAO_GIOP_MessageHeader::MY_MINOR, TAO_ENCAP_BYTE_ORDER, @@ -369,18 +371,13 @@ error_message [TAO_GIOP_HEADER_LEN] = void TAO_GIOP::send_error (TAO_Transport *transport) { - // @@ How does this works with GIOP lite? - TAO_GIOP::dump_msg ("send_error", (const u_char *) error_message, TAO_GIOP_HEADER_LEN); - ACE_HANDLE which = transport->handle (); - // @@ Carlos, can you please check to see if <send_n> should have // it's reply checked? - if (transport->send ((const u_char *)error_message, - TAO_GIOP_HEADER_LEN) == -1) + if (transport->send ((const u_char *)error_message, TAO_GIOP_HEADER_LEN) == -1) { if (TAO_orbdebug != 0) ACE_DEBUG ((LM_DEBUG, @@ -389,12 +386,11 @@ TAO_GIOP::send_error (TAO_Transport *transport) } if (TAO_orbdebug) { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) aborted transport handle %d\n", - transport->handle ())); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) aborted transport handle %d\n", transport->handle ())); } - // @@ Why do we close the connection at this point? - transport->close_connection (); + // @@ + transport->close_conn (); + transport = 0; } ssize_t @@ -404,7 +400,7 @@ TAO_GIOP::read_buffer (TAO_Transport *transport, { ACE_FUNCTION_TIMEPROBE (TAO_GIOP_READ_BUFFER_START); - ssize_t bytes_read = transport->recv (buf, len); + ssize_t bytes_read = transport->receive (buf, len); if (bytes_read == -1 && errno == ECONNRESET) { @@ -443,7 +439,10 @@ TAO_GIOP::recv_request (TAO_Transport *transport, TAO_InputCDR &msg, TAO_ORB_Core* orb_core) { - TAO_FUNCTION_PP_TIMEPROBE (TAO_GIOP_RECV_REQUEST_START); + ACE_FUNCTION_TIMEPROBE (TAO_GIOP_RECV_REQUEST_START); + + TAO_GIOP::Message_Type retval; + CORBA::ULong message_size; // Read the message header off the wire. // @@ -455,15 +454,16 @@ TAO_GIOP::recv_request (TAO_Transport *transport, // as the "duty factor" goes down because of either long calls or // bursty contention during numerous short calls to the same server. - ACE_CDR::mb_align (&msg.start_); + CDR::mb_align (&msg.start_); ssize_t header_len = TAO_GIOP_HEADER_LEN; + // @@ would like to use use_lite_protocol, fredk if (orb_core->orb_params ()->use_lite_protocol ()) - header_len = TAO_GIOP_LITE_HEADER_LEN; + header_len = 5; - if (ACE_CDR::grow (&msg.start_, - header_len) == -1) + if (CDR::grow (&msg.start_, + header_len) == -1) // This should probably be an exception. return TAO_GIOP::CommunicationError; @@ -487,20 +487,17 @@ TAO_GIOP::recv_request (TAO_Transport *transport, // an exception, since for most servers it's not an error. // Is it _never_ an error? Not sure ... /* NOTREACHED */ - case -1: // error if (TAO_orbdebug) ACE_DEBUG ((LM_ERROR, - "(%P|%t) GIOP::recv_request header %p\n", + "(%P|%t) GIOP::recv_request header socket error %p\n", "read_buffer")); break; /* NOTREACHED */ - default: if (TAO_orbdebug) ACE_DEBUG ((LM_ERROR, - "(%P|%t) GIOP::recv_request header read failed, " - "only %d of %d bytes\n", + "(%P|%t) GIOP::recv_request header read failed, only %d of %d bytes\n", len, header_len)); break; @@ -510,24 +507,21 @@ TAO_GIOP::recv_request (TAO_Transport *transport, return TAO_GIOP::CommunicationError; } - // NOTE: if message headers, or whole messages, get encrypted in + // NOTE: if message headers, or whome messages, get encrypted in // application software (rather than by the network infrastructure) // they should be decrypted here ... // First make sure it's a GIOP message of any version. - TAO_GIOP::Message_Type retval; - CORBA::ULong message_size; if (TAO_GIOP::parse_header (msg, - msg.do_byte_swap_, - retval, - message_size, - orb_core) == -1) + msg.do_byte_swap_, + retval, + message_size, + orb_core) == -1) { TAO_GIOP::send_error (transport); - // We didn't really receive anything useful here. - return TAO_GIOP::CommunicationError; - + return TAO_GIOP::EndOfFile; // We didn't really receive + // anything useful here. } // Make sure we have the full length in memory, growing the buffer @@ -538,13 +532,13 @@ TAO_GIOP::recv_request (TAO_Transport *transport, assert (message_size <= UINT_MAX); - if (ACE_CDR::grow (&msg.start_, - header_len + message_size) == -1) + if (CDR::grow (&msg.start_, + header_len + message_size) == -1) return TAO_GIOP::CommunicationError; // Growing the buffer may have reset the rd_ptr(), but we want to // leave it just after the GIOP header (that was parsed already); - ACE_CDR::mb_align (&msg.start_); + CDR::mb_align (&msg.start_); msg.start_.wr_ptr (header_len); msg.start_.wr_ptr (message_size); msg.start_.rd_ptr (header_len); @@ -564,58 +558,55 @@ TAO_GIOP::recv_request (TAO_Transport *transport, case 0: if (TAO_orbdebug) ACE_DEBUG ((LM_DEBUG, - "(%t) End of connection, transport handle %d\n", + "(%P|%t) TAO_GIOP::recv_request body, EOF on transport handle %d\n", transport->handle ())); - return TAO_GIOP::EndOfFile; + break; /* NOTREACHED */ - case -1: if (TAO_orbdebug) ACE_DEBUG ((LM_ERROR, - "(%P|%t) TAO_GIOP::recv_request - body %p\n", + "(%P|%t) TAO_GIOP::recv_request () body %p\n", "read_buffer")); break; /* NOTREACHED */ - default: if (TAO_orbdebug) ACE_DEBUG ((LM_ERROR, - "TAO: (%P|%t) GIOP::recv_request body read failed, " - "only %d of %d bytes\n", + "(%P|%t) short read, only %d of %d bytes\n", len, message_size)); break; /* NOTREACHED */ } + // clean up, and ... + if (TAO_orbdebug) + ACE_DEBUG ((LM_DEBUG, "couldn't read rest of message\n")); return TAO_GIOP::CommunicationError; } TAO_GIOP::dump_msg ("recv", - ACE_reinterpret_cast (u_char *, header), + ACE_reinterpret_cast (u_char *, + header), message_size + header_len); - return retval; } int TAO_GIOP::parse_header_std (TAO_InputCDR &cdr, - int &do_byte_swap, - TAO_GIOP::Message_Type &message_type, - CORBA::ULong &message_size) + int &do_byte_swap, + TAO_GIOP::Message_Type &message_type, + CORBA::ULong &message_size) { char *header = cdr.start_.rd_ptr (); - // The values are hard-coded to support non-ASCII platforms - if (!(header [0] == 0x47 // 'G' - && header [1] == 0x49 // 'I' - && header [2] == 0x4f // 'O' - && header [3] == 0x50 // 'P' - )) + if (!(header [0] == 'G' + && header [1] == 'I' + && header [2] == 'O' + && header [3] == 'P')) { ACE_DEBUG ((LM_DEBUG, - "TAO: (%P|%t) bad header, magic word [%c%c%c%c]\n", - header[0], header[1], header[2], header[3])); + "bad header, magic word\n")); return -1; } @@ -626,8 +617,7 @@ TAO_GIOP::parse_header_std (TAO_InputCDR &cdr, && header [5] <= TAO_GIOP_MessageHeader::MY_MINOR)) { ACE_DEBUG ((LM_DEBUG, - "TAO: (%P|%t) bad header, version [%c%c]\n", - header[4], header[5])); + "bad header, version\n")); return -1; } @@ -649,9 +639,9 @@ TAO_GIOP::parse_header_std (TAO_InputCDR &cdr, int TAO_GIOP::parse_header_lite (TAO_InputCDR &cdr, - int &do_byte_swap, - TAO_GIOP::Message_Type &message_type, - CORBA::ULong &message_size) + int &do_byte_swap, + TAO_GIOP::Message_Type &message_type, + CORBA::ULong &message_size) { do_byte_swap = 0; @@ -670,36 +660,39 @@ TAO_GIOP::parse_header_lite (TAO_InputCDR &cdr, int TAO_GIOP::parse_header (TAO_InputCDR &cdr, - int &do_byte_swap, - TAO_GIOP::Message_Type &message_type, - CORBA::ULong &message_size, - TAO_ORB_Core *orb_core) + int &do_byte_swap, + TAO_GIOP::Message_Type &message_type, + CORBA::ULong &message_size, + TAO_ORB_Core *orb_core) { if (orb_core->orb_params ()->use_lite_protocol ()) return TAO_GIOP::parse_header_lite (cdr, - do_byte_swap, - message_type, - message_size); + do_byte_swap, + message_type, + message_size); else return TAO_GIOP::parse_header_std (cdr, - do_byte_swap, - message_type, - message_size); + do_byte_swap, + message_type, + message_size); } CORBA::Boolean TAO_GIOP_LocateRequestHeader::init (TAO_InputCDR &msg, - CORBA::Environment &) + CORBA::Environment &ACE_TRY_ENV) { ACE_FUNCTION_TIMEPROBE (TAO_GIOP_LOCATE_REQUEST_HEADER_INIT_START); return (msg.read_ulong (this->request_id) - && (msg >> this->object_key) != 0); + && msg.decode (TC_opaque, + &this->object_key, + 0, + ACE_TRY_ENV)); } CORBA::Boolean TAO_GIOP::start_message_std (TAO_GIOP::Message_Type type, - TAO_OutputCDR &msg) + TAO_OutputCDR &msg) { msg.reset (); @@ -708,8 +701,7 @@ TAO_GIOP::start_message_std (TAO_GIOP::Message_Type type, static CORBA::Octet header[] = { - // 'G', 'I', 'O', 'P', - 0x47, 0x49, 0x4f, 0x50, // work on non-ASCII platforms... + 'G', 'I', 'O', 'P', TAO_GIOP_MessageHeader::MY_MAJOR, TAO_GIOP_MessageHeader::MY_MINOR, TAO_ENCAP_BYTE_ORDER @@ -731,7 +723,7 @@ TAO_GIOP::start_message_std (TAO_GIOP::Message_Type type, CORBA::Boolean TAO_GIOP::start_message_lite (TAO_GIOP::Message_Type type, - TAO_OutputCDR &msg) + TAO_OutputCDR &msg) { msg.reset (); @@ -747,8 +739,8 @@ TAO_GIOP::start_message_lite (TAO_GIOP::Message_Type type, CORBA::Boolean TAO_GIOP::start_message (TAO_GIOP::Message_Type type, - TAO_OutputCDR &msg, - TAO_ORB_Core* orb_core) + TAO_OutputCDR &msg, + TAO_ORB_Core* orb_core) { if (orb_core->orb_params ()->use_lite_protocol ()) return TAO_GIOP::start_message_lite (type, msg); @@ -781,7 +773,7 @@ TAO_GIOP::message_name (TAO_GIOP::Message_Type which) } TAO_GIOP_ReplyStatusType -TAO_GIOP::convert_CORBA_to_GIOP_exception (CORBA::exception_type corba_type) +TAO_GIOP::convert_CORBA_to_GIOP_exception (CORBA::ExceptionType corba_type) { switch (corba_type) { |