X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=65b554006a3207f86248b00b629f92c68b3ce5c7;hb=bf0dd0513e016abb4025748fe12e57539078c70b;hp=6b3583a6a006e4d5aa1e07eef8e63fd25ebe0214;hpb=800f02e7599d5f90d1c16f02cb1c28901d354140;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 6b3583a6a..65b554006 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd: (C) 2002-2009 InspIRCd Development Team + * InspIRCd: (C) 2002-2010 InspIRCd Development Team * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see @@ -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() @@ -156,7 +153,7 @@ bool StreamSocket::GetNextLine(std::string& line, char delim) std::string::size_type i = recvq.find(delim); if (i == std::string::npos) return false; - line = recvq.substr(0, i - 1); + line = recvq.substr(0, i); // TODO is this the most efficient way to split? recvq = recvq.substr(i + 1); return true; @@ -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(); @@ -533,7 +530,7 @@ void StreamSocket::HandleEvent(EventType et, int errornum) } catch (CoreException& ex) { - ServerInstance->Logs->Log("SOCKET", ERROR, "Caught exception in socket processing on FD %d - '%s'", + ServerInstance->Logs->Log("SOCKET", DEFAULT, "Caught exception in socket processing on FD %d - '%s'", fd, ex.GetReason()); SetError(ex.GetReason()); }