From 706303e177d05afa6269d3a40cfde726854c52c3 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 30 Jan 2007 20:32:59 +0000 Subject: Whoops, fix inspsocket so that its ok to use errno after a failure of the Write/Read methods or constructor! the close() in its Close method always changed errno to "Endpoint is not connected" on error, so now we make a copy. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6462 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspsocket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/inspsocket.cpp') diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 18fd346b7..f408de6dd 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -235,6 +235,11 @@ bool InspSocket::DoConnect() void InspSocket::Close() { + /* Save this, so we dont lose it, + * otherise on failure, error messages + * might be inaccurate. + */ + int save = errno; if (this->fd > -1) { if (this->IsIOHooked && Instance->Config->GetIOHook(this)) @@ -252,6 +257,7 @@ void InspSocket::Close() shutdown(this->fd,2); close(this->fd); } + errno = save; } std::string InspSocket::GetIP() -- cgit v1.2.3