diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-18 01:08:14 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-18 01:08:14 +0000 |
commit | e381b06561228aaea752deda20a62c6dc99a560e (patch) | |
tree | 2119fe8bc8895597261935f389004e3c6bafe6a8 /src/modules | |
parent | 3c82d2d767186dd6d386dbbe08219ad8612e299e (diff) |
EventHandler class, an abstraction for raw i/o
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4941 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_cgiirc.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_samode.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 14 | ||||
-rw-r--r-- | src/modules/m_timedbans.cpp | 2 |
6 files changed, 23 insertions, 26 deletions
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 0a8c1fd11..1790fdfef 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -738,13 +738,12 @@ bool SQLConn::DoConnect() } this->state = I_CONNECTING; - if (!this->Instance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) + if (!this->Instance->SE->AddFd(this)) { Instance->Log(DEBUG, "A PQsocket cant be added to the socket engine!"); Close(); return false; } - this->Instance->socket_ref[this->fd] = this; /* Socket all hooked into the engine, now to tell PgSQL to start connecting */ @@ -754,9 +753,7 @@ bool SQLConn::DoConnect() void SQLConn::Close() { Instance->Log(DEBUG,"SQLConn::Close"); - - if(this->fd > 01) - Instance->socket_ref[this->fd] = NULL; + this->fd = -1; this->state = I_ERROR; this->OnError(I_ERR_SOCKET); diff --git a/src/modules/m_cgiirc.cpp b/src/modules/m_cgiirc.cpp index 496162877..d70bd9561 100644 --- a/src/modules/m_cgiirc.cpp +++ b/src/modules/m_cgiirc.cpp @@ -60,7 +60,7 @@ class CGIResolver : public Resolver virtual void OnLookupComplete(const std::string &result) { /* Check the user still exists */ - if ((them) && (them == ServerInstance->fd_ref_table[theirfd])) + if ((them) && (them == ServerInstance->SE->GetRef(theirfd))) { if (notify) ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), changing real host to %s from %s", them->nick, them->host, result.c_str(), typ.c_str()); @@ -73,7 +73,7 @@ class CGIResolver : public Resolver virtual void OnError(ResolverError e, const std::string &errormessage) { - if ((them) && (them == ServerInstance->fd_ref_table[theirfd])) + if ((them) && (them == ServerInstance->SE->GetRef(theirfd))) { if (notify) ServerInstance->WriteOpers("*** Connecting user %s detected as using CGI:IRC (%s), but their host can't be resolved from their %s!", them->nick, them->host,typ.c_str()); @@ -262,7 +262,7 @@ public: try { - CGIResolver* r = new CGIResolver(NotifyOpers, user->password, false, user, user->fd, "PASS"); + CGIResolver* r = new CGIResolver(NotifyOpers, user->password, false, user, user->GetFd(), "PASS"); ServerInstance->AddResolver(r); } catch (ModuleException& e) @@ -317,8 +317,8 @@ public: try { - ServerInstance->Log(DEBUG,"MAKE RESOLVER: %s %d %s",newip, user->fd, "IDENT"); - CGIResolver* r = new CGIResolver(NotifyOpers, newip, false, user, user->fd, "IDENT"); + ServerInstance->Log(DEBUG,"MAKE RESOLVER: %s %d %s",newip, user->GetFd(), "IDENT"); + CGIResolver* r = new CGIResolver(NotifyOpers, newip, false, user, user->GetFd(), "IDENT"); ServerInstance->AddResolver(r); } catch (ModuleException& e) diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 5e842b070..a7ffe6052 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -41,7 +41,7 @@ class RFC1413 : public InspSocket userrec* u; // user record that the lookup is associated with int ufd; - RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user), ufd(user->fd) + RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user), ufd(user->GetFd()) { } @@ -49,7 +49,7 @@ class RFC1413 : public InspSocket { // When we timeout, the connection failed within the allowed timeframe, // so we just display a notice, and tidy off the ident_data. - if (u && (Instance->fd_ref_table[ufd] == u)) + if (u && (Instance->SE->GetRef(ufd) == u)) { u->Shrink("ident_data"); u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Could not find your ident, using "+std::string(u->ident)+" instead."); @@ -80,7 +80,7 @@ class RFC1413 : public InspSocket *j = '\0'; // truncate at invalid chars if (*section) { - if (u && (Instance->fd_ref_table[ufd] == u)) + if (u && (Instance->SE->GetRef(ufd) == u)) { if (this->Instance->IsIdent(section)) { @@ -121,7 +121,7 @@ class RFC1413 : public InspSocket // descriptor that they were when the lookup began. // // Fixes issue reported by webs, 7 Jun 2006 - if (u && (Instance->fd_ref_table[ufd] == u)) + if (u && (Instance->SE->GetRef(ufd) == u)) { u->Shrink("ident_data"); } @@ -129,7 +129,7 @@ class RFC1413 : public InspSocket virtual void OnError(InspSocketError e) { - if (u && (Instance->fd_ref_table[ufd] == u)) + if (u && (Instance->SE->GetRef(ufd) == u)) { u->Shrink("ident_data"); } @@ -137,11 +137,11 @@ class RFC1413 : public InspSocket virtual bool OnConnected() { - if (u && (Instance->fd_ref_table[ufd] == u)) + if (u && (Instance->SE->GetRef(ufd) == u)) { uslen = sizeof(sock_us); themlen = sizeof(sock_them); - if ((getsockname(this->u->fd,(sockaddr*)&sock_us,&uslen) || getpeername(this->u->fd, (sockaddr*)&sock_them, &themlen))) + if ((getsockname(this->u->GetFd(),(sockaddr*)&sock_us,&uslen) || getpeername(this->u->GetFd(), (sockaddr*)&sock_them, &themlen))) { Instance->Log(DEBUG,"Ident: failed to get socket names, bailing"); return false; diff --git a/src/modules/m_samode.cpp b/src/modules/m_samode.cpp index 77d9a756d..2453308d3 100644 --- a/src/modules/m_samode.cpp +++ b/src/modules/m_samode.cpp @@ -57,7 +57,7 @@ class cmd_samode : public command_t std::string result; ServerInstance->Log(DEBUG,"SAMODE: Being handled"); userrec* n = new userrec(ServerInstance); - n->fd = FD_MAGIC_NUMBER; + n->SetFd(FD_MAGIC_NUMBER); ServerInstance->SendMode(parameters,pcnt,n); delete n; ServerInstance->Log(DEBUG,"SAMODE: Modechange handled"); diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index b3cc874bd..fde13ef98 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -309,7 +309,7 @@ class TreeServer : public classbase for (std::vector<userrec*>::iterator n = time_to_die.begin(); n != time_to_die.end(); n++) { userrec* a = (userrec*)*n; - ServerInstance->Log(DEBUG,"Kill %s fd=%d",a->nick,a->fd); + ServerInstance->Log(DEBUG,"Kill %s fd=%d",a->nick,a->GetFd()); if (!IS_LOCAL(a)) userrec::QuitUser(ServerInstance,a,reason_s); } @@ -932,7 +932,7 @@ class TreeSocket : public InspSocket { /* FMODE from a server, create a fake user to receive mode feedback */ who = new userrec(this->Instance); - who->fd = FD_MAGIC_NUMBER; + who->SetFd(FD_MAGIC_NUMBER); smode = true; /* Setting this flag tells us we should free the userrec later */ sourceserv = source; /* Set sourceserv to the actual source string */ } @@ -1542,7 +1542,7 @@ class TreeSocket : public InspSocket userrec* _new = new userrec(this->Instance); this->Instance->clientlist[tempnick] = _new; - _new->fd = FD_MAGIC_NUMBER; + _new->SetFd(FD_MAGIC_NUMBER); strlcpy(_new->nick, tempnick,NICKMAX-1); strlcpy(_new->host, params[2].c_str(),63); strlcpy(_new->dhost, params[3].c_str(),63); @@ -3135,7 +3135,7 @@ void GetListOfServersForChannel(chanrec* c, std::deque<TreeServer*> &list) CUList *ulist = c->GetUsers(); for (CUList::iterator i = ulist->begin(); i != ulist->end(); i++) { - if (i->second->fd < 0) + if (i->second->GetFd() < 0) { TreeServer* best = BestRouteTo(i->second->server); if (best) @@ -3689,7 +3689,7 @@ class ModuleSpanningTree : public Module if ((IS_LOCAL(user)) && (pcnt > 1)) { userrec* remote = ServerInstance->FindNick(parameters[1]); - if ((remote) && (remote->fd < 0)) + if ((remote) && (remote->GetFd() < 0)) { std::deque<std::string> params; params.push_back(parameters[1]); @@ -4005,7 +4005,7 @@ class ModuleSpanningTree : public Module if (target_type == TYPE_USER) { userrec* d = (userrec*)dest; - if ((d->fd < 0) && (IS_LOCAL(user))) + if ((d->GetFd() < 0) && (IS_LOCAL(user))) { std::deque<std::string> params; params.clear(); @@ -4053,7 +4053,7 @@ class ModuleSpanningTree : public Module // route private messages which are targetted at clients only to the server // which needs to receive them userrec* d = (userrec*)dest; - if ((d->fd < 0) && (IS_LOCAL(user))) + if ((d->GetFd() < 0) && (IS_LOCAL(user))) { std::deque<std::string> params; params.clear(); diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp index d933c7f13..8639aa7df 100644 --- a/src/modules/m_timedbans.cpp +++ b/src/modules/m_timedbans.cpp @@ -177,7 +177,7 @@ class ModuleTimedBans : public Module // hash and set its descriptor to FD_MAGIC_NUMBER so the data // falls into the abyss :p userrec* temp = new userrec(ServerInstance); - temp->fd = FD_MAGIC_NUMBER; + temp->SetFd(FD_MAGIC_NUMBER); /* FIX: Send mode remotely*/ std::deque<std::string> n; n.push_back(setban[0]); |