diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 34 | ||||
-rw-r--r-- | cpp/src/Ice/Emitter.cpp | 22 | ||||
-rw-r--r-- | cpp/src/Ice/Emitter.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 3 | ||||
-rw-r--r-- | cpp/src/Ice/Network.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/Object.cpp | 11 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 8 | ||||
-rw-r--r-- | cpp/src/Ice/SslConfig.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/UdpTransceiver.cpp | 2 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 43 |
11 files changed, 73 insertions, 59 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 67495714ba1..cc37bf1da1f 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -24,23 +24,14 @@ using namespace Ice; using namespace IceInternal; IceInternal::BasicStream::BasicStream(const InstancePtr& instance) : - _instance(instance), - _encapsStack(1) + _instance(instance) { + _encapsStack.reserve(4); _encapsStack.resize(1); _encapsStack.back().encoding = 0; _encapsStack.back().start = 0; } -IceInternal::BasicStream::~BasicStream() -{ - // - // No check for exactly one, because an error might have aborted - // marshalling/unmarshalling - // - assert(_encapsStack.size() > 0); -} - InstancePtr IceInternal::BasicStream::instance() const { @@ -682,12 +673,6 @@ IceInternal::BasicStream::write(const string& v) } void -IceInternal::BasicStream::write(const char* v) -{ - write(string(v)); -} - -void IceInternal::BasicStream::write(const vector<string>& v) { write(Int(v.size())); @@ -874,13 +859,14 @@ IceInternal::BasicStream::write(const ObjectPtr& v) } else { - write(""); + static const string empty; + write(empty); } } } bool -IceInternal::BasicStream::read(const char* signatureType, ObjectPtr& v) +IceInternal::BasicStream::read(const string& signatureType, ObjectPtr& v) { Int pos; read(pos); @@ -896,6 +882,7 @@ IceInternal::BasicStream::read(const char* signatureType, ObjectPtr& v) } else { + static const string iceObject("::Ice::Object"); string id; read(id); @@ -904,7 +891,7 @@ IceInternal::BasicStream::read(const char* signatureType, ObjectPtr& v) v = 0; return true; } - else if (id == "::Ice::Object") + else if (id == iceObject) { v = new ::Ice::Object; read(v); @@ -950,7 +937,7 @@ IceInternal::BasicStream::write(const UserException& v) } Int -IceInternal::BasicStream::throwException(const char** throwsBegin, const char** throwsEnd) +IceInternal::BasicStream::throwException(const string* throwsBegin, const string* throwsEnd) { string id; read(id); @@ -964,7 +951,8 @@ IceInternal::BasicStream::throwException(const char** throwsBegin, const char** } catch (UserException& ex) { - for (const char** p = ex.__getExceptionIds(); strcmp(*p, "::Ice::UserException") != 0; ++p) + static const string userException("::Ice::UserException"); + for (const string* p = ex.__getExceptionIds(); *p != userException != 0; ++p) { if (binary_search(throwsBegin, throwsEnd, string(*p))) { @@ -977,7 +965,7 @@ IceInternal::BasicStream::throwException(const char** throwsBegin, const char** } } - pair<const char**, const char**> p = equal_range(throwsBegin, throwsEnd, id); + pair<const string*, const string*> p = equal_range(throwsBegin, throwsEnd, id); if (p.first != p.second) { return p.first - throwsBegin; diff --git a/cpp/src/Ice/Emitter.cpp b/cpp/src/Ice/Emitter.cpp index f890e61d5b0..318a51d3f14 100644 --- a/cpp/src/Ice/Emitter.cpp +++ b/cpp/src/Ice/Emitter.cpp @@ -109,7 +109,7 @@ IceInternal::Emitter::sendRequest(Outgoing* out, bool oneway) // if (!_endpoint->oneway() && !oneway) { - _requests.insert(_requests.end(), make_pair(requestId, out)); + _requestsHint = _requests.insert(_requests.end(), make_pair(requestId, out)); } } @@ -279,13 +279,29 @@ IceInternal::Emitter::message(BasicStream& stream) traceReply("received reply", stream, _logger, _traceLevels); Int requestId; stream.read(requestId); - map<Int, Outgoing*>::iterator p = _requests.find(requestId); + + map<Int, Outgoing*>::iterator p = _requests.end(); + + if (_requestsHint != _requests.end()) + { + if (_requestsHint->first == requestId) + { + p = _requestsHint; + } + } + + if (_requestsHint == _requests.end()) + { + p = _requests.find(requestId); + } + if (p == _requests.end()) { throw UnknownRequestIdException(__FILE__, __LINE__); } p->second->finished(stream); _requests.erase(p); + _requestsHint = _requests.end(); break; } @@ -360,6 +376,7 @@ IceInternal::Emitter::Emitter(const InstancePtr& instance, _transceiver(transceiver), _endpoint(endpoint), _nextRequestId(1), + _requestsHint(_requests.end()), _batchStream(instance), _state(StateActive) { @@ -413,6 +430,7 @@ IceInternal::Emitter::setState(State state, const LocalException& ex) p->second->finished(*_exception.get()); } _requests.clear(); + _requestsHint = _requests.end(); _state = state; } diff --git a/cpp/src/Ice/Emitter.h b/cpp/src/Ice/Emitter.h index 9330e7010bb..4af6399c944 100644 --- a/cpp/src/Ice/Emitter.h +++ b/cpp/src/Ice/Emitter.h @@ -81,6 +81,7 @@ private: ThreadPoolPtr _threadPool; ::Ice::Int _nextRequestId; std::map< ::Ice::Int, Outgoing*> _requests; + std::map< ::Ice::Int, Outgoing*>::iterator _requestsHint; std::auto_ptr< ::Ice::LocalException> _exception; BasicStream _batchStream; State _state; diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index b3754d50a30..15eb2e62916 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -73,7 +73,6 @@ IceInternal::Incoming::invoke() try { servant = _adapter->identityToServant(current.identity); - DispatchStatus status; if (!servant && !current.identity.category.empty()) { @@ -93,6 +92,8 @@ IceInternal::Incoming::invoke() } } + DispatchStatus status; + if (!servant) { status = DispatchObjectNotExist; diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index 9bbfa0c5afe..88dec87e7fa 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -341,8 +341,12 @@ IceInternal::doBind(int fd, struct sockaddr_in& addr) } socklen_t len = sizeof(addr); +#ifdef NDEBUG + getsockname(fd, reinterpret_cast<struct sockaddr*>(&addr), &len); +#else int ret = getsockname(fd, reinterpret_cast<struct sockaddr*>(&addr), &len); assert(ret != SOCKET_ERROR); +#endif } void diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index bf6e44e148c..410816f6c96 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -52,12 +52,12 @@ Ice::Object::ice_hash() const return reinterpret_cast<Int>(this); } -const char* Ice::Object::__classIds[] = +string Ice::Object::__classIds[] = { "::Ice::Object" }; -const char** +string* Ice::Object::__getClassIds() { return __classIds; @@ -94,7 +94,7 @@ Ice::Object::___ice_ping(Incoming&, const Current& __current) return DispatchOK; } -const char* Ice::Object::__all[] = +string Ice::Object::__all[] = { "ice_isA", "ice_ping" @@ -103,12 +103,9 @@ const char* Ice::Object::__all[] = DispatchStatus Ice::Object::__dispatch(Incoming& in, const Current& current) { - const char** b = __all; - const char** e = __all + sizeof(__all) / sizeof(const char*); - pair<const char**, const char**> r = equal_range(b, e, current.operation); + pair<string*, string*> r = equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation); if (r.first == r.second) { - cout << "xxx" << endl; return DispatchOperationNotExist; } diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index c8285134f81..b716a84d1af 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -39,7 +39,7 @@ IceInternal::NonRepeatable::get() const } IceInternal::Outgoing::Outgoing(const EmitterPtr& emitter, const ReferencePtr& ref, bool sendProxy, - const char* operation, bool nonmutating, const Context& context) : + const string& operation, bool nonmutating, const Context& context) : _emitter(emitter), _reference(ref), _state(StateUnsent), diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index cb4851bcb34..4cf5900ab9d 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -518,7 +518,8 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context& __context) { try { - Outgoing __out(__emitter, __reference, __sendProxy, "ice_isA", true, __context); + static const string __operation("ice_isA"); + Outgoing __out(__emitter, __reference, __sendProxy, __operation, true, __context); BasicStream* __is = __out.is(); BasicStream* __os = __out.os(); __os->write(__id); @@ -545,7 +546,8 @@ IceDelegateM::Ice::Object::ice_ping(const Context& __context) { try { - Outgoing __out(__emitter, __reference, __sendProxy, "ice_ping", true, __context); + static const string __operation("ice_ping"); + Outgoing __out(__emitter, __reference, __sendProxy, __operation, true, __context); if (!__out.invoke()) { throw ::Ice::UnknownUserException(__FILE__, __LINE__); @@ -571,7 +573,7 @@ IceDelegateM::Ice::Object::ice_invoke(const string& operation, { try { - Outgoing __out(__emitter, __reference, __sendProxy, operation.c_str(), nonmutating, __context); + Outgoing __out(__emitter, __reference, __sendProxy, operation, nonmutating, __context); BasicStream* __os = __out.os(); __os->writeBlob(inParams); __out.invoke(); diff --git a/cpp/src/Ice/SslConfig.cpp b/cpp/src/Ice/SslConfig.cpp index 6d8eca2ea80..71128f50d14 100644 --- a/cpp/src/Ice/SslConfig.cpp +++ b/cpp/src/Ice/SslConfig.cpp @@ -534,7 +534,7 @@ IceSecurity::Ssl::Parser::loadCertificateFile(DOM_Node rootNode, CertificateFile if (rootNode != 0) { string filename; - int encoding; + int encoding = 0; // Initialize, to keep the compiler from complaining. DOM_NamedNodeMap attributes = rootNode.getAttributes(); int attrCount = attributes.getLength(); diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 7d3ba7b97b8..24155334528 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -58,8 +58,10 @@ IceInternal::UdpTransceiver::write(Buffer& buf, int) { assert(_sender); assert(buf.i == buf.b.begin()); +#ifndef NDEBUG const int packetSize = 64 * 1024; // TODO: configurable assert(packetSize >= static_cast<int>(buf.b.size())); // TODO: exception +#endif repeat: int ret = ::send(_fd, buf.b.begin(), buf.b.size(), 0); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index f2bb8033d45..3c2671bc8f8 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -248,7 +248,8 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << _dllExport << "virtual ::std::string ice_name() const;"; C << sp << nl << "::std::string" << nl << scoped.substr(2) << "::ice_name() const"; C << sb; - C << nl << "return \"" << scoped.substr(2) << "\";"; + C << nl << "static const ::std::string name(\"" << scoped.substr(2) << "\");"; + C << nl << "return name;"; C << eb; if (p->isLocal()) @@ -280,9 +281,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) StringList::const_iterator q; H << sp; - H << nl << _dllExport << "static const char* __exceptionIds[" << exceptionIds.size() << "];"; - H << nl << _dllExport << "virtual const char** __getExceptionIds() const;"; - C << sp << nl << "const char*" << scoped.substr(2) << "::__exceptionIds[" << exceptionIds.size() << "] ="; + H << nl << _dllExport << "static ::std::string __exceptionIds[" << exceptionIds.size() << "];"; + H << nl << _dllExport << "virtual ::std::string* __getExceptionIds() const;"; + C << sp << nl << "::std::string " << scoped.substr(2) << "::__exceptionIds[" << exceptionIds.size() << "] ="; C << sb; q = exceptionIds.begin(); while (q != exceptionIds.end()) @@ -294,7 +295,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) } } C << eb << ';'; - C << sp << nl << "const char**" << nl << scoped.substr(2) << "::__getExceptionIds() const"; + C << sp << nl << "::std::string*" << nl << scoped.substr(2) << "::__getExceptionIds() const"; C << sb; C << nl << "return __exceptionIds;"; C << eb; @@ -1152,7 +1153,8 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "try"; C << sb; - C << nl << "::IceInternal::Outgoing __out(__emitter, __reference, __sendProxy, \"" << name << "\", " + C << nl << "static const ::std::string __operation(\"" << name << "\");"; + C << nl << "::IceInternal::Outgoing __out(__emitter, __reference, __sendProxy, __operation, " << (p->nonmutating() ? "true" : "false") << ", __context);"; if (ret || !outParams.empty() || !throws.empty()) { @@ -1168,7 +1170,7 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) if (!throws.empty()) { ExceptionList::const_iterator r; - C << nl << "static const char* __throws[] ="; + C << nl << "static ::std::string __throws[] ="; C << sb; for (r = throws.begin(); r != throws.end(); ++r) { @@ -1578,12 +1580,12 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) StringList::const_iterator q; H << sp; - H << nl << exp2 << "static const char* __ids[" << ids.size() << "];"; - H << nl << exp2 << "static const char* __classIds[" << classIds.size() << "];"; + H << nl << exp2 << "static ::std::string __ids[" << ids.size() << "];"; + H << nl << exp2 << "static ::std::string __classIds[" << classIds.size() << "];"; H << nl << exp2 << "virtual bool ice_isA(const ::std::string&, const ::Ice::Current& = ::Ice::Current());"; - H << nl << exp2 << "virtual const char** __getClassIds();"; + H << nl << exp2 << "virtual ::std::string* __getClassIds();"; C << sp; - C << nl << "const char* " << scoped.substr(2) << "::__ids[" << ids.size() << "] ="; + C << nl << "::std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] ="; C << sb; q = ids.begin(); while (q != ids.end()) @@ -1596,7 +1598,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) } C << eb << ';'; C << sp; - C << nl << "const char* " << scoped.substr(2) << "::__classIds[" << classIds.size() << "] ="; + C << nl << "::std::string " << scoped.substr(2) << "::__classIds[" << classIds.size() << "] ="; C << sb; q = classIds.begin(); while (q != classIds.end()) @@ -1611,12 +1613,12 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) C << sp; C << nl << "bool" << nl << scoped.substr(2) << "::ice_isA(const ::std::string& s, const ::Ice::Current&)"; C << sb; - C << nl << "const char** b = __ids;"; - C << nl << "const char** e = __ids + " << ids.size() << ';'; + C << nl << "::std::string* b = __ids;"; + C << nl << "::std::string* e = __ids + " << ids.size() << ';'; C << nl << "return ::std::binary_search(b, e, s);"; C << eb; C << sp; - C << nl << "const char**" << nl << scoped.substr(2) << "::__getClassIds()"; + C << nl << "::std::string*" << nl << scoped.substr(2) << "::__getClassIds()"; C << sb; C << nl << "return __classIds;"; C << eb; @@ -1662,11 +1664,11 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) StringList::const_iterator q; H << sp; - H << nl << exp2 << "static const char* __all[" << allOpNames.size() << "];"; + H << nl << exp2 << "static ::std::string __all[" << allOpNames.size() << "];"; H << nl << exp2 << "virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);"; C << sp; - C << nl << "const char* " << scoped.substr(2) << "::__all[] ="; + C << nl << "::std::string " << scoped.substr(2) << "::__all[] ="; C << sb; q = allOpNames.begin(); while (q != allOpNames.end()) @@ -1682,9 +1684,8 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p) C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2) << "::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)"; C << sb; - C << nl << "const char** b = __all;"; - C << nl << "const char** e = __all + " << allOpNames.size() << ';'; - C << nl << "::std::pair< const char**, const char**> r = ::std::equal_range(b, e, current.operation);"; + C << nl << "::std::pair< ::std::string*, ::std::string*> r = " + << "::std::equal_range(__all, __all + " << allOpNames.size() << ", current.operation);"; C << nl << "if (r.first == r.second)"; C << sb; C << nl << "return ::IceInternal::DispatchOperationNotExist;"; @@ -1917,7 +1918,6 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) } C << name << args << ';'; writeMarshalCode(C, outParams, ret); - C << nl << "return ::IceInternal::DispatchOK;"; if (!throws.empty()) { C << eb; @@ -1931,6 +1931,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) C << eb; } } + C << nl << "return ::IceInternal::DispatchOK;"; C << eb; } } |