diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-04-12 16:20:13 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-04-12 16:20:13 +0200 |
commit | 612384b3d46d06eea6fd71ee6dc60471d0f9e3d1 (patch) | |
tree | f9926b5ca8841a30c3a16916116a7d4102e91c31 /src/modules | |
parent | e3303330f8cc04121907715d789370f492878646 (diff) |
Dispatch EventHandler events to dedicated virtual functions
Remove enum EventType
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 21 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 35 |
2 files changed, 19 insertions, 37 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 1e73c0143..ff8c1174c 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -178,18 +178,19 @@ class SQLConn : public SQLProvider, public EventHandler } } - void HandleEvent(EventType et, int errornum) + void OnEventHandlerRead() CXX11_OVERRIDE { - switch (et) - { - case EVENT_READ: - case EVENT_WRITE: - DoEvent(); - break; + DoEvent(); + } - case EVENT_ERROR: - DelayReconnect(); - } + void OnEventHandlerWrite() CXX11_OVERRIDE + { + DoEvent(); + } + + void OnEventHandlerError(int errornum) CXX11_OVERRIDE + { + DelayReconnect(); } std::string GetDSN() diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 959e58a47..0e5aa43ae 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -140,9 +140,8 @@ class IdentRequestSocket : public EventHandler } } - void OnConnected() + void OnEventHandlerWrite() CXX11_OVERRIDE { - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "OnConnected()"); SocketEngine::ChangeEventMask(this, FD_WANT_POLL_READ | FD_WANT_NO_WRITE); char req[32]; @@ -163,30 +162,6 @@ class IdentRequestSocket : public EventHandler done = true; } - void HandleEvent(EventType et, int errornum = 0) - { - switch (et) - { - case EVENT_READ: - /* fd readable event, received ident response */ - ReadResponse(); - break; - case EVENT_WRITE: - /* fd writeable event, successfully connected! */ - OnConnected(); - break; - case EVENT_ERROR: - /* fd error event, ohshi- */ - ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "EVENT_ERROR"); - /* We *must* Close() here immediately or we get a - * huge storm of EVENT_ERROR events! - */ - Close(); - done = true; - break; - } - } - void Close() { /* Remove ident socket from engine, and close it, but dont detatch it @@ -204,7 +179,7 @@ class IdentRequestSocket : public EventHandler return done; } - void ReadResponse() + void OnEventHandlerRead() CXX11_OVERRIDE { /* We don't really need to buffer for incomplete replies here, since IDENT replies are * extremely short - there is *no* sane reason it'd be in more than one packet @@ -264,6 +239,12 @@ class IdentRequestSocket : public EventHandler } } + void OnEventHandlerError(int errornum) CXX11_OVERRIDE + { + Close(); + done = true; + } + CullResult cull() CXX11_OVERRIDE { Close(); |