📄 omnitransport.cc
字号:
// -*- Mode: C++; -*-// Package : omniORB// omniTransport.cc Created on: 16/01/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:///* $Log: omniTransport.cc,v $ Revision 1.1.4.8 2005/11/16 17:35:25 dgrisby New connectionWatchPeriod and connectionWatchImmediate parameters. Revision 1.1.4.7 2005/08/23 11:45:06 dgrisby New maxSocketSend and maxSocketRecv parameters. Revision 1.1.4.6 2002/09/04 23:29:30 dgrisby Avoid memory corruption with multiple list removals. Revision 1.1.4.5 2001/09/20 13:26:15 dpg1 Allow ORB_init() after orb->destroy(). Revision 1.1.4.4 2001/09/19 17:26:51 dpg1 Full clean-up after orb->destroy(). Revision 1.1.4.3 2001/08/17 17:12:41 sll Modularise ORB configuration parameters. Revision 1.1.4.2 2001/06/13 20:13:15 sll Minor updates to make the ORB compiles with MSVC++. 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 <omniORB4/omniTransport.h>#include <omniORB4/IOP_C.h>#include <initialiser.h>#include <orbOptions.h>#include <orbParameters.h>#include <SocketCollection.h>OMNI_NAMESPACE_BEGIN(omni)omni_tracedmutex* omniTransportLock = 0;////////////////////////////////////////////////////////////////////////////// Maximum sizes for socket sends / recvs#if defined(__WIN32__)// Windows has a bug that sometimes means large sends failsize_t orbParameters::maxSocketSend = 131072;size_t orbParameters::maxSocketRecv = 131072;#elif defined(__VMS)// VMS has a hard limitsize_t orbParameters::maxSocketSend = 65528;size_t orbParameters::maxSocketRecv = 65528;#else// Other platforms have no limitsize_t orbParameters::maxSocketSend = 0x7fffffff;size_t orbParameters::maxSocketRecv = 0x7fffffff;#endif////////////////////////////////////////////////////////////////////////////IOP_C_Holder::IOP_C_Holder(const omniIOR* ior, const CORBA::Octet* key, CORBA::ULong keysize, Rope* rope, omniCallDescriptor* calldesc) : pd_rope(rope) { OMNIORB_ASSERT(calldesc); pd_iop_c = rope->acquireClient(ior,key,keysize,calldesc);}////////////////////////////////////////////////////////////////////////////IOP_C_Holder::~IOP_C_Holder() { pd_rope->releaseClient(pd_iop_c);}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidRopeLink::insert(RopeLink& head){ next = head.prev->next; head.prev->next = this; prev = head.prev; head.prev = this;}////////////////////////////////////////////////////////////////////////////voidRopeLink::remove(){ prev->next = next; next->prev = prev; // When a connection is scavenged, remove() is called by the // scavenger to remove the connection from the scavenger's list. // Later, the thread looking after the strand calls safeDelete() // which attempts to remove() it again. Setting next and prev to // this means the second remove has no effect. next = prev = this;}////////////////////////////////////////////////////////////////////////////CORBA::BooleanRopeLink::is_empty(RopeLink& head){ return (head.next == &head);}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////voidStrandList::insert(StrandList& head){ next = head.prev->next; head.prev->next = this; prev = head.prev; head.prev = this;}////////////////////////////////////////////////////////////////////////////voidStrandList::remove(){ prev->next = next; next->prev = prev; next = prev = this;}////////////////////////////////////////////////////////////////////////////CORBA::BooleanStrandList::is_empty(StrandList& head){ return (head.next == &head);}/////////////////////////////////////////////////////////////////////////////class maxSocketSendHandler : public orbOptions::Handler {public: maxSocketSendHandler() : orbOptions::Handler("maxSocketSend", "maxSocketSend = n >= 8192", 1, "-ORBmaxSocketSend < n >= 8192 >") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { CORBA::ULong v; if (!orbOptions::getULong(value,v) || v < 8192) { throw orbOptions::BadParam(key(),value, "Invalid value, expect n >= 8192"); } orbParameters::maxSocketSend = v; } void dump(orbOptions::sequenceString& result) { orbOptions::addKVULong(key(),orbParameters::maxSocketSend, result); }};static maxSocketSendHandler maxSocketSendHandler_;/////////////////////////////////////////////////////////////////////////////class maxSocketRecvHandler : public orbOptions::Handler {public: maxSocketRecvHandler() : orbOptions::Handler("maxSocketRecv", "maxSocketRecv = n >= 8192", 1, "-ORBmaxSocketRecv < n >= 8192 >") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { CORBA::ULong v; if (!orbOptions::getULong(value,v) || v < 8192) { throw orbOptions::BadParam(key(),value, "Invalid value, expect n >= 8192"); } orbParameters::maxSocketRecv = v; } void dump(orbOptions::sequenceString& result) { orbOptions::addKVULong(key(),orbParameters::maxSocketRecv, result); }};static maxSocketRecvHandler maxSocketRecvHandler_;/////////////////////////////////////////////////////////////////////////////class connectionWatchPeriodHandler : public orbOptions::Handler {public: connectionWatchPeriodHandler() : orbOptions::Handler("connectionWatchPeriod", "connectionWatchPeriod = n >= 0 in microsecs", 1, "-ORBconnectionWatchPeriod < n >= 0 in microsecs >") {} void visit(const char* value,orbOptions::Source) throw (orbOptions::BadParam) { CORBA::ULong v; if (!orbOptions::getULong(value,v)) { throw orbOptions::BadParam(key(),value, "Expect n >= 0 in microsecs"); } SocketCollection::scan_interval_sec = v / 1000000; SocketCollection::scan_interval_nsec = (v % 1000000) * 1000; } void dump(orbOptions::sequenceString& result) { CORBA::ULong v = (SocketCollection::scan_interval_sec * 1000000 + SocketCollection::scan_interval_nsec / 1000); orbOptions::addKVULong(key(),v,result); }};static connectionWatchPeriodHandler connectionWatchPeriodHandler_;/////////////////////////////////////////////////////////////////////////////// Module initialiser ///////////////////////////////////////////////////////////////////////////////class omni_omniTransport_initialiser : public omniInitialiser {public: omni_omniTransport_initialiser() { orbOptions::singleton().registerHandler(maxSocketSendHandler_); orbOptions::singleton().registerHandler(maxSocketRecvHandler_); orbOptions::singleton().registerHandler(connectionWatchPeriodHandler_); } void attach() { if (!omniTransportLock) omniTransportLock = new omni_tracedmutex; } void detach() { // omniTransportLock is deleted by the final clean-up in omniInternal.cc }};static omni_omniTransport_initialiser initialiser;omniInitialiser& omni_omniTransport_initialiser_ = initialiser;OMNI_NAMESPACE_END(omni)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -