giopstreamimpl.cc

来自「编译工具」· CC 代码 · 共 578 行 · 第 1/2 页

CC
578
字号
// -*- Mode: C++; -*-//                            Package   : omniORB2// giopStreamImpl.cc          Created on: 14/02/2001//                            Author    : Sai Lai Lo (sll)////    Copyright (C) 2001 AT&T Laboratories, Cambridge////    This file is part of the omniORB library////    The omniORB library is free software; you can redistribute it and/or//    modify it under the terms of the GNU Library General Public//    License as published by the Free Software Foundation; either//    version 2 of the License, or (at your option) any later version.////    This library is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU//    Library General Public License for more details.////    You should have received a copy of the GNU Library General Public//    License along with this library; if not, write to the Free//    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  //    02111-1307, USA////// Description://	*** PROPRIETORY INTERFACE ***//	/*  $Log: giopStreamImpl.cc,v $  Revision 1.1.4.8  2003/09/25 13:12:20  dgrisby  Correctly complain if some parameters are set to zero.  Revision 1.1.4.7  2002/10/14 20:07:11  dgrisby  Per objref / per thread timeouts.  Revision 1.1.4.6  2002/04/29 11:52:51  dgrisby  More fixes for FreeBSD, Darwin, Windows.  Revision 1.1.4.5  2002/03/18 15:13:08  dpg1  Fix bug with old-style ORBInitRef in config file; look for  -ORBtraceLevel arg before anything else; update Windows registry  key. Correct error message.  Revision 1.1.4.4  2001/09/20 13:26:14  dpg1  Allow ORB_init() after orb->destroy().  Revision 1.1.4.3  2001/08/21 11:02:16  sll  orbOptions handlers are now told where an option comes from. This  is necessary to process DefaultInitRef and InitRef correctly.  Revision 1.1.4.2  2001/08/17 17:12:38  sll  Modularise ORB configuration parameters.  Revision 1.1.4.1  2001/04/18 18:10:48  sll  Big checkin with the brand new internal APIs.*/#include <omniORB4/CORBA.h>#include <giopStream.h>#include <giopStreamImpl.h>#include <initialiser.h>#include <orbOptions.h>#include <orbParameters.h>#include <stdio.h>OMNI_NAMESPACE_BEGIN(omni)//////////////////////////////////////////////////////////////////////////////             Configuration options                                      //////////////////////////////////////////////////////////////////////////////GIOP::Version orbParameters::maxGIOPVersion = { 1, 2 };//  Set the maximum GIOP version the ORB should support. The ORB tries//  to match the <major>.<minor> version as specified. This function//  should only be called before ORB_init(). Calling this function//  after ORB_init()  does not cause the ORB to change its maximum//  supported version, in this case the ORB just returns its version//  number in <major>.<minor>.////  Valid values = 1.0 | 1.1 | 1.2CORBA::ULong orbParameters::giopMaxMsgSize = 2048 * 1024;//   This value defines the ORB-wide limit on the size of GIOP message //   (excluding the header). If this limit is exceeded, the ORB will//   refuse to send or receive the message and raise a MARSHAL exception.////   Valid values = (n >= 8192)orbParameters::timeValue orbParameters::clientCallTimeOutPeriod = {0,0};//   Call timeout. On the client side, if a remote call takes longer//   than the timeout value, the ORB will shutdown the connection and//   raise a COMM_FAILURE.////   Valid values = (n >= 0 in seconds) //                   0 --> no timeout. Block till a reply comes backCORBA::Boolean orbParameters::supportPerThreadTimeOut = 0;//   If true, each thread may have a timeout associated with it. This//   gives a performance hit due to accessing per-thread data.////   Valid values = 0 or 1orbParameters::timeValue orbParameters::serverCallTimeOutPeriod = {0,0};//   Call timeout. On the server side, if the ORB cannot completely //   unmarshal a call's arguments in the defined timeout, it shutdown the//   connection.////   Valid values = (n >= 0 in seconds) //                   0 --> no timeout.CORBA::ULong  orbParameters::maxInterleavedCallsPerConnection = 5;//  No. of interleaved calls per connection the server is prepared//  to accept. If this number is exceeded, the connection is closed.////  Valid values = (n >= 1) GIOP::AddressingDisposition orbParameters::giopTargetAddressMode = GIOP::KeyAddr;//  On the client side, if it is to use GIOP 1.2 or above to talk to a //  server, use this Target Address Mode.////  Valid values = 0 (GIOP::KeyAddr)//                 1 (GIOP::ProfileAddr)//                 2 (GIOP::ReferenceAddr)CORBA::Boolean orbParameters::strictIIOP = 1;//   Enable vigorous check on incoming IIOP messages////   In some (sloppy) IIOP implementations, the message size value in//   the header can be larger than the actual body size, i.e. there is//   garbage at the end. As the spec does not say the message size//   must match the body size exactly, this is not a clear violation//   of the spec.////   If this flag is non-zero, the incoming message is expected to//   be well behaved. Any messages that have garbage at the end will//   be rejected.//   //   The default value of this flag is true, so invalid messages are//   rejected. If you set it to zero, the ORB will silently skip the//   unread part. The problem with this behaviour is that the header//   message size may actually be garbage, caused by a bug in the//   sender's code. The receiving thread may forever block on the//   strand as it tries to read more data from it. In this case the//   sender won't send any more as it thinks it has marshalled in all//   the data.////   Valid values = 0 or 1////////////////////////////////////////////////////////////////////////static giopStreamImpl* implHead = 0;static giopStreamImpl* implMax = 0;////////////////////////////////////////////////////////////////////////giopStreamImpl::giopStreamImpl(const GIOP::Version& v) : pd_next(0) {  pd_version.major = v.major;  pd_version.minor = v.minor;  // Shared by the client and server side  // Process message header  outputMessageBegin             = 0;  outputMessageEnd               = 0;  inputMessageBegin              = 0;  inputMessageEnd                = 0;  sendMsgErrorMessage            = 0;  // Client side  // Process message header  marshalRequestHeader           = 0;  sendLocateRequest              = 0;  unmarshalReplyHeader           = 0;  unmarshalLocateReply           = 0;  // Server side  // Process message header  unmarshalWildCardRequestHeader = 0;  unmarshalRequestHeader         = 0;  unmarshalLocateRequest         = 0;  marshalReplyHeader             = 0;  sendSystemException            = 0;  sendUserException              = 0;  sendLocationForwardReply       = 0;  sendLocateReply                = 0;  // Shared by the client and the server side  // Process message body  inputRemaining                 = 0;  getInputData                   = 0;  skipInputData                  = 0;  copyInputData                  = 0;  outputRemaining                = 0;  getReserveSpace                = 0;  copyOutputData                 = 0;  currentInputPtr                = 0;  currentOutputPtr               = 0;}////////////////////////////////////////////////////////////////////////giopStreamImpl::~giopStreamImpl() {}////////////////////////////////////////////////////////////////////////voidgiopStreamImpl::registerImpl(giopStreamImpl* impl) {  // Insert implementation to the last of the queue  giopStreamImpl** pp = &implHead;  while (*pp) pp = &((*pp)->pd_next);  impl->pd_next = 0;  *pp = impl;  if (implMax) {    CORBA::UShort ver1, ver2;    ver1 = ((CORBA::UShort)impl->pd_version.major << 8) +             impl->pd_version.minor;    ver2 = ((CORBA::UShort)implMax->pd_version.major << 8) +           implMax->pd_version.minor;    if (ver1 <= ver2) return;  }  implMax = impl;}////////////////////////////////////////////////////////////////////////giopStreamImpl*giopStreamImpl::matchVersion(const GIOP::Version& v) {  giopStreamImpl* p = implHead;  while (p) {    if (p->pd_version.major == v.major && p->pd_version.minor == v.minor)      break;    p = p->pd_next;  }  return p;}////////////////////////////////////////////////////////////////////////giopStreamImpl*giopStreamImpl::maxVersion() {  return implMax;}///////////////////////////////////////////////////////////////////////////////            Handlers for Configuration Options                           ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////class maxGIOPVersionHandler : public orbOptions::Handler {public:  maxGIOPVersionHandler() :     orbOptions::Handler("maxGIOPVersion",			"maxGIOPVersion = 1.0 | 1.1 | 1.2",			1,			"-ORBmaxGIOPVersion < 1.0 | 1.1 | 1.2 >") {}  void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) {    unsigned int ma, mi;    if ( sscanf(value, "%u.%u", &ma, &mi) != 2 || ma > 255 || mi > 255) {      throw orbOptions::BadParam(key(),value,				 "Expect 1.0 | 1.1 | 1.2");    }    orbParameters::maxGIOPVersion.major = ma;    orbParameters::maxGIOPVersion.minor = mi;  }  void dump(orbOptions::sequenceString& result) {    CORBA::String_var v(CORBA::string_alloc(3));    sprintf(v,"%1d.%1d",orbParameters::maxGIOPVersion.major, orbParameters::maxGIOPVersion.minor);    orbOptions::addKVString(key(),v,result);  }};static maxGIOPVersionHandler maxGIOPVersionHandler_;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?