summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-06 13:43:24 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-07-06 13:43:24 -0400
commit2c0cdc9484e2481f2b640a8eb9a997816e1f81ed (patch)
tree977c9e1efa5499d4f4db0ed454ea871f5d32b51f /node
parentcfef114c31f4edfa55d9c36eabd3fd319a94d307 (diff)
downloadinfinitytier-2c0cdc9484e2481f2b640a8eb9a997816e1f81ed.tar.gz
infinitytier-2c0cdc9484e2481f2b640a8eb9a997816e1f81ed.zip
Fix for failure to bind port if IPv6 is not enabled on a system -- it should succeed if it can bind either V4 or V6 or both and only fail if neither binds
Diffstat (limited to 'node')
-rw-r--r--node/Demarc.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/node/Demarc.cpp b/node/Demarc.cpp
index ae52db48..4885c086 100644
--- a/node/Demarc.cpp
+++ b/node/Demarc.cpp
@@ -93,9 +93,9 @@ bool Demarc::bindLocalUdp(unsigned int localPort)
uint64_t v4p = ((uint64_t)PORT_TYPE_UDP_SOCKET_V4 << 60) | (uint64_t)localPort;
uint64_t v6p = ((uint64_t)PORT_TYPE_UDP_SOCKET_V6 << 60) | (uint64_t)localPort;
if ((_ports.count((Port)v4p))||(_ports.count((Port)v6p)))
- return true;
+ return true; // port already bound
- UdpSocket *v4;
+ UdpSocket *v4 = (UdpSocket *)0;
try {
DemarcPortObj *v4r = &(_ports[(Port)v4p]);
v4r->port = (Port)v4p;
@@ -104,10 +104,10 @@ bool Demarc::bindLocalUdp(unsigned int localPort)
v4r->type = PORT_TYPE_UDP_SOCKET_V4;
} catch ( ... ) {
_ports.erase((Port)v4p);
- return false;
+ v4 = (UdpSocket *)0;
}
- UdpSocket *v6;
+ UdpSocket *v6 = (UdpSocket *)0;
try {
DemarcPortObj *v6r = &(_ports[(Port)v6p]);
v6r->port = (Port)v6p;
@@ -115,13 +115,11 @@ bool Demarc::bindLocalUdp(unsigned int localPort)
v6r->obj = v6 = new UdpSocket(localPort,true,&Demarc::_CBudpSocketPacketHandler,v6r);
v6r->type = PORT_TYPE_UDP_SOCKET_V6;
} catch ( ... ) {
- delete v4;
- _ports.erase((Port)v4p);
_ports.erase((Port)v6p);
- return false;
+ v6 = (UdpSocket *)0;
}
- return true;
+ return ((v4)||(v6));
}
Demarc::Port Demarc::pick(const InetAddress &to) const