summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/SslAcceptor.cpp4
-rw-r--r--cpp/src/Ice/SslTransceiver.cpp30
-rw-r--r--cpp/src/Ice/TcpAcceptor.cpp4
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp30
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp12
-rw-r--r--cpp/src/IcePack/Activator.cpp12
-rw-r--r--cpp/src/IcePack/Forward.cpp2
-rw-r--r--cpp/src/IcePack/Parser.cpp14
-rw-r--r--cpp/src/Slice/Parser.cpp4
9 files changed, 105 insertions, 7 deletions
diff --git a/cpp/src/Ice/SslAcceptor.cpp b/cpp/src/Ice/SslAcceptor.cpp
index 56717319e9d..d23f2fe08fa 100644
--- a/cpp/src/Ice/SslAcceptor.cpp
+++ b/cpp/src/Ice/SslAcceptor.cpp
@@ -109,7 +109,9 @@ IceInternal::SslAcceptor::equivalent(const string& host, int port) const
struct sockaddr_in addr;
getAddress(host.c_str(), port, addr);
if (addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
+ {
return port == ntohs(_addr.sin_port);
+ }
struct sockaddr_in localAddr;
getLocalAddress(ntohs(_addr.sin_port), localAddr);
@@ -126,7 +128,9 @@ IceInternal::SslAcceptor::SslAcceptor(const InstancePtr& instance, int port) :
#endif
if (_backlog <= 0)
+ {
_backlog = 5;
+ }
try
{
diff --git a/cpp/src/Ice/SslTransceiver.cpp b/cpp/src/Ice/SslTransceiver.cpp
index eeb334ae0c5..ba11c44533c 100644
--- a/cpp/src/Ice/SslTransceiver.cpp
+++ b/cpp/src/Ice/SslTransceiver.cpp
@@ -70,7 +70,9 @@ IceInternal::SslTransceiver::write(Buffer& buf, int timeout)
// Limit packet size to avoid performance problems on WIN32
//
if (packetSize > 64 * 1024)
+ {
packetSize = 64 * 1024;
+ }
#endif
while (buf.i != buf.b.end())
@@ -90,7 +92,9 @@ IceInternal::SslTransceiver::write(Buffer& buf, int timeout)
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
continue;
+ }
if (noBuffers() && packetSize > 1024)
{
@@ -114,27 +118,37 @@ IceInternal::SslTransceiver::write(Buffer& buf, int timeout)
ret = ::select(fd + 1, 0, &wFdSet, 0, &tv);
}
else
+ {
ret = ::select(fd + 1, 0, &wFdSet, 0, 0);
+ }
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeatSelect;
+ }
throw SocketException(__FILE__, __LINE__);
}
if (ret == 0)
+ {
throw TimeoutException(__FILE__, __LINE__);
+ }
}
continue;
}
if (connectionLost())
+ {
throw ConnectionLostException(__FILE__, __LINE__);
+ }
else
+ {
throw SocketException(__FILE__, __LINE__);
+ }
}
#ifndef ICE_NO_TRACE
@@ -149,7 +163,9 @@ IceInternal::SslTransceiver::write(Buffer& buf, int timeout)
buf.i += ret;
if (packetSize > buf.b.end() - buf.i)
+ {
packetSize = buf.b.end() - buf.i;
+ }
}
}
@@ -175,7 +191,9 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout)
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
continue;
+ }
if (noBuffers() && packetSize > 1024)
{
@@ -199,27 +217,37 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout)
ret = ::select(fd + 1, &rFdSet, 0, 0, &tv);
}
else
+ {
ret = ::select(fd + 1, &rFdSet, 0, 0, 0);
+ }
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeatSelect;
+ }
throw SocketException(__FILE__, __LINE__);
}
if (ret == 0)
+ {
throw TimeoutException(__FILE__, __LINE__);
+ }
}
continue;
}
if (connectionLost())
+ {
throw ConnectionLostException(__FILE__, __LINE__);
+ }
else
+ {
throw SocketException(__FILE__, __LINE__);
+ }
}
#ifndef ICE_NO_TRACE
@@ -234,7 +262,9 @@ IceInternal::SslTransceiver::read(Buffer& buf, int timeout)
buf.i += ret;
if (packetSize > buf.b.end() - buf.i)
+ {
packetSize = buf.b.end() - buf.i;
+ }
}
}
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp
index 779551b2aee..28c43b9ef16 100644
--- a/cpp/src/Ice/TcpAcceptor.cpp
+++ b/cpp/src/Ice/TcpAcceptor.cpp
@@ -109,7 +109,9 @@ IceInternal::TcpAcceptor::equivalent(const string& host, int port) const
struct sockaddr_in addr;
getAddress(host.c_str(), port, addr);
if (addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
+ {
return port == ntohs(_addr.sin_port);
+ }
struct sockaddr_in localAddr;
getLocalAddress(ntohs(_addr.sin_port), localAddr);
@@ -126,7 +128,9 @@ IceInternal::TcpAcceptor::TcpAcceptor(const InstancePtr& instance, int port) :
#endif
if (_backlog <= 0)
+ {
_backlog = 5;
+ }
try
{
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index 55240ec8eb1..9785922af1f 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -70,7 +70,9 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
// Limit packet size to avoid performance problems on WIN32
//
if (packetSize > 64 * 1024)
+ {
packetSize = 64 * 1024;
+ }
#endif
while (buf.i != buf.b.end())
@@ -90,7 +92,9 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
continue;
+ }
if (noBuffers() && packetSize > 1024)
{
@@ -114,27 +118,37 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
ret = ::select(fd + 1, 0, &wFdSet, 0, &tv);
}
else
+ {
ret = ::select(fd + 1, 0, &wFdSet, 0, 0);
+ }
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeatSelect;
+ }
throw SocketException(__FILE__, __LINE__);
}
if (ret == 0)
+ {
throw TimeoutException(__FILE__, __LINE__);
+ }
}
continue;
}
if (connectionLost())
+ {
throw ConnectionLostException(__FILE__, __LINE__);
+ }
else
+ {
throw SocketException(__FILE__, __LINE__);
+ }
}
#ifndef ICE_NO_TRACE
@@ -149,7 +163,9 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
buf.i += ret;
if (packetSize > buf.b.end() - buf.i)
+ {
packetSize = buf.b.end() - buf.i;
+ }
}
}
@@ -175,7 +191,9 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
continue;
+ }
if (noBuffers() && packetSize > 1024)
{
@@ -199,27 +217,37 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
ret = ::select(fd + 1, &rFdSet, 0, 0, &tv);
}
else
+ {
ret = ::select(fd + 1, &rFdSet, 0, 0, 0);
+ }
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeatSelect;
+ }
throw SocketException(__FILE__, __LINE__);
}
if (ret == 0)
+ {
throw TimeoutException(__FILE__, __LINE__);
+ }
}
continue;
}
if (connectionLost())
+ {
throw ConnectionLostException(__FILE__, __LINE__);
+ }
else
+ {
throw SocketException(__FILE__, __LINE__);
+ }
}
#ifndef ICE_NO_TRACE
@@ -234,7 +262,9 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
buf.i += ret;
if (packetSize > buf.b.end() - buf.i)
+ {
packetSize = buf.b.end() - buf.i;
+ }
}
}
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 5ec525de5f3..a22a0ee065e 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -35,9 +35,13 @@ IceInternal::UdpTransceiver::close()
{
ostringstream s;
if (_sender)
+ {
s << "stopping to send packets to " << toString();
+ }
else
+ {
s << "stopping to receive packets at " << toString();
+ }
_logger->trace(_traceLevels->networkCat, s.str());
}
#endif
@@ -66,7 +70,9 @@ repeat:
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeat;
+ }
throw SocketException(__FILE__, __LINE__);
}
@@ -100,7 +106,9 @@ repeat:
if (ret == SOCKET_ERROR)
{
if (interrupted())
+ {
goto repeat;
+ }
throw SocketException(__FILE__, __LINE__);
}
@@ -128,12 +136,16 @@ bool
IceInternal::UdpTransceiver::equivalent(const string& host, int port) const
{
if (_sender)
+ {
return false;
+ }
struct sockaddr_in addr;
getAddress(host.c_str(), port, addr);
if (addr.sin_addr.s_addr == htonl(INADDR_LOOPBACK))
+ {
return port == ntohs(_addr.sin_port);
+ }
struct sockaddr_in localAddr;
getLocalAddress(ntohs(_addr.sin_port), localAddr);
diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp
index ecc3a84da62..a75bc1b4874 100644
--- a/cpp/src/IcePack/Activator.cpp
+++ b/cpp/src/IcePack/Activator.cpp
@@ -13,6 +13,7 @@
#include <IcePack/Admin.h>
#include <sstream>
#include <fcntl.h>
+#include <sys/wait.h>
using namespace std;
using namespace Ice;
@@ -296,6 +297,17 @@ IcePack::Activator::terminationListener()
}
}
}
+
+ //
+ // Remove zombie processes, if any
+ //
+ if (waitpid(-1, 0, WNOHANG | WUNTRACED) == -1)
+ {
+ if (errno != ECHILD) // Ignore ECHILD
+ {
+ throw SystemException(__FILE__, __LINE__);
+ }
+ }
}
}
diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp
index 390cdc7945c..cfdf25e3bde 100644
--- a/cpp/src/IcePack/Forward.cpp
+++ b/cpp/src/IcePack/Forward.cpp
@@ -31,7 +31,7 @@ IcePack::Forward::Forward(const CommunicatorPtr& communicator, const AdminPtr& a
value = properties->getProperty("IcePack.Activator.WaitTime");
if (value.length())
{
- _waitTime = atoi(value);
+ _waitTime = atoi(value.c_str());
if (_waitTime < 0)
{
_waitTime = 0;
diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp
index 1f3febedad8..da7cb9be577 100644
--- a/cpp/src/IcePack/Parser.cpp
+++ b/cpp/src/IcePack/Parser.cpp
@@ -216,9 +216,12 @@ IcePack::Parser::error(const char* s)
{
if (!yycommands && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ' ';
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
+ }
+ else
+ {
+ cerr << "error: " << s << endl;
}
- cerr << "error: " << s << endl;
yynerrs++;
}
@@ -233,9 +236,12 @@ IcePack::Parser::warning(const char* s)
{
if (!yycommands && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ' ';
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
+ }
+ else
+ {
+ cerr << "warning: " << s << endl;
}
- cerr << "warning: " << s << endl;
}
void
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 63a7da6e124..58da790bea5 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -1664,7 +1664,7 @@ Slice::Unit::currentIncludeLevel()
void
Slice::Unit::error(const char* s)
{
- cerr << _currentFile << ':' << _currentLine << " error: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
yynerrs++;
}
@@ -1677,7 +1677,7 @@ Slice::Unit::error(const string& s)
void
Slice::Unit::warning(const char* s)
{
- cerr << _currentFile << ':' << _currentLine << " warning: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
}
void