X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspsocket.cpp;h=1fbe3b5abbc9fed6866dc098058437b38cce7ce8;hb=9d4004e8d477232c143830508a7a6e41fd2d31b7;hp=86104c54d407eecaf030e3af50435410a867fc11;hpb=68e8a75daf6933d7ec4a3bd21cf12ed1ac880739;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 86104c54d..1fbe3b5ab 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 @@ -90,7 +90,7 @@ BufferedSocketError BufferedSocket::BeginConnect(const irc::sockets::sockaddrs& if (bind.sa.sa_family != 0) { - if (ServerInstance->SE->Bind(fd, &bind.sa, sa_size(bind)) < 0) + if (ServerInstance->SE->Bind(fd, bind) < 0) return I_ERR_BIND; } @@ -118,11 +118,6 @@ 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) { if (IOHook) @@ -142,7 +137,6 @@ void StreamSocket::Close() ServerInstance->SE->Close(this); fd = -1; } - errno = save; } CullResult StreamSocket::cull() @@ -156,7 +150,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 +230,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 +323,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 +527,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()); } @@ -541,7 +535,6 @@ void StreamSocket::HandleEvent(EventType et, int errornum) { ServerInstance->Logs->Log("SOCKET", DEBUG, "Error on FD %d - '%s'", fd, error.c_str()); OnError(errcode); - ServerInstance->GlobalCulls.AddItem(this); } }