X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=620f11737c3886eec097db153c93883de5b3e3ab;hb=aec772bdc98bdcfe35c2fc8e74942403c9efcc4d;hp=b9d31845fb33d958fc86ab7b53e019c51d1513a5;hpb=1a2623a51bcec6ffd692c6e1d9b333c11d23d51d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index b9d31845f..620f11737 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -166,14 +166,12 @@ void InspSocket::SetQueues(int nfd) */ bool InspSocket::BindAddr(const std::string &ip) { - Instance->Log(DEBUG,"BindAddr(%s)", ip.c_str()); ConfigReader Conf(this->Instance); - bool bindfail = false; socklen_t size = sizeof(sockaddr_in); #ifdef IPV6 bool v6 = false; /* Are we looking for a binding to fit an ipv6 host? */ - if ((!*this->host) || strchr(this->host, ':')) + if ((ip.empty()) || (ip.find(':') != std::string::npos)) v6 = true; #endif int j = 0; @@ -196,7 +194,11 @@ bool InspSocket::BindAddr(const std::string &ip) size = sizeof(sockaddr_in6); } else - bindfail = true; + { + delete[] s; + j++; + continue; + } } else { @@ -207,7 +209,11 @@ bool InspSocket::BindAddr(const std::string &ip) ((sockaddr_in*)s)->sin_family = AF_INET; } else - bindfail = true; + { + delete[] s; + j++; + continue; + } } #else in_addr n; @@ -217,13 +223,12 @@ bool InspSocket::BindAddr(const std::string &ip) ((sockaddr_in*)s)->sin_family = AF_INET; } else - bindfail = true; -#endif - if (bindfail) { delete[] s; - return false; + j++; + continue; } +#endif if (bind(this->fd, s, size) < 0) { @@ -472,7 +477,7 @@ bool InspSocket::FlushWriteBuffer() int result = Instance->Config->GetIOHook(this)->OnRawSocketWrite(this->fd, outbuffer[0].c_str(), outbuffer[0].length()); if (result > 0) { - if ((unsigned int)result == outbuffer[0].length()) + if ((unsigned int)result >= outbuffer[0].length()) { outbuffer.pop_front(); } @@ -510,7 +515,7 @@ bool InspSocket::FlushWriteBuffer() int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length()); if (result > 0) { - if ((unsigned int)result == outbuffer[0].length()) + if ((unsigned int)result >= outbuffer[0].length()) { /* The whole block was written (usually a line) * Pop the block off the front of the queue,