diff options
author | Jose <jose@zeroc.com> | 2019-07-02 17:31:08 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-07-02 17:31:08 +0200 |
commit | 5ff454c980022b2399511011f5d503a77b231e8f (patch) | |
tree | 40e22c4c1fb834c7f940b8c35ba9f13a47ceaa89 /cpp/src | |
parent | update Cartfile.resolved (diff) | |
parent | Check sysconf errors Close #418 (#420) (diff) | |
download | ice-5ff454c980022b2399511011f5d503a77b231e8f.tar.bz2 ice-5ff454c980022b2399511011f5d503a77b231e8f.tar.xz ice-5ff454c980022b2399511011f5d503a77b231e8f.zip |
Merge remote-tracking branch 'origin/3.7' into swift
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/DynamicLibrary.cpp | 11 | ||||
-rwxr-xr-x | cpp/src/Ice/Network.cpp | 20 | ||||
-rw-r--r-- | cpp/src/Ice/Selector.cpp | 4 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 12 | ||||
-rw-r--r-- | cpp/src/Ice/Timer.cpp | 10 | ||||
-rw-r--r-- | cpp/src/Ice/ios/StreamTransceiver.cpp | 14 | ||||
-rw-r--r-- | cpp/src/IceGrid/Activator.cpp | 5 | ||||
-rw-r--r-- | cpp/src/IceIAP/Transceiver.mm | 8 | ||||
-rw-r--r-- | cpp/src/IceSSL/CertificateI.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceSSL/SecureTransportCertificateI.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceSSL/SecureTransportUtil.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceUtil/Options.cpp | 4 |
12 files changed, 72 insertions, 35 deletions
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 3fac7e6ecfe..5685d1bfa3f 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -212,12 +212,11 @@ IceInternal::DynamicLibrary::load(const string& lib) // Don't need to use a wide string converter as the wide string is passed // to Windows API. // -#ifdef ICE_OS_UWP +#if defined(ICE_OS_UWP) _hnd = LoadPackagedLibrary(stringToWstring(lib, getProcessStringConverter()).c_str(), 0); #elif defined(_WIN32) _hnd = LoadLibraryW(stringToWstring(lib, getProcessStringConverter()).c_str()); #else - int flags = RTLD_NOW | RTLD_GLOBAL; #ifdef _AIX flags |= RTLD_MEMBER; @@ -230,8 +229,10 @@ IceInternal::DynamicLibrary::load(const string& lib) // // Remember the most recent error in _err. // -#ifdef _WIN32 - _err = IceUtilInternal::lastErrorToString(); +#if defined(ICE_OS_UWP) + _err = "LoadPackagedLibrary on `" + lib + "' failed with `" + IceUtilInternal::lastErrorToString() + "'"; +#elif defined(_WIN32) + _err = "LoadLibraryW on `" + lib + "' failed with `" + IceUtilInternal::lastErrorToString() + "'"; #else const char* err = dlerror(); if(err) @@ -260,7 +261,7 @@ IceInternal::DynamicLibrary::getSymbol(const string& name) // Remember the most recent error in _err. // #ifdef _WIN32 - _err = IceUtilInternal::lastErrorToString(); + _err = "GetProcAddress for `" + name + "' failed with `" + IceUtilInternal::lastErrorToString() + "'"; #else const char* err = dlerror(); if(err) diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index d1e4b8194ee..f4713ddea3a 100755 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -448,40 +448,40 @@ getLocalAddresses(ProtocolSupport protocol, bool includeLoopback, bool singleAdd numaddrs = ifc.ifc_len / static_cast<int>(sizeof(struct ifreq)); struct ifreq* ifr = ifc.ifc_req; set<string> interfaces; - for(int i = 0; i < numaddrs; ++i) + for(int j = 0; j < numaddrs; ++j) { - if(!(ifr[i].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses + if(!(ifr[j].ifr_flags & IFF_LOOPBACK)) // Don't include loopback interface addresses { // // On Solaris the above Loopback check does not always work so we double // check the address below. Solaris also returns duplicate entries that need // to be filtered out. // - if(ifr[i].ifr_addr.sa_family == AF_INET && protocol != EnableIPv6) + if(ifr[j].ifr_addr.sa_family == AF_INET && protocol != EnableIPv6) { Address addr; - memcpy(&addr.saStorage, &ifr[i].ifr_addr, sizeof(sockaddr_in)); + memcpy(&addr.saStorage, &ifr[j].ifr_addr, sizeof(sockaddr_in)); if(addr.saIn.sin_addr.s_addr != 0 && (includeLoopback || addr.saIn.sin_addr.s_addr != htonl(INADDR_LOOPBACK))) { - if(!singleAddressPerInterface || interfaces.find(ifr[i].ifr_name) == interfaces.end()) + if(!singleAddressPerInterface || interfaces.find(ifr[j].ifr_name) == interfaces.end()) { result.push_back(addr); - interfaces.insert(ifr[i].ifr_name); + interfaces.insert(ifr[j].ifr_name); } } } - else if(ifr[i].ifr_addr.sa_family == AF_INET6 && protocol != EnableIPv4) + else if(ifr[j].ifr_addr.sa_family == AF_INET6 && protocol != EnableIPv4) { Address addr; - memcpy(&addr.saStorage, &ifr[i].ifr_addr, sizeof(sockaddr_in6)); + memcpy(&addr.saStorage, &ifr[j].ifr_addr, sizeof(sockaddr_in6)); if(!IN6_IS_ADDR_UNSPECIFIED(&addr.saIn6.sin6_addr) && (includeLoopback || !IN6_IS_ADDR_LOOPBACK(&addr.saIn6.sin6_addr))) { - if(!singleAddressPerInterface || interfaces.find(ifr[i].ifr_name) == interfaces.end()) + if(!singleAddressPerInterface || interfaces.find(ifr[j].ifr_name) == interfaces.end()) { result.push_back(addr); - interfaces.insert(ifr[i].ifr_name); + interfaces.insert(ifr[j].ifr_name); } } } diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp index 0070f93fb3f..9b2782b1733 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -928,7 +928,9 @@ Selector::updateSelector() } void -Selector::updateSelectorForEventHandler(EventHandler* handler, SocketOperation remove, SocketOperation add) +Selector::updateSelectorForEventHandler(EventHandler* handler, + ICE_MAYBE_UNUSED SocketOperation remove, + ICE_MAYBE_UNUSED SocketOperation add) { #if defined(ICE_USE_EPOLL) SocketOperation previous = handler->_registered; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index f1be4dcb8dc..bbd8b49d087 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -300,8 +300,20 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); int nProcessors = sysInfo.dwNumberOfProcessors; +# elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + static int ncpu[2] = { CTL_HW, HW_NCPU }; + size_t sz = sizeof(nProcessors); + int nProcessors; + if(sysctl(ncpu, 2, &nProcessors, &sz, 0, 0) == -1) + { + nProcessors = 1; + } # else int nProcessors = static_cast<int>(sysconf(_SC_NPROCESSORS_ONLN)); + if(nProcessors == -1) + { + nProcessors = 1; + } # endif #endif diff --git a/cpp/src/Ice/Timer.cpp b/cpp/src/Ice/Timer.cpp index e573b905a9d..4f4e2e3f030 100644 --- a/cpp/src/Ice/Timer.cpp +++ b/cpp/src/Ice/Timer.cpp @@ -242,6 +242,16 @@ Timer::run() { consoleErr << "IceUtil::Timer::run(): uncaught exception" << endl; } + + if(token.delay == IceUtil::Time()) + { + // + // If thisthe task is not a repeated task, clear the task reference now rather than + // in the synchronization block above. Clearing the task reference might end up + // calling user code which could trigger a deadlock. See also issue #352. + // + token.task = ICE_NULLPTR; + } } } } diff --git a/cpp/src/Ice/ios/StreamTransceiver.cpp b/cpp/src/Ice/ios/StreamTransceiver.cpp index 1405e476d39..b033ed1dfa5 100644 --- a/cpp/src/Ice/ios/StreamTransceiver.cpp +++ b/cpp/src/Ice/ios/StreamTransceiver.cpp @@ -320,7 +320,7 @@ IceObjC::StreamTransceiver::write(Buffer& buf) checkErrorStatus(_writeStream.get(), 0, __FILE__, __LINE__); } - size_t packetSize = buf.b.end() - buf.i; + size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i); while(buf.i != buf.b.end()) { if(!CFWriteStreamCanAcceptBytes(_writeStream.get())) @@ -329,7 +329,8 @@ IceObjC::StreamTransceiver::write(Buffer& buf) } assert(_fd != INVALID_SOCKET); - CFIndex ret = CFWriteStreamWrite(_writeStream.get(), reinterpret_cast<const UInt8*>(&*buf.i), packetSize); + CFIndex ret = CFWriteStreamWrite(_writeStream.get(), reinterpret_cast<const UInt8*>(&*buf.i), + static_cast<CFIndex>(packetSize)); if(ret == SOCKET_ERROR) { @@ -345,7 +346,7 @@ IceObjC::StreamTransceiver::write(Buffer& buf) if(packetSize > static_cast<size_t>(buf.b.end() - buf.i)) { - packetSize = buf.b.end() - buf.i; + packetSize = static_cast<size_t>(buf.b.end() - buf.i); } } return SocketOperationNone; @@ -360,7 +361,7 @@ IceObjC::StreamTransceiver::read(Buffer& buf) checkErrorStatus(0, _readStream.get(), __FILE__, __LINE__); } - size_t packetSize = buf.b.end() - buf.i; + size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i); while(buf.i != buf.b.end()) { if(!CFReadStreamHasBytesAvailable(_readStream.get())) @@ -369,7 +370,8 @@ IceObjC::StreamTransceiver::read(Buffer& buf) } assert(_fd != INVALID_SOCKET); - CFIndex ret = CFReadStreamRead(_readStream.get(), reinterpret_cast<UInt8*>(&*buf.i), packetSize); + CFIndex ret = CFReadStreamRead(_readStream.get(), reinterpret_cast<UInt8*>(&*buf.i), + static_cast<CFIndex>(packetSize)); if(ret == 0) { @@ -390,7 +392,7 @@ IceObjC::StreamTransceiver::read(Buffer& buf) if(packetSize > static_cast<size_t>(buf.b.end() - buf.i)) { - packetSize = buf.b.end() - buf.i; + packetSize = static_cast<size_t>(buf.b.end() - buf.i); } } diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 46832e71757..9c568f75ef5 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -743,6 +743,11 @@ Activator::activate(const string& name, // of the newly created pipe. // int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX)); + if(maxFd <= 0) + { + maxFd = INT_MAX; + } + for(int fd = 3; fd < maxFd; ++fd) { if(fd != fds[1] && fd != errorFds[1]) diff --git a/cpp/src/IceIAP/Transceiver.mm b/cpp/src/IceIAP/Transceiver.mm index 3f2a0d3f4ae..2ca9931e407 100644 --- a/cpp/src/IceIAP/Transceiver.mm +++ b/cpp/src/IceIAP/Transceiver.mm @@ -263,7 +263,7 @@ IceObjC::iAPTransceiver::write(Buffer& buf) checkErrorStatus(_writeStream, __FILE__, __LINE__); } - size_t packetSize = buf.b.end() - buf.i; + size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i); while(buf.i != buf.b.end()) { if(![_writeStream hasSpaceAvailable]) @@ -287,7 +287,7 @@ IceObjC::iAPTransceiver::write(Buffer& buf) if(packetSize > static_cast<size_t>(buf.b.end() - buf.i)) { - packetSize = buf.b.end() - buf.i; + packetSize = static_cast<size_t>(buf.b.end() - buf.i); } } @@ -303,7 +303,7 @@ IceObjC::iAPTransceiver::read(Buffer& buf) checkErrorStatus(_readStream, __FILE__, __LINE__); } - size_t packetSize = buf.b.end() - buf.i; + size_t packetSize = static_cast<size_t>(buf.b.end() - buf.i); while(buf.i != buf.b.end()) { if(![_readStream hasBytesAvailable] && [_readStream streamStatus] != NSStreamStatusError) @@ -332,7 +332,7 @@ IceObjC::iAPTransceiver::read(Buffer& buf) if(packetSize > static_cast<size_t>(buf.b.end() - buf.i)) { - packetSize = buf.b.end() - buf.i; + packetSize = static_cast<size_t>(buf.b.end() - buf.i); } } diff --git a/cpp/src/IceSSL/CertificateI.cpp b/cpp/src/IceSSL/CertificateI.cpp index cb7e2d3ee39..bb5030f76cd 100644 --- a/cpp/src/IceSSL/CertificateI.cpp +++ b/cpp/src/IceSSL/CertificateI.cpp @@ -46,7 +46,7 @@ const CertificateOID IceSSL::certificateOIDS[] = const int IceSSL::certificateOIDSSize = sizeof(IceSSL::certificateOIDS) / sizeof(CertificateOID); CertificateReadException::CertificateReadException(const char* file, int line, const string& r) : - ExceptionHelper<CertificateReadException>(file, line), + IceUtil::ExceptionHelper<CertificateReadException>(file, line), reason(r) { } @@ -72,7 +72,7 @@ CertificateReadException::ice_clone() const #endif CertificateEncodingException::CertificateEncodingException(const char* file, int line, const string& r) : - ExceptionHelper<CertificateEncodingException>(file, line), + IceUtil::ExceptionHelper<CertificateEncodingException>(file, line), reason(r) { } @@ -98,7 +98,7 @@ CertificateEncodingException::ice_clone() const #endif ParseException::ParseException(const char* file, int line, const string& r) : - ExceptionHelper<ParseException>(file, line), + IceUtil::ExceptionHelper<ParseException>(file, line), reason(r) { } diff --git a/cpp/src/IceSSL/SecureTransportCertificateI.cpp b/cpp/src/IceSSL/SecureTransportCertificateI.cpp index 611a940a3e0..f0904e02645 100644 --- a/cpp/src/IceSSL/SecureTransportCertificateI.cpp +++ b/cpp/src/IceSSL/SecureTransportCertificateI.cpp @@ -83,7 +83,11 @@ class ASN1Parser { public: - ASN1Parser(CFDataRef data) : _data(CFDataGetBytePtr(data)), _length(CFDataGetLength(data)), _p(_data), _next(0) + ASN1Parser(CFDataRef data) : + _data(CFDataGetBytePtr(data)), + _length(static_cast<size_t>(CFDataGetLength(data))), + _p(_data), + _next(0) { } @@ -170,7 +174,7 @@ public: parseUTF8String() { int length = parseLength(0); - string v(reinterpret_cast<const char*>(_p), length); + string v(reinterpret_cast<const char*>(_p), static_cast<size_t>(length)); _p += length; return v; } @@ -828,7 +832,7 @@ IceSSL::SecureTransport::Certificate::decode(const std::string& encoding) } vector<unsigned char> data(IceInternal::Base64::decode(string(&encoding[startpos], size))); - UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], data.size())); + UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], static_cast<CFIndex>(data.size()))); SecCertificateRef cert = SecCertificateCreateWithData(0, certdata.get()); if(!cert) { diff --git a/cpp/src/IceSSL/SecureTransportUtil.cpp b/cpp/src/IceSSL/SecureTransportUtil.cpp index fbf7ebd53d1..0b0956d092b 100644 --- a/cpp/src/IceSSL/SecureTransportUtil.cpp +++ b/cpp/src/IceSSL/SecureTransportUtil.cpp @@ -487,7 +487,8 @@ loadCerts(const string& file) } vector<unsigned char> data(IceInternal::Base64::decode(string(&buffer[startpos], size))); - UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], data.size())); + UniqueRef<CFDataRef> certdata(CFDataCreate(kCFAllocatorDefault, &data[0], + static_cast<CFIndex>(data.size()))); UniqueRef<SecCertificateRef> cert(SecCertificateCreateWithData(0, certdata.get())); if(!cert) { diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp index e1b6babedcd..dd3d11f5483 100644 --- a/cpp/src/IceUtil/Options.cpp +++ b/cpp/src/IceUtil/Options.cpp @@ -529,7 +529,7 @@ IceUtilInternal::Options::split(const string& line) } default: { - assert(!"Impossible parse state"); + assert(false); // Impossible parse state break; } } @@ -559,7 +559,7 @@ IceUtilInternal::Options::split(const string& line) } default: { - assert(!"Impossible parse state"); + assert(false); // Impossible parse state break; } } |