X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=65b554006a3207f86248b00b629f92c68b3ce5c7;hb=bf0dd0513e016abb4025748fe12e57539078c70b;hp=5099df88201016c68a2e68745604ba218c052f24;hpb=2aae57ca07b3de40feb72a21b2f2dea521665d80;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 5099df882..65b554006 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -118,13 +118,10 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs& void StreamSocket::Close() { - /* Save this, so we dont lose it, - * otherise on failure, error messages - * might be inaccurate. - */ - int save = errno; if (this->fd > -1) { + // final chance, dump as much of the sendq as we can + DoWrite(); if (IOHook) { try @@ -136,13 +133,13 @@ void StreamSocket::Close() ServerInstance->Logs->Log("SOCKET", DEFAULT,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason()); } + IOHook = NULL; } ServerInstance->SE->Shutdown(this, 2); ServerInstance->SE->DelFd(this); ServerInstance->SE->Close(this); fd = -1; } - errno = save; } CullResult StreamSocket::cull() @@ -236,7 +233,7 @@ void StreamSocket::DoWrite() int rv = -1; try { - while (!sendq.empty()) + while (error.empty() && !sendq.empty()) { if (sendq.size() > 1 && sendq[0].length() < 1024) { @@ -329,7 +326,7 @@ void StreamSocket::DoWrite() return; // start out optimistic - we won't need to write any more int eventChange = FD_WANT_EDGE_WRITE; - while (sendq_len && eventChange == FD_WANT_EDGE_WRITE) + while (error.empty() && sendq_len && eventChange == FD_WANT_EDGE_WRITE) { // Prepare a writev() call to write all buffers efficiently int bufcount = sendq.size();