]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/inspsocket.cpp
Merge pull request #971 from SaberUK/master+numeric-xline
[user/henk/code/inspircd.git] / src / inspsocket.cpp
index d3ee7538b6e70102b32fae654b8f883a711aaea2..ee5287e5f33888e0cd24b46f0ce68979cf2d33f9 100644 (file)
@@ -219,7 +219,7 @@ void StreamSocket::DoWrite()
 {
        if (sendq.empty())
                return;
-       if (!error.empty() || fd < 0 || fd == INT_MAX)
+       if (!error.empty() || fd < 0)
        {
                ServerInstance->Logs->Log("SOCKET", LOG_DEBUG, "DoWrite on errored or closed socket");
                return;
@@ -339,15 +339,17 @@ void StreamSocket::DoWrite()
                        }
 
                        int rv_max = 0;
-                       iovec* iovecs = new iovec[bufcount];
-                       for(int i=0; i < bufcount; i++)
+                       int rv;
                        {
-                               iovecs[i].iov_base = const_cast<char*>(sendq[i].data());
-                               iovecs[i].iov_len = sendq[i].length();
-                               rv_max += sendq[i].length();
+                               iovec iovecs[MYIOV_MAX];
+                               for (int i = 0; i < bufcount; i++)
+                               {
+                                       iovecs[i].iov_base = const_cast<char*>(sendq[i].data());
+                                       iovecs[i].iov_len = sendq[i].length();
+                                       rv_max += sendq[i].length();
+                               }
+                               rv = writev(fd, iovecs, bufcount);
                        }
-                       int rv = writev(fd, iovecs, bufcount);
-                       delete[] iovecs;
 
                        if (rv == (int)sendq_len)
                        {