]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Add extra /map info (connection uptime, and lag time) to /MAP for opers. Adds feature...
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index b9d31845fb33d958fc86ab7b53e019c51d1513a5..620f11737c3886eec097db153c93883de5b3e3ab 100644 (file)
@@ -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,