diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-05 20:08:51 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-02-05 20:08:51 +0000 |
commit | 9a52a667163a6abc5b83fd268b55c9062b55131f (patch) | |
tree | ba92b20ce0cfdd404d9509fe93fc2ac0f1f96024 /include | |
parent | f631009527f3e615416f693e3a95266832a101bd (diff) |
Move quitting of clients to a central Cull List, and do quitting outside userrec and in main loop.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6497 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r-- | include/cull_list.h | 107 | ||||
-rw-r--r-- | include/inspircd.h | 15 | ||||
-rw-r--r-- | include/users.h | 44 |
3 files changed, 80 insertions, 86 deletions
diff --git a/include/cull_list.h b/include/cull_list.h index 678329bc2..64e6b3bdb 100644 --- a/include/cull_list.h +++ b/include/cull_list.h @@ -33,29 +33,29 @@ class CullItem : public classbase { private: /** Holds a pointer to the user, - * must be valid and can be a local or remote user. - */ - userrec* user; + * must be valid and can be a local or remote user. + */ + userrec* user; /** Holds the quit reason to use for this user. - */ + */ std::string reason; public: /** Constrcutor. - * Initializes the CullItem with a user pointer - * and their quit reason - * @param u The user to add - * @param r The quit reason of the added user - */ - CullItem(userrec* u, std::string &r); + * Initializes the CullItem with a user pointer + * and their quit reason + * @param u The user to add + * @param r The quit reason of the added user + */ + CullItem(userrec* u, std::string &r); CullItem(userrec* u, const char* r); ~CullItem(); /** Returns a pointer to the user - */ - userrec* GetUser(); + */ + userrec* GetUser(); /** Returns the user's quit reason - */ + */ std::string& GetReason(); }; @@ -75,50 +75,45 @@ class CullItem : public classbase class CullList : public classbase { private: - /** Creator of this CullList - */ - InspIRCd* ServerInstance; - /** Holds a list of users being quit. - * See the information for CullItem for - * more information. - */ - std::vector<CullItem> list; - /** A list of users who have already been - * placed on the list, as a map for fast - * reference. When deleting an item, the - * time_t value stored here must match - * the one of the actual userrec, otherwise - * we don't delete it (its a different user) - */ - std::map<userrec*,time_t> exempt; - - /** Check if a user pointer is valid - * (e.g. it exists in the user hash) - */ - bool IsValid(userrec* user); + /** Creator of this CullList + */ + InspIRCd* ServerInstance; + + /** Holds a list of users already added for quick lookup + */ + std::map<userrec*, userrec*> exempt; + + /** Holds a list of users being quit. + * See the information for CullItem for + * more information. + */ + std::vector<CullItem> list; + public: - /** Constructor. - * Clears the CullList::list and CullList::exempt - * items. - * @param Instance Creator of this CullList object - */ - CullList(InspIRCd* Instance); - /** Adds a user to the cull list for later - * removal via QUIT. - * @param user The user to add - * @param reason The quit reason of the user being added - */ - void AddItem(userrec* user, std::string &reason); - void AddItem(userrec* user, const char* reason); - /** Applies the cull list, quitting all the users - * on the list with their quit reasons all at once. - * This is a very fast operation compared to - * iterating the user list and comparing each one, - * especially if there are multiple comparisons - * to be done, or recursion. - * @returns The number of users removed from IRC. - */ - int Apply(); + /** Constructor. + * Clears the CullList::list and CullList::exempt + * items. + * @param Instance Creator of this CullList object + */ + CullList(InspIRCd* Instance); + + /** Adds a user to the cull list for later + * removal via QUIT. + * @param user The user to add + * @param reason The quit reason of the user being added + */ + void AddItem(userrec* user, std::string &reason); + void AddItem(userrec* user, const char* reason); + + /** Applies the cull list, quitting all the users + * on the list with their quit reasons all at once. + * This is a very fast operation compared to + * iterating the user list and comparing each one, + * especially if there are multiple comparisons + * to be done, or recursion. + * @returns The number of users removed from IRC. + */ + int Apply(); }; #endif diff --git a/include/inspircd.h b/include/inspircd.h index a1184a92a..60a29d5f4 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -25,6 +25,7 @@ #include "socketengine.h" #include "command_parse.h" #include "snomasks.h" +#include "cull_list.h" /** Returned by some functions to indicate failure. */ @@ -47,7 +48,7 @@ enum DebugLevel }; /** - * This define is used in place of strcmp when we + * This define is used in place of strcmp when we * want to check if a char* string contains only one * letter. Pretty fast, its just two compares and an * addition. @@ -296,7 +297,7 @@ class InspIRCd : public classbase /** Holds a string describing the last module error to occur */ char MODERR[MAXBUF]; - + /** Remove a ModuleFactory pointer * @param j Index number of the ModuleFactory to remove */ @@ -521,6 +522,10 @@ class InspIRCd : public classbase */ time_t next_call; + /** Global cull list, will be processed on next iteration + */ + CullList GlobalCulls; + /** Get the current time * Because this only calls time() once every time around the mainloop, * it is much faster than calling time() directly. @@ -629,7 +634,7 @@ class InspIRCd : public classbase * @param text The text to send */ void WriteOpers(const std::string &text); - + /** Find a nickname in the nick hash * @param nick The nickname to find * @return A pointer to the user, or NULL if the user does not exist @@ -705,7 +710,7 @@ class InspIRCd : public classbase /** Send text to all users with a specific set of modes * @param modes The modes to check against, without a +, e.g. 'og' - * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the + * @param flags one of WM_OR or WM_AND. If you specify WM_OR, any one of the * mode characters in the first parameter causes receipt of the message, and * if you specify WM_OR, all the modes must be present. * @param text The text format string to send @@ -1061,7 +1066,7 @@ class InspIRCd : public classbase bool DelELine(const std::string &hostmask); /** Return true if the given parameter is a valid nick!user\@host mask - * @param mask A nick!user\@host masak to match against + * @param mask A nick!user\@host masak to match against * @return True i the mask is valid */ bool IsValidMask(const std::string &mask); diff --git a/include/users.h b/include/users.h index bfe21f116..487bbb2ba 100644 --- a/include/users.h +++ b/include/users.h @@ -11,18 +11,17 @@ * --------------------------------------------------- */ -#ifndef __USERS_H__ -#define __USERS_H__ +#ifndef __USERS_H__ +#define __USERS_H__ #include <string> -#include "inspircd_config.h" +#include "inspircd_config.h" #include "socket.h" #include "channels.h" #include "inspstring.h" #include "connection.h" #include "hashcomp.h" #include "dns.h" -#include "cull_list.h" enum ChanStatus { STATUS_OP = 4, @@ -307,13 +306,13 @@ class userrec : public connection * When complete, these objects set userrec::dns_done to true. */ void StartDNSLookup(); - + /** The users nickname. * An invalid nickname indicates an unregistered connection prior to the NICK command. * Use InspIRCd::IsNick() to validate nicknames. */ char nick[NICKMAX]; - + /** The users ident reply. * Two characters are added to the user-defined limit to compensate for the tilde etc. */ @@ -323,11 +322,11 @@ class userrec : public connection * This usually matches the value of userrec::host. */ char dhost[65]; - + /** The users full name (GECOS). */ char fullname[MAXGECOS+1]; - + /** The user's mode list. * This is NOT a null terminated string! In the 1.1 version of InspIRCd * this is an array of values in a similar way to channel modes. @@ -347,28 +346,28 @@ class userrec : public connection /** Channels this user is on, and the permissions they have there */ UserChanList chans; - + /** The server the user is connected to. */ const char* server; - + /** The user's away message. * If this string is empty, the user is not marked as away. */ char awaymsg[MAXAWAY+1]; - + /** Number of lines the user can place into the buffer * (up to the global NetBufferSize bytes) before they * are disconnected for excess flood */ int flood; - + /** Timestamp of current time + connection class timeout. * This user must send USER/NICK before this timestamp is * reached or they will be disconnected. */ time_t timeout; - + /** The oper type they logged in as, if they are an oper. * This is used to check permissions in operclasses, so that * we can say 'yay' or 'nay' to any commands they issue. @@ -474,14 +473,14 @@ class userrec : public connection * @throw Nothing at present */ userrec(InspIRCd* Instance); - + /** Returns the full displayed host of the user * This member function returns the hostname of the user as seen by other users * on the server, in nick!ident&at;host form. * @return The full masked host of the user */ virtual char* GetFullHost(); - + /** Returns the full real host of the user * This member function returns the hostname of the user as seen by other users * on the server, in nick!ident&at;host form. If any form of hostname cloaking is in operation, @@ -536,25 +535,25 @@ class userrec : public connection * @param value On or off setting of the mode */ void SetMode(unsigned char m, bool value); - + /** Returns true if a user is invited to a channel. * @param channel A channel name to look up * @return True if the user is invited to the given channel */ virtual bool IsInvited(const irc::string &channel); - + /** Adds a channel to a users invite list (invites them to a channel) * @param channel A channel name to add */ virtual void InviteTo(const irc::string &channel); - + /** Removes a channel from a users invite list. * This member function is called on successfully joining an invite only channel * to which the user has previously been invited, to clear the invitation. * @param channel The channel to remove the invite to */ virtual void RemoveInvite(const irc::string &channel); - + /** Returns true or false for if a user can execute a privilaged oper command. * This is done by looking up their oper type from userrec::oper, then referencing * this to their oper classes and checking the commands they can execute. @@ -679,13 +678,8 @@ class userrec : public connection /** Use this method to fully connect a user. * This will send the message of the day, check G/K/E lines, etc. - * @param Goners If the user is disconnected by this method call, the - * value of 'this' will be pushed onto this CullList. This is used by - * the core to connect many users in rapid succession without invalidating - * iterators. - * @param Goners a CullList to use for failed connections */ - void FullConnect(CullList* Goners); + void FullConnect(); /** Change this users hash key to a new string. * You should not call this function directly. It is used by the core |