From 0584675861f05321b89fff44fda38ebd49006e54 Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Wed, 17 Feb 2010 17:22:23 -0600 Subject: New I/O hook API This removes some pointless Module:: entries, uses the ServiceProvider lookup API for bind tags, and allows GnuTLS to use custom certificates per bind or link block using: --- src/inspsocket.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/inspsocket.cpp') diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 65b554006..ce301ffa9 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -122,18 +122,19 @@ void StreamSocket::Close() { // final chance, dump as much of the sendq as we can DoWrite(); - if (IOHook) + if (hook) { try { - IOHook->OnStreamSocketClose(this); + hook->OnClose(this); } catch (CoreException& modexcept) { ServerInstance->Logs->Log("SOCKET", DEFAULT,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason()); } - IOHook = NULL; + delete hook; + hook = NULL; } ServerInstance->SE->Shutdown(this, 2); ServerInstance->SE->DelFd(this); @@ -161,12 +162,12 @@ bool StreamSocket::GetNextLine(std::string& line, char delim) void StreamSocket::DoRead() { - if (IOHook) + if (hook) { int rv = -1; try { - rv = IOHook->OnStreamSocketRead(this, recvq); + rv = hook->OnRead(this, recvq); } catch (CoreException& modexcept) { @@ -227,7 +228,7 @@ void StreamSocket::DoWrite() } #ifndef DISABLE_WRITEV - if (IOHook) + if (hook) #endif { int rv = -1; @@ -253,9 +254,9 @@ void StreamSocket::DoWrite() } std::string& front = sendq.front(); int itemlen = front.length(); - if (IOHook) + if (hook) { - rv = IOHook->OnStreamSocketWrite(this, front); + rv = hook->OnWrite(this, front); if (rv > 0) { // consumed the entire string, and is ready for more @@ -465,10 +466,7 @@ void BufferedSocket::DoWrite() { state = I_CONNECTED; this->OnConnected(); - if (GetIOHook()) - GetIOHook()->OnStreamSocketConnect(this); - else - ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE); + ServerInstance->SE->ChangeEventMask(this, FD_WANT_FAST_READ | FD_WANT_EDGE_WRITE); } this->StreamSocket::DoWrite(); } -- cgit v1.3.1-10-gc9f91