From d17465716790010b6e3221f9ce49272110276ccf Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 11 Aug 2006 12:15:03 +0000 Subject: [PATCH] Now two types of log macro, log() and ilog(). log() assumes an InspIRCd object called ServerInstance, ilog() takes an InspIRCd object as first param. TODO: Run a regexp over these, using perl, to translate them into InspIRCd::Log calls and then eliminate the macro :) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4879 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/helperfuncs.h | 35 ----------- include/inspircd.h | 29 +++++++-- include/modules.h | 4 +- include/socketengine.h | 5 +- include/socketengine_epoll.h | 6 +- include/socketengine_kqueue.h | 6 +- include/socketengine_select.h | 6 +- src/base.cpp | 11 +--- src/channels.cpp | 11 ++-- src/cmd_oper.cpp | 1 - src/configreader.cpp | 32 +++++----- src/dns.cpp | 3 - src/dynamic.cpp | 3 - src/helperfuncs.cpp | 65 +++++--------------- src/inspircd.cpp | 4 +- src/inspsocket.cpp | 48 +++++++-------- src/modules.cpp | 3 - src/modules/extra/m_mysql.cpp | 41 ++----------- src/modules/extra/m_pgsql.cpp | 108 ++++++++++++++++----------------- src/modules/extra/m_sqllog.cpp | 16 +++-- src/modules/extra/m_sqlv2.h | 2 - src/modules/m_httpd.cpp | 6 +- src/modules/m_ident.cpp | 7 +-- src/modules/m_joinflood.cpp | 5 -- src/modules/m_messageflood.cpp | 5 -- src/modules/m_operlevels.cpp | 1 - src/modules/m_spanningtree.cpp | 26 ++++---- src/socket.cpp | 27 ++++----- src/socketengine.cpp | 4 +- src/socketengine_epoll.cpp | 3 +- src/socketengine_kqueue.cpp | 2 +- src/socketengine_select.cpp | 2 +- src/userprocess.cpp | 30 ++++----- src/users.cpp | 14 ++--- src/xline.cpp | 8 +-- 35 files changed, 236 insertions(+), 343 deletions(-) diff --git a/include/helperfuncs.h b/include/helperfuncs.h index bae7f8326..ce169c3b0 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -14,38 +14,3 @@ * --------------------------------------------------- */ -#ifndef _HELPER_H_ -#define _HELPER_H_ - -#include "dynamic.h" -#include "base.h" -#include "ctables.h" -#include "users.h" -#include "channels.h" -#include "typedefs.h" -#include -#include -#include - -/** Debug levels for use with InspIRCd::Log() - */ -enum DebugLevel -{ - DEBUG = 10, - VERBOSE = 20, - DEFAULT = 30, - SPARSE = 40, - NONE = 50, -}; - -/* I'm not entirely happy with this, the ## before 'args' is a g++ extension. - * The problem is that if you #define log(l, x, args...) and then call it - * with only two parameters, you get do_log(l, x, ), which is a syntax error... - * The ## tells g++ to remove the trailing comma... - * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a) - */ -#define STRINGIFY2(x) #x -#define STRINGIFY(x) STRINGIFY2(x) -#define log(l, x, args...) InspIRCd::Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) - -#endif diff --git a/include/inspircd.h b/include/inspircd.h index 699d910dc..3800c09ab 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -36,6 +36,28 @@ /* Crucial defines */ #define ETIREDGERBILS EAGAIN +/** Debug levels for use with InspIRCd::Log() + */ +enum DebugLevel +{ + DEBUG = 10, + VERBOSE = 20, + DEFAULT = 30, + SPARSE = 40, + NONE = 50, +}; + +/* I'm not entirely happy with this, the ## before 'args' is a g++ extension. + * The problem is that if you #define log(l, x, args...) and then call it + * with only two parameters, you get do_log(l, x, ), which is a syntax error... + * The ## tells g++ to remove the trailing comma... + * If this is ever an issue, we can just have an #ifndef GCC then #define log(a...) do_log(a) + */ +#define STRINGIFY2(x) #x +#define STRINGIFY(x) STRINGIFY2(x) +#define log(l, x, args...) ServerInstance->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) +#define ilog(i, l, x, args...) i->Log(l, __FILE__ ":" STRINGIFY(__LINE__) ": " x, ##args) + /* 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 @@ -43,7 +65,7 @@ */ #define IS_SINGLE(x,y) ( (*x == y) && (*(x+1) == 0) ) -#define DELETE(x) { InspIRCd::Log(DEBUG,"%s:%d: delete()",__FILE__,__LINE__); if (x) { delete x; x = NULL; } else InspIRCd::Log(DEBUG,"Attempt to delete NULL pointer!"); } +#define DELETE(x) {if (x) { delete x; x = NULL; }} template inline std::string ConvToStr(const T &in) { @@ -177,7 +199,6 @@ class InspIRCd : public classbase bool IsChannel(const char *chname); - static void Error(int status); static void Rehash(int status); static void Exit(int status); @@ -319,8 +340,8 @@ class InspIRCd : public classbase bool UnloadModule(const char* filename); InspIRCd(int argc, char** argv); void DoOneIteration(bool process_module_sockets); - static void Log(int level, const char* text, ...); - static void Log(int level, const std::string &text); + void Log(int level, const char* text, ...); + void Log(int level, const std::string &text); int Run(); }; diff --git a/include/modules.h b/include/modules.h index 9ca7eab5e..6142af17a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -111,7 +111,7 @@ typedef std::map featurelist; } \ catch (ModuleException& modexcept) \ { \ - log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); \ + ilog(z,DEBUG,"Module exception caught: %s",modexcept.GetReason()); \ } \ } \ } @@ -155,7 +155,7 @@ typedef std::map featurelist; } \ catch (ModuleException& modexcept) \ { \ - log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ + ilog(z,DEBUG,"Module exception cought: %s",modexcept.GetReason()); \ } \ } \ } \ diff --git a/include/socketengine.h b/include/socketengine.h index a788618a2..5ccfa801e 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -46,6 +46,8 @@ const char X_ESTAB_DNS = 4; */ const char X_READBIT = 0x80; +class InspIRCd; + /** * The actual socketengine class presents the * same interface on all operating systems, but @@ -67,6 +69,7 @@ const char X_READBIT = 0x80; class SocketEngine : public Extensible { protected: + InspIRCd* ServerInstance; int EngineHandle; /* Handle to the socket engine if needed */ int CurrentSetSize; /* Current number of descriptors in the engine */ char ref[MAX_DESCRIPTORS]; /* Reference table */ @@ -80,7 +83,7 @@ public: * epoll on a 2.4 linux kernel) then this * function may bail back to the shell. */ - SocketEngine(); + SocketEngine(InspIRCd* Instance); /** Destructor * The destructor transparently tidies up diff --git a/include/socketengine_epoll.h b/include/socketengine_epoll.h index ddbeb6f40..65d1150f7 100644 --- a/include/socketengine_epoll.h +++ b/include/socketengine_epoll.h @@ -27,12 +27,14 @@ #include #define EP_DELAY 5 +class InspIRCd; + class EPollEngine : public SocketEngine { private: struct epoll_event events[MAX_DESCRIPTORS]; /* Up to 64k sockets for epoll */ public: - EPollEngine(); + EPollEngine(InspIRCd* Instance); virtual ~EPollEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -45,7 +47,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new EPollEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new EPollEngine(Instance); } }; #endif diff --git a/include/socketengine_kqueue.h b/include/socketengine_kqueue.h index 822b4740a..d7451b642 100644 --- a/include/socketengine_kqueue.h +++ b/include/socketengine_kqueue.h @@ -28,13 +28,15 @@ #include #include "socketengine.h" +class InspIRCd; + class KQueueEngine : public SocketEngine { private: struct kevent ke_list[MAX_DESCRIPTORS]; /* Up to 64k sockets for kqueue */ struct timespec ts; /* kqueue delay value */ public: - KQueueEngine(); + KQueueEngine(InspIRCd* Instance); virtual ~KQueueEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -47,7 +49,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new KQueueEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new KQueueEngine(InspIRCd* Instance); } }; #endif diff --git a/include/socketengine_select.h b/include/socketengine_select.h index 442f8c754..b3f7479ee 100644 --- a/include/socketengine_select.h +++ b/include/socketengine_select.h @@ -26,13 +26,15 @@ #include "inspircd.h" #include "socketengine.h" +class InspIRCd; + class SelectEngine : public SocketEngine { private: std::map fds; /* List of file descriptors being monitored */ fd_set wfdset, rfdset; /* Readable and writeable sets for select() */ public: - SelectEngine(); + SelectEngine(InspIRCd* Instance); virtual ~SelectEngine(); virtual bool AddFd(int fd, bool readable, char type); virtual int GetMaxFds(); @@ -45,7 +47,7 @@ public: class SocketEngineFactory { public: - SocketEngine* Create() { return new SelectEngine(); } + SocketEngine* Create(InspIRCd* Instance) { return new SelectEngine(InspIRCd* Instance); } }; #endif diff --git a/src/base.cpp b/src/base.cpp index e79d336b7..30df1f0e7 100644 --- a/src/base.cpp +++ b/src/base.cpp @@ -38,16 +38,7 @@ bool Extensible::Shrink(const std::string &key) * returns the number of elements removed, std::map * is single-associative so this should only be 0 or 1 */ - if(this->Extension_Items.erase(key)) - { - log(DEBUG, "Shrinking object with item %s",key.c_str()); - return true; - } - else - { - log(DEBUG, "Tried to shrink object with item %s but no items removed", key.c_str()); - return false; - } + return this->Extension_Items.erase(key); } void Extensible::GetExtList(std::deque &list) diff --git a/src/channels.cpp b/src/channels.cpp index b72db32fc..f2f031a5c 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -240,7 +240,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo *Ptr->topic = 0; strlcpy(Ptr->setby, user->nick,NICKMAX-1); Ptr->topicset = 0; - log(DEBUG,"chanrec::JoinUser(): created: %s",cname); + ilog(Instance,DEBUG,"chanrec::JoinUser(): created: %s",cname); /* * set created to 2 to indicate user * is the first in the channel @@ -276,7 +276,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo { if (!key) { - log(DEBUG,"chanrec::JoinUser(): no key given in JOIN"); + ilog(Instance,DEBUG,"chanrec::JoinUser(): no key given in JOIN"); user->WriteServ("475 %s %s :Cannot join channel (Requires key)",user->nick, Ptr->name); return NULL; } @@ -284,7 +284,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo { if (strcmp(key,Ptr->key)) { - log(DEBUG,"chanrec::JoinUser(): bad key given in JOIN"); + ilog(Instance,DEBUG,"chanrec::JoinUser(): bad key given in JOIN"); user->WriteServ("475 %s %s :Cannot join channel (Incorrect key)",user->nick, Ptr->name); return NULL; } @@ -350,7 +350,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo } else { - log(DEBUG,"chanrec::JoinUser(): Overridden checks"); + ilog(Instance,DEBUG,"chanrec::JoinUser(): Overridden checks"); } created = 1; } @@ -391,7 +391,7 @@ chanrec* chanrec::JoinUser(InspIRCd* Instance, userrec *user, const char* cn, bo if (created == 2) { - log(DEBUG,"BLAMMO, Whacking channel."); + ilog(Instance,DEBUG,"BLAMMO, Whacking channel."); /* Things went seriously pear shaped, so take this away. bwahaha. */ chan_hash::iterator n = Instance->chanlist.find(cname); if (n != Instance->chanlist.end()) @@ -443,7 +443,6 @@ chanrec* chanrec::ForceChan(InspIRCd* Instance, chanrec* Ptr,ucrec *a,userrec* u /* Major improvement by Brain - we dont need to be calculating all this pointlessly for remote users */ if (IS_LOCAL(user)) { - log(DEBUG,"Sent JOIN to client"); if (Ptr->topicset) { user->WriteServ("332 %s %s :%s", user->nick, Ptr->name, Ptr->topic); diff --git a/src/cmd_oper.cpp b/src/cmd_oper.cpp index e8654ea59..1e206a3f2 100644 --- a/src/cmd_oper.cpp +++ b/src/cmd_oper.cpp @@ -42,7 +42,6 @@ bool OneOfMatches(const char* host, const char* ip, const char* hostlist) std::string xhost; while (hl >> xhost) { - log(DEBUG,"Oper: Matching host %s",xhost.c_str()); if (match(host,xhost.c_str()) || match(ip,xhost.c_str(),true)) { return true; diff --git a/src/configreader.cpp b/src/configreader.cpp index b57de1692..a90c23438 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -139,7 +139,7 @@ bool ServerConfig::CheckOnce(char* tag, bool bail, userrec* user) bool NoValidation(ServerConfig* conf, const char* tag, const char* value, void* data) { - log(DEBUG,"No validation for <%s:%s>",tag,value); + ilog(conf->GetInstance(),DEBUG,"No validation for <%s:%s>",tag,value); return true; } @@ -156,7 +156,7 @@ bool ValidateMaxTargets(ServerConfig* conf, const char* tag, const char* value, int* x = (int*)data; if ((*x < 0) || (*x > 31)) { - log(DEFAULT,"WARNING: value is greater than 31 or less than 0, set to 20."); + ilog(conf->GetInstance(),DEFAULT,"WARNING: value is greater than 31 or less than 0, set to 20."); *x = 20; } return true; @@ -167,7 +167,7 @@ bool ValidateSoftLimit(ServerConfig* conf, const char* tag, const char* value, v int* x = (int*)data; if ((*x < 1) || (*x > MAXCLIENTS)) { - log(DEFAULT,"WARNING: value is greater than %d or less than 0, set to %d.",MAXCLIENTS,MAXCLIENTS); + ilog(conf->GetInstance(),DEFAULT,"WARNING: value is greater than %d or less than 0, set to %d.",MAXCLIENTS,MAXCLIENTS); *x = MAXCLIENTS; } return true; @@ -177,7 +177,7 @@ bool ValidateMaxConn(ServerConfig* conf, const char* tag, const char* value, voi { int* x = (int*)data; if (*x > SOMAXCONN) - log(DEFAULT,"WARNING: value may be higher than the system-defined SOMAXCONN value!"); + ilog(conf->GetInstance(),DEFAULT,"WARNING: value may be higher than the system-defined SOMAXCONN value!"); if (!*x) *x = SOMAXCONN; return true; @@ -219,7 +219,7 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, v if (!*x) { // attempt to look up their nameserver from /etc/resolv.conf - log(DEFAULT,"WARNING: not defined, attempting to find working server in /etc/resolv.conf..."); + ilog(conf->GetInstance(),DEFAULT,"WARNING: not defined, attempting to find working server in /etc/resolv.conf..."); ifstream resolv("/etc/resolv.conf"); std::string nameserver; bool found_server = false; @@ -233,19 +233,19 @@ bool ValidateDnsServer(ServerConfig* conf, const char* tag, const char* value, v resolv >> nameserver; strlcpy(x,nameserver.c_str(),MAXBUF); found_server = true; - log(DEFAULT," set to '%s' as first resolver in /etc/resolv.conf.",nameserver.c_str()); + ilog(conf->GetInstance(),DEFAULT," set to '%s' as first resolver in /etc/resolv.conf.",nameserver.c_str()); } } if (!found_server) { - log(DEFAULT,"/etc/resolv.conf contains no viable nameserver entries! Defaulting to nameserver '127.0.0.1'!"); + ilog(conf->GetInstance(),DEFAULT,"/etc/resolv.conf contains no viable nameserver entries! Defaulting to nameserver '127.0.0.1'!"); strlcpy(x,"127.0.0.1",MAXBUF); } } else { - log(DEFAULT,"/etc/resolv.conf can't be opened! Defaulting to nameserver '127.0.0.1'!"); + ilog(conf->GetInstance(),DEFAULT,"/etc/resolv.conf can't be opened! Defaulting to nameserver '127.0.0.1'!"); strlcpy(x,"127.0.0.1",MAXBUF); } } @@ -266,7 +266,7 @@ bool ValidateServerName(ServerConfig* conf, const char* tag, const char* value, char* x = (char*)data; if (!strchr(x,'.')) { - log(DEFAULT,"WARNING: '%s' is not a fully-qualified domain name. Changed to '%s%c'",x,x,'.'); + ilog(conf->GetInstance(),DEFAULT,"WARNING: '%s' is not a fully-qualified domain name. Changed to '%s%c'",x,x,'.'); charlcat(x,'.',MAXBUF); } //strlower(x); @@ -277,7 +277,7 @@ bool ValidateNetBufferSize(ServerConfig* conf, const char* tag, const char* valu { if ((!conf->NetBufferSize) || (conf->NetBufferSize > 65535) || (conf->NetBufferSize < 1024)) { - log(DEFAULT,"No NetBufferSize specified or size out of range, setting to default of 10240."); + ilog(conf->GetInstance(),DEFAULT,"No NetBufferSize specified or size out of range, setting to default of 10240."); conf->NetBufferSize = 10240; } return true; @@ -287,7 +287,7 @@ bool ValidateMaxWho(ServerConfig* conf, const char* tag, const char* value, void { if ((!conf->MaxWhoResults) || (conf->MaxWhoResults > 65535) || (conf->MaxWhoResults < 1)) { - log(DEFAULT,"No MaxWhoResults specified or size out of range, setting to default of 128."); + ilog(conf->GetInstance(),DEFAULT,"No MaxWhoResults specified or size out of range, setting to default of 128."); conf->MaxWhoResults = 128; } return true; @@ -329,7 +329,7 @@ bool ValidateRules(ServerConfig* conf, const char* tag, const char* value, void* */ bool InitConnect(ServerConfig* conf, const char* tag) { - log(DEFAULT,"Reading connect classes..."); + ilog(conf->GetInstance(),DEFAULT,"Reading connect classes..."); conf->Classes.clear(); return true; } @@ -374,7 +374,7 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** value { c.threshold = 1; c.flood = 999; - log(DEFAULT,"Warning: Connect allow line '%s' has no flood/threshold settings. Setting this tag to 999 lines in 1 second.",c.host.c_str()); + ilog(conf->GetInstance(),DEFAULT,"Warning: Connect allow line '%s' has no flood/threshold settings. Setting this tag to 999 lines in 1 second.",c.host.c_str()); } if (c.sendqmax == 0) c.sendqmax = 262114; @@ -391,7 +391,7 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** value c.host = deny; c.type = CC_DENY; conf->Classes.push_back(c); - log(DEBUG,"Read connect class type DENY, host=%s",deny); + ilog(conf->GetInstance(),DEBUG,"Read connect class type DENY, host=%s",deny); } return true; @@ -401,7 +401,7 @@ bool DoConnect(ServerConfig* conf, const char* tag, char** entries, void** value */ bool DoneConnect(ServerConfig* conf, const char* tag) { - log(DEBUG,"DoneConnect called for tag: %s",tag); + ilog(conf->GetInstance(),DEBUG,"DoneConnect called for tag: %s",tag); return true; } @@ -418,7 +418,7 @@ bool InitULine(ServerConfig* conf, const char* tag) bool DoULine(ServerConfig* conf, const char* tag, char** entries, void** values, int* types) { char* server = (char*)values[0]; - log(DEBUG,"Read ULINE '%s'",server); + ilog(conf->GetInstance(),DEBUG,"Read ULINE '%s'",server); conf->ulines.push_back(server); return true; } diff --git a/src/dns.cpp b/src/dns.cpp index b67fef8d9..35b3c6825 100644 --- a/src/dns.cpp +++ b/src/dns.cpp @@ -194,10 +194,7 @@ int DNSRequest::SendRequests(const DNSHeader *header, const int length, QueryTyp addr.sin_port = htons(DNS::QUERY_PORT); #endif if (sendto(DNS::GetMasterSocket(), payload, length + 12, 0, (sockaddr *) &addr, sizeof(addr)) == -1) - { - log(DEBUG,"Error in sendto! (%s)",strerror(errno)); return -1; - } return 0; } diff --git a/src/dynamic.cpp b/src/dynamic.cpp index 23e1e3267..e773f8363 100644 --- a/src/dynamic.cpp +++ b/src/dynamic.cpp @@ -138,12 +138,10 @@ DLLManager::~DLLManager() bool DLLManager::GetSymbol(initfunc* &v, const char *sym_name) { - log(DEBUG,"Symbol search..."); for (int j = 0; modsyms[j].name; j++) { if (!strcmp(this->staticname,modsyms[j].name)) { - log(DEBUG,"Loading symbol..."); v = modsyms[j].value; err = 0; return true; @@ -162,7 +160,6 @@ bool DLLManager::GetSymbol(void** v, const char* sym_name) if (h) { - log(DEBUG,"Found symbol %s", sym_name); dlerror(); // clear value *v = dlsym(h, sym_name); err = (char*)dlerror(); diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 6d4bcfe3e..44958d44f 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -59,37 +59,35 @@ void InspIRCd::Log(int level, const char* text, ...) vsnprintf(textbuffer, MAXBUF, text, argsPtr); va_end(argsPtr); - InspIRCd::Log(level, std::string(textbuffer)); + this->Log(level, std::string(textbuffer)); } void InspIRCd::Log(int level, const std::string &text) { - extern InspIRCd* ServerInstance; - - if (!ServerInstance || !ServerInstance->Config) + if (!this->Config) return; /* If we were given -debug we output all messages, regardless of configured loglevel */ - if ((level < ServerInstance->Config->LogLevel) && !ServerInstance->Config->forcedebug) + if ((level < Config->LogLevel) && !Config->forcedebug) return; - if (ServerInstance->Time() != LAST) + if (Time() != LAST) { - time_t local = ServerInstance->Time(); + time_t local = Time(); struct tm *timeinfo = localtime(&local); strlcpy(TIMESTR,asctime(timeinfo),26); TIMESTR[24] = ':'; - LAST = ServerInstance->Time(); + LAST = Time(); } - if (ServerInstance->Config->log_file && ServerInstance->Config->writelog) + if (Config->log_file && Config->writelog) { - fprintf(ServerInstance->Config->log_file,"%s %s\n",TIMESTR,text.c_str()); - fflush(ServerInstance->Config->log_file); + fprintf(Config->log_file,"%s %s\n",TIMESTR,text.c_str()); + fflush(Config->log_file); } - if (ServerInstance->Config->nofork) + if (Config->nofork) { printf("%s %s\n", TIMESTR, text.c_str()); } @@ -194,7 +192,7 @@ void InspIRCd::WriteMode(const char* modes, int flags, const char* text, ...) if ((!text) || (!modes) || (!flags)) { - log(DEFAULT,"*** BUG *** WriteMode was given an invalid parameter"); + ilog(this,DEFAULT,"*** BUG *** WriteMode was given an invalid parameter"); return; } @@ -321,39 +319,6 @@ void InspIRCd::SendError(const char *s) } } -void InspIRCd::Error(int status) -{ - void *array[300]; - size_t size; - char **strings; - - signal(SIGALRM, SIG_IGN); - signal(SIGPIPE, SIG_IGN); - signal(SIGTERM, SIG_IGN); - signal(SIGABRT, SIG_IGN); - signal(SIGSEGV, SIG_IGN); - signal(SIGURG, SIG_IGN); - signal(SIGKILL, SIG_IGN); - log(DEFAULT,"*** fell down a pothole in the road to perfection ***"); -#ifdef HAS_EXECINFO - log(DEFAULT,"Please report the backtrace lines shown below with any bugreport to the bugtracker at http://www.inspircd.org/bugtrack/"); - size = backtrace(array, 30); - strings = backtrace_symbols(array, size); - for (size_t i = 0; i < size; i++) { - log(DEFAULT,"[%d] %s", i, strings[i]); - } - free(strings); -#else - log(DEFAULT,"You do not have execinfo.h so i could not backtrace -- on FreeBSD, please install the libexecinfo port."); -#endif - signal(SIGSEGV, SIG_DFL); - if (raise(SIGSEGV) == -1) - { - log(DEFAULT,"What the hell, i couldnt re-raise SIGSEGV! Error: %s",strerror(errno)); - } - Exit(status); -} - // this function counts all users connected, wether they are registered or NOT. int InspIRCd::usercnt() { @@ -498,7 +463,7 @@ void InspIRCd::CheckRoot() if (geteuid() == 0) { printf("WARNING!!! You are running an irc server as ROOT!!! DO NOT DO THIS!!!\n\n"); - log(DEFAULT,"InspIRCd: startup: not starting with UID 0!"); + ilog(this,DEFAULT,"Cant start as root"); Exit(ERROR); } } @@ -508,7 +473,7 @@ void InspIRCd::CheckDie() if (*Config->DieValue) { printf("WARNING: %s\n\n",Config->DieValue); - log(DEFAULT,"Uh-Oh, somebody didn't read their config file: '%s'",Config->DieValue); + ilog(this,DEFAULT,"Died because of tag: %s",Config->DieValue); Exit(ERROR); } } @@ -527,12 +492,12 @@ void InspIRCd::LoadAllModules() if (!this->LoadModule(configToken)) { - log(DEFAULT,"Exiting due to a module loader error."); + ilog(this,DEFAULT,"There was an error loading a module: %s", this->ModuleError()); printf("\nThere was an error loading a module: %s\n\n",this->ModuleError()); Exit(ERROR); } } printf("\nA total of \033[1;32m%d\033[0m module%s been loaded.\n", this->ModCount+1, this->ModCount+1 == 1 ? " has" : "s have"); - log(DEFAULT,"Total loaded modules: %d", this->ModCount+1); + ilog(this,DEFAULT,"Total loaded modules: %d", this->ModCount+1); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 22d2e51a9..c63ac750b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -136,8 +136,6 @@ void InspIRCd::SetSignals(bool SEGVHandler) signal (SIGHUP, InspIRCd::Rehash); signal (SIGPIPE, SIG_IGN); signal (SIGTERM, InspIRCd::Exit); - if (SEGVHandler) - signal (SIGSEGV, InspIRCd::Error); } bool InspIRCd::DaemonSeed() @@ -301,7 +299,7 @@ InspIRCd::InspIRCd(int argc, char** argv) : ModCount(-1) * initialize the socket engine. */ SocketEngineFactory* SEF = new SocketEngineFactory(); - SE = SEF->Create(); + SE = SEF->Create(this); delete SEF; /* We must load the modules AFTER initializing the socket engine, now */ diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index c99dedf96..c419ba130 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -65,14 +65,14 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool this->state = I_ERROR; this->OnError(I_ERR_SOCKET); this->ClosePending = true; - log(DEBUG,"OpenTCPSocket() error"); + ilog(this->Instance,DEBUG,"OpenTCPSocket() error"); return; } else { if (!SI->BindSocket(this->fd,this->client,this->server,aport,(char*)ipaddr.c_str())) { - log(DEBUG,"BindSocket() error %s",strerror(errno)); + ilog(this->Instance,DEBUG,"BindSocket() error %s",strerror(errno)); this->Close(); this->fd = -1; this->state = I_ERROR; @@ -94,7 +94,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool } this->Instance->socket_ref[this->fd] = this; } - log(DEBUG,"New socket now in I_LISTENING state"); + ilog(this->Instance,DEBUG,"New socket now in I_LISTENING state"); return; } } @@ -106,7 +106,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool if (insp_aton(host,&addy) < 1) { - log(DEBUG,"You cannot pass hostnames to InspSocket, resolve them first with Resolver!"); + ilog(this->Instance,DEBUG,"You cannot pass hostnames to InspSocket, resolve them first with Resolver!"); this->Close(); this->fd = -1; this->state = I_ERROR; @@ -116,7 +116,7 @@ InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool } else { - log(DEBUG,"No need to resolve %s",this->host); + ilog(this->Instance,DEBUG,"No need to resolve %s",this->host); strlcpy(this->IP,host,MAXBUF); timeout_end = time(NULL) + maxtime; this->DoConnect(); @@ -170,7 +170,7 @@ bool InspSocket::BindAddr() insp_inaddr n; ConfigReader Conf(this->Instance); - log(DEBUG,"In InspSocket::BindAddr()"); + ilog(this->Instance,DEBUG,"In InspSocket::BindAddr()"); for (int j =0; j < Conf.Enumerate("bind"); j++) { std::string Type = Conf.ReadValue("bind","type",j); @@ -183,7 +183,7 @@ bool InspSocket::BindAddr() if (insp_aton(IP.c_str(),&n) > 0) { - log(DEBUG,"Found an IP to bind to: %s",IP.c_str()); + ilog(this->Instance,DEBUG,"Found an IP to bind to: %s",IP.c_str()); #ifdef IPV6 s.sin6_addr = n; s.sin6_family = AF_FAMILY; @@ -193,32 +193,32 @@ bool InspSocket::BindAddr() #endif if (bind(this->fd,(struct sockaddr*)&s,sizeof(s)) < 0) { - log(DEBUG,"Cant bind()"); + ilog(this->Instance,DEBUG,"Cant bind()"); this->state = I_ERROR; this->OnError(I_ERR_BIND); this->fd = -1; return false; } - log(DEBUG,"bind() reports outbound fd bound to ip %s",IP.c_str()); + ilog(this->Instance,DEBUG,"bind() reports outbound fd bound to ip %s",IP.c_str()); return true; } else { - log(DEBUG,"Address '%s' was not an IP address",IP.c_str()); + ilog(this->Instance,DEBUG,"Address '%s' was not an IP address",IP.c_str()); } } } } - log(DEBUG,"Found no suitable IPs to bind, binding INADDR_ANY"); + ilog(this->Instance,DEBUG,"Found no suitable IPs to bind, binding INADDR_ANY"); return true; } bool InspSocket::DoConnect() { - log(DEBUG,"In DoConnect()"); + ilog(this->Instance,DEBUG,"In DoConnect()"); if ((this->fd = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1) { - log(DEBUG,"Cant socket()"); + ilog(this->Instance,DEBUG,"Cant socket()"); this->state = I_ERROR; this->OnError(I_ERR_SOCKET); this->fd = -1; @@ -231,7 +231,7 @@ bool InspSocket::DoConnect() return false; } - log(DEBUG,"Part 2 DoConnect() %s",this->IP); + ilog(this->Instance,DEBUG,"Part 2 DoConnect() %s",this->IP); insp_aton(this->IP,&addy); #ifdef IPV6 addr.sin6_family = AF_FAMILY; @@ -251,7 +251,7 @@ bool InspSocket::DoConnect() { if (errno != EINPROGRESS) { - log(DEBUG,"Error connect() %d: %s",this->fd,strerror(errno)); + ilog(this->Instance,DEBUG,"Error connect() %d: %s",this->fd,strerror(errno)); this->OnError(I_ERR_CONNECT); this->Close(); this->state = I_ERROR; @@ -275,7 +275,7 @@ bool InspSocket::DoConnect() this->Instance->socket_ref[this->fd] = this; this->SetQueues(this->fd); } - log(DEBUG,"Returning true from InspSocket::DoConnect"); + ilog(this->Instance,DEBUG,"Returning true from InspSocket::DoConnect"); return true; } @@ -316,7 +316,7 @@ char* InspSocket::Read() } else { - log(DEBUG,"EOF or error on socket: %s",strerror(errno)); + ilog(this->Instance,DEBUG,"EOF or error on socket: %s",strerror(errno)); return NULL; } } @@ -324,7 +324,7 @@ char* InspSocket::Read() void InspSocket::MarkAsClosed() { - log(DEBUG,"Marked as closed"); + ilog(this->Instance,DEBUG,"Marked as closed"); this->ClosePending = true; } @@ -375,7 +375,7 @@ bool InspSocket::FlushWriteBuffer() } else if ((result == -1) && (errno != EAGAIN)) { - log(DEBUG,"Write error on socket: %s",strerror(errno)); + ilog(this->Instance,DEBUG,"Write error on socket: %s",strerror(errno)); this->OnError(I_ERR_WRITE); this->state = I_ERROR; this->ClosePending = true; @@ -390,19 +390,19 @@ bool InspSocket::Timeout(time_t current) { if (!this->Instance->socket_ref[this->fd] || !this->Instance->SE->HasFd(this->fd)) { - log(DEBUG,"No FD or socket ref"); + ilog(this->Instance,DEBUG,"No FD or socket ref"); return false; } if (this->ClosePending) { - log(DEBUG,"Close is pending"); + ilog(this->Instance,DEBUG,"Close is pending"); return true; } if ((this->state == I_CONNECTING) && (current > timeout_end)) { - log(DEBUG,"Timed out, current=%lu timeout_end=%lu"); + ilog(this->Instance,DEBUG,"Timed out, current=%lu timeout_end=%lu"); // for non-listening sockets, the timeout can occur // which causes termination of the connection after // the given number of seconds without a successful @@ -431,7 +431,7 @@ bool InspSocket::Poll() switch (this->state) { case I_CONNECTING: - log(DEBUG,"State = I_CONNECTING"); + ilog(this->Instance,DEBUG,"State = I_CONNECTING"); this->SetState(I_CONNECTED); /* Our socket was in write-state, so delete it and re-add it * in read-state. @@ -489,7 +489,7 @@ bool InspSocket::Poll() void InspSocket::SetState(InspSocketState s) { - log(DEBUG,"Socket state change"); + ilog(this->Instance,DEBUG,"Socket state change"); this->state = s; } diff --git a/src/modules.cpp b/src/modules.cpp index ed2d5a2fd..fd5672cd3 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -419,7 +419,6 @@ bool InspIRCd::UserToPseudo(userrec* user, const std::string &message) if (find(local_users.begin(),local_users.end(),user) != local_users.end()) { local_users.erase(find(local_users.begin(),local_users.end(),user)); - log(DEBUG,"Delete local user"); } this->SE->DelFd(old_fd); @@ -430,7 +429,6 @@ bool InspIRCd::UserToPseudo(userrec* user, const std::string &message) bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string &message) { - log(DEBUG,"PseudoToUser"); zombie->fd = alive->fd; FOREACH_MOD_I(this,I_OnUserQuit,OnUserQuit(alive,message)); alive->fd = FD_MAGIC_NUMBER; @@ -444,7 +442,6 @@ bool InspIRCd::PseudoToUser(userrec* alive, userrec* zombie, const std::string & if (find(local_users.begin(),local_users.end(),alive) != local_users.end()) { local_users.erase(find(local_users.begin(),local_users.end(),alive)); - log(DEBUG,"Delete local user"); } // Fix by brain - cant write the user until their fd table entry is updated this->fd_ref_table[zombie->fd] = zombie; diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index b539f6327..d8a20535a 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -102,8 +102,6 @@ public: void push(const SQLrequest &q) { - log(DEBUG, "QueryQueue::push(): Adding %s query to queue: %s", ((q.pri) ? "priority" : "non-priority"), q.query.q.c_str()); - if(q.pri) priority.push_back(q); else @@ -216,7 +214,6 @@ class MySQLresult : public SQLresult { /* A number of affected rows from from mysql_affected_rows. */ - log(DEBUG,"Created new MySQLresult of non-error type"); fieldlists.clear(); rows = 0; if (affected_rows >= 1) @@ -249,7 +246,6 @@ class MySQLresult : public SQLresult SQLfield sqlf(b, !row[field_count]); colnames.push_back(a); fieldlists[n].push_back(sqlf); - log(DEBUG,"Inc field count to %d",field_count+1); field_count++; } n++; @@ -258,14 +254,12 @@ class MySQLresult : public SQLresult } mysql_free_result(res); } - log(DEBUG, "Created new MySQL result; %d rows, %d columns", rows, colnames.size()); } MySQLresult(Module* self, Module* to, SQLerror e, unsigned int id) : SQLresult(self, to, id), currentrow(0) { rows = 0; error = e; - log(DEBUG,"Created new MySQLresult of error type"); } ~MySQLresult() @@ -313,7 +307,6 @@ class MySQLresult : public SQLresult return fieldlists[row][column]; } - log(DEBUG,"Danger will robinson, we don't have row %d, column %d!", row, column); throw SQLbadColName(); /* XXX: We never actually get here because of the throw */ @@ -439,7 +432,6 @@ class SQLConnection : public classbase /* Parse the command string and dispatch it to mysql */ SQLrequest& req = queue.front(); - log(DEBUG,"DO QUERY: %s",req.query.q.c_str()); /* Pointer to the buffer we screw around with substitution in */ char* query; @@ -491,10 +483,7 @@ class SQLConnection : public classbase req.query.p.pop_front(); } else - { - log(DEBUG, "Found a substitution location but no parameter to substitute :|"); break; - } } else { @@ -506,14 +495,10 @@ class SQLConnection : public classbase *queryend = 0; - log(DEBUG, "Attempting to dispatch query: %s", query); - pthread_mutex_lock(&queue_mutex); req.query.q = query; pthread_mutex_unlock(&queue_mutex); - log(DEBUG,"REQUEST ID: %d",req.id); - if (!mysql_real_query(&connection, req.query.q.data(), req.query.q.length())) { /* Successfull query */ @@ -533,7 +518,6 @@ class SQLConnection : public classbase { /* XXX: See /usr/include/mysql/mysqld_error.h for a list of * possible error numbers and error messages */ - log(DEBUG,"SQL ERROR: %s",mysql_error(&connection)); SQLerror e(QREPLY_FAIL, ConvToStr(mysql_errno(&connection)) + std::string(": ") + mysql_error(&connection)); MySQLresult* r = new MySQLresult(SQLModule, req.GetSource(), e, req.id); r->dbid = this->GetID(); @@ -649,12 +633,7 @@ void NotifyMainThread(SQLConnection* connection_with_new_result) * block if we like. We just send the connection id of the * connection back. */ - log(DEBUG,"Notify of result on connection: %s",connection_with_new_result->GetID().c_str()); - if (send(QueueFD, connection_with_new_result->GetID().c_str(), connection_with_new_result->GetID().length()+1, 0) < 1) // add one for null terminator - { - log(DEBUG,"Error writing to QueueFD: %s",strerror(errno)); - } - log(DEBUG,"Sent it on its way via fd=%d",QueueFD); + send(QueueFD, connection_with_new_result->GetID().c_str(), connection_with_new_result->GetID().length()+1, 0); } void* DispatcherThread(void* arg); @@ -683,7 +662,7 @@ class Notifier : public InspSocket Notifier(InspIRCd* SI, int newfd, char* ip) : InspSocket(SI, newfd, ip) { - log(DEBUG,"Constructor of new socket"); + ilog(Instance,DEBUG,"Constructor of new socket"); } /* Using getsockname and ntohs, we can determine which port number we were allocated */ @@ -698,7 +677,7 @@ class Notifier : public InspSocket virtual int OnIncomingConnection(int newsock, char* ip) { - log(DEBUG,"Inbound connection on fd %d!",newsock); + ilog(Instance,DEBUG,"Inbound connection on fd %d!",newsock); Notifier* n = new Notifier(this->Instance, newsock, ip); this->Instance->AddSocket(n); return true; @@ -706,17 +685,17 @@ class Notifier : public InspSocket virtual bool OnDataReady() { - log(DEBUG,"Inbound data!"); + ilog(Instance,DEBUG,"Inbound data!"); char* data = this->Read(); ConnMap::iterator iter; if (data && *data) { - log(DEBUG,"Looking for connection %s",data); + ilog(Instance,DEBUG,"Looking for connection %s",data); /* We expect to be sent a null terminated string */ if((iter = Connections.find(data)) != Connections.end()) { - log(DEBUG,"Found it!"); + ilog(Instance,DEBUG,"Found it!"); /* Lock the mutex, send back the data */ pthread_mutex_lock(&results_mutex); @@ -837,7 +816,6 @@ class ModuleSQL : public Module void* DispatcherThread(void* arg) { - log(DEBUG,"Starting Dispatcher thread, mysql version %d",mysql_get_client_version()); ModuleSQL* thismodule = (ModuleSQL*)arg; LoadDatabases(thismodule->Conf, thismodule->PublicServerInstance); @@ -846,12 +824,9 @@ void* DispatcherThread(void* arg) if ((QueueFD = socket(AF_FAMILY, SOCK_STREAM, 0)) == -1) { /* crap, we're out of sockets... */ - log(DEBUG,"QueueFD cant be created"); return NULL; } - log(DEBUG,"Initialize QueueFD to %d",QueueFD); - insp_sockaddr addr; #ifdef IPV6 @@ -869,12 +844,9 @@ void* DispatcherThread(void* arg) if (connect(QueueFD, (sockaddr*)&addr,sizeof(addr)) == -1) { /* wtf, we cant connect to it, but we just created it! */ - log(DEBUG,"QueueFD cant connect!"); return NULL; } - log(DEBUG,"Connect QUEUE FD"); - while (!giveup) { SQLConnection* conn = NULL; @@ -894,7 +866,6 @@ void* DispatcherThread(void* arg) /* Theres an item! */ if (conn) { - log(DEBUG,"Process Leading query"); conn->DoLeadingQuery(); /* XXX: Lock */ diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index e4319aed5..b3427261a 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -152,7 +152,7 @@ public: void push(const SQLrequest &q) { - log(DEBUG, "QueryQueue::push(): Adding %s query to queue: %s", ((q.pri) ? "priority" : "non-priority"), q.query.q.c_str()); + //log(DEBUG, "QueryQueue::push(): Adding %s query to queue: %s", ((q.pri) ? "priority" : "non-priority"), q.query.q.c_str()); if(q.pri) priority.push_back(q); @@ -268,7 +268,7 @@ public: rows = PQntuples(res); cols = PQnfields(res); - log(DEBUG, "Created new PgSQL result; %d rows, %d columns, %s affected", rows, cols, PQcmdTuples(res)); + //log(DEBUG, "Created new PgSQL result; %d rows, %d columns, %s affected", rows, cols, PQcmdTuples(res)); } ~PgSQLresult() @@ -331,7 +331,7 @@ public: } else { - log(DEBUG, "PQgetvalue returned a null pointer..nobody wants to tell us what this means"); + //log(DEBUG, "PQgetvalue returned a null pointer..nobody wants to tell us what this means"); throw SQLbadColName(); } } @@ -662,7 +662,7 @@ public: SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, const SQLhost& hi) : InspSocket::InspSocket(SI), us(self), dbhost(hi.host), dbport(hi.port), dbname(hi.name), dbuser(hi.user), dbpass(hi.pass), ssl(hi.ssl), sql(NULL), status(CWRITE), qinprog(false) { - log(DEBUG, "Creating new PgSQL connection to database %s on %s:%u (%s/%s)", dbname.c_str(), dbhost.c_str(), dbport, dbuser.c_str(), dbpass.c_str()); + //log(DEBUG, "Creating new PgSQL connection to database %s on %s:%u (%s/%s)", dbname.c_str(), dbhost.c_str(), dbport, dbuser.c_str(), dbpass.c_str()); /* Some of this could be reviewed, unsure if I need to fill 'host' etc... * just copied this over from the InspSocket constructor. @@ -674,7 +674,7 @@ SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, const SQLhost& hi) this->ClosePending = false; - log(DEBUG,"No need to resolve %s", this->host); + ilog(Instance,DEBUG,"No need to resolve %s", this->host); if(!this->DoConnect()) @@ -690,18 +690,18 @@ SQLConn::~SQLConn() bool SQLConn::DoConnect() { - log(DEBUG, "SQLConn::DoConnect()"); + //log(DEBUG, "SQLConn::DoConnect()"); if(!(sql = PQconnectStart(MkInfoStr().c_str()))) { - log(DEBUG, "Couldn't allocate PGconn structure, aborting: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "Couldn't allocate PGconn structure, aborting: %s", PQerrorMessage(sql)); Close(); return false; } if(PQstatus(sql) == CONNECTION_BAD) { - log(DEBUG, "PQconnectStart failed: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "PQconnectStart failed: %s", PQerrorMessage(sql)); Close(); return false; } @@ -710,7 +710,7 @@ bool SQLConn::DoConnect() if(PQsetnonblocking(sql, 1) == -1) { - log(DEBUG, "Couldn't set connection nonblocking: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "Couldn't set connection nonblocking: %s", PQerrorMessage(sql)); Close(); return false; } @@ -719,13 +719,13 @@ bool SQLConn::DoConnect() * and then start polling it. */ - log(DEBUG, "Old DNS socket: %d", this->fd); + //log(DEBUG, "Old DNS socket: %d", this->fd); this->fd = PQsocket(sql); - log(DEBUG, "New SQL socket: %d", this->fd); + ilog(Instance,DEBUG, "New SQL socket: %d", this->fd); if(this->fd <= -1) { - log(DEBUG, "PQsocket says we have an invalid FD: %d", this->fd); + ilog(Instance,DEBUG, "PQsocket says we have an invalid FD: %d", this->fd); Close(); return false; } @@ -733,7 +733,7 @@ bool SQLConn::DoConnect() this->state = I_CONNECTING; if (!this->Instance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) { - log(DEBUG, "A PQsocket cant be added to the socket engine!"); + ilog(Instance,DEBUG, "A PQsocket cant be added to the socket engine!"); Close(); return false; } @@ -746,7 +746,7 @@ bool SQLConn::DoConnect() void SQLConn::Close() { - log(DEBUG,"SQLConn::Close"); + ilog(Instance,DEBUG,"SQLConn::Close"); if(this->fd > 01) Instance->socket_ref[this->fd] = NULL; @@ -769,23 +769,23 @@ bool SQLConn::DoPoll() switch(PQconnectPoll(sql)) { case PGRES_POLLING_WRITING: - log(DEBUG, "PGconnectPoll: PGRES_POLLING_WRITING"); + //log(DEBUG, "PGconnectPoll: PGRES_POLLING_WRITING"); WantWrite(); status = CWRITE; return DoPoll(); case PGRES_POLLING_READING: - log(DEBUG, "PGconnectPoll: PGRES_POLLING_READING"); + //log(DEBUG, "PGconnectPoll: PGRES_POLLING_READING"); status = CREAD; return true; case PGRES_POLLING_FAILED: - log(DEBUG, "PGconnectPoll: PGRES_POLLING_FAILED: %s", PQerrorMessage(sql)); + //log(DEBUG, "PGconnectPoll: PGRES_POLLING_FAILED: %s", PQerrorMessage(sql)); return false; case PGRES_POLLING_OK: - log(DEBUG, "PGconnectPoll: PGRES_POLLING_OK"); + //log(DEBUG, "PGconnectPoll: PGRES_POLLING_OK"); status = WWRITE; return DoConnectedPoll(); default: - log(DEBUG, "PGconnectPoll: wtf?"); + //log(DEBUG, "PGconnectPoll: wtf?"); return true; } } @@ -801,7 +801,7 @@ bool SQLConn::DoConnectedPoll() if(PQconsumeInput(sql)) { - log(DEBUG, "PQconsumeInput succeeded"); + ilog(Instance,DEBUG, "PQconsumeInput succeeded"); /* We just read stuff from the server, that counts as it being alive * so update the idle-since time :p @@ -810,16 +810,16 @@ bool SQLConn::DoConnectedPoll() if(PQisBusy(sql)) { - log(DEBUG, "Still busy processing command though"); + //log(DEBUG, "Still busy processing command though"); } else if(qinprog) { - log(DEBUG, "Looks like we have a result to process!"); + //log(DEBUG, "Looks like we have a result to process!"); /* Grab the request we're processing */ SQLrequest& query = queue.front(); - log(DEBUG, "ID is %lu", query.id); + ilog(Instance,DEBUG, "ID is %lu", query.id); /* Get a pointer to the module we're about to return the result to */ Module* to = query.GetSource(); @@ -844,7 +844,7 @@ bool SQLConn::DoConnectedPoll() /* ..and the result */ PgSQLresult reply(us, to, query.id, result); - log(DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result)); + ilog(Instance,DEBUG, "Got result, status code: %s; error message: %s", PQresStatus(PQresultStatus(result)), PQresultErrorMessage(result)); switch(PQresultStatus(result)) { @@ -867,7 +867,7 @@ bool SQLConn::DoConnectedPoll() * the pointer to NULL. We cannot just cancel the query as the result will still come * through at some point...and it could get messy if we play with invalid pointers... */ - log(DEBUG, "Looks like we're handling a zombie query from a module which unloaded before it got a result..fun. ID: %lu", query.id); + ilog(Instance,DEBUG, "Looks like we're handling a zombie query from a module which unloaded before it got a result..fun. ID: %lu", query.id); PQclear(result); } @@ -877,7 +877,7 @@ bool SQLConn::DoConnectedPoll() } else { - log(DEBUG, "Eh!? We just got a read event, and connection isn't busy..but no result :("); + ilog(Instance,DEBUG, "Eh!? We just got a read event, and connection isn't busy..but no result :("); } return true; @@ -889,7 +889,7 @@ bool SQLConn::DoConnectedPoll() * deserves to reconnect [/excuse] * Returning true so the core doesn't try and close the connection. */ - log(DEBUG, "PQconsumeInput failed: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "PQconsumeInput failed: %s", PQerrorMessage(sql)); Reconnect(); return true; } @@ -900,23 +900,23 @@ bool SQLConn::DoResetPoll() switch(PQresetPoll(sql)) { case PGRES_POLLING_WRITING: - log(DEBUG, "PGresetPoll: PGRES_POLLING_WRITING"); + //log(DEBUG, "PGresetPoll: PGRES_POLLING_WRITING"); WantWrite(); status = CWRITE; return DoPoll(); case PGRES_POLLING_READING: - log(DEBUG, "PGresetPoll: PGRES_POLLING_READING"); + //log(DEBUG, "PGresetPoll: PGRES_POLLING_READING"); status = CREAD; return true; case PGRES_POLLING_FAILED: - log(DEBUG, "PGresetPoll: PGRES_POLLING_FAILED: %s", PQerrorMessage(sql)); + //log(DEBUG, "PGresetPoll: PGRES_POLLING_FAILED: %s", PQerrorMessage(sql)); return false; case PGRES_POLLING_OK: - log(DEBUG, "PGresetPoll: PGRES_POLLING_OK"); + //log(DEBUG, "PGresetPoll: PGRES_POLLING_OK"); status = WWRITE; return DoConnectedPoll(); default: - log(DEBUG, "PGresetPoll: wtf?"); + //log(DEBUG, "PGresetPoll: wtf?"); return true; } } @@ -926,38 +926,38 @@ void SQLConn::ShowStatus() switch(PQstatus(sql)) { case CONNECTION_STARTED: - log(DEBUG, "PQstatus: CONNECTION_STARTED: Waiting for connection to be made."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_STARTED: Waiting for connection to be made."); break; case CONNECTION_MADE: - log(DEBUG, "PQstatus: CONNECTION_MADE: Connection OK; waiting to send."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_MADE: Connection OK; waiting to send."); break; case CONNECTION_AWAITING_RESPONSE: - log(DEBUG, "PQstatus: CONNECTION_AWAITING_RESPONSE: Waiting for a response from the server."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_AWAITING_RESPONSE: Waiting for a response from the server."); break; case CONNECTION_AUTH_OK: - log(DEBUG, "PQstatus: CONNECTION_AUTH_OK: Received authentication; waiting for backend start-up to finish."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_AUTH_OK: Received authentication; waiting for backend start-up to finish."); break; case CONNECTION_SSL_STARTUP: - log(DEBUG, "PQstatus: CONNECTION_SSL_STARTUP: Negotiating SSL encryption."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_SSL_STARTUP: Negotiating SSL encryption."); break; case CONNECTION_SETENV: - log(DEBUG, "PQstatus: CONNECTION_SETENV: Negotiating environment-driven parameter settings."); + ilog(Instance,DEBUG, "PQstatus: CONNECTION_SETENV: Negotiating environment-driven parameter settings."); break; default: - log(DEBUG, "PQstatus: ???"); + ilog(Instance,DEBUG, "PQstatus: ???"); } } bool SQLConn::OnDataReady() { /* Always return true here, false would close the socket - we need to do that ourselves with the pgsql API */ - log(DEBUG, "OnDataReady(): status = %s", StatusStr()); + ilog(Instance,DEBUG, "OnDataReady(): status = %s", StatusStr()); return DoEvent(); } @@ -965,21 +965,21 @@ bool SQLConn::OnDataReady() bool SQLConn::OnWriteReady() { /* Always return true here, false would close the socket - we need to do that ourselves with the pgsql API */ - log(DEBUG, "OnWriteReady(): status = %s", StatusStr()); + ilog(Instance,DEBUG, "OnWriteReady(): status = %s", StatusStr()); return DoEvent(); } bool SQLConn::OnConnected() { - log(DEBUG, "OnConnected(): status = %s", StatusStr()); + ilog(Instance,DEBUG, "OnConnected(): status = %s", StatusStr()); return DoEvent(); } bool SQLConn::Reconnect() { - log(DEBUG, "Initiating reconnect"); + ilog(Instance,DEBUG, "Initiating reconnect"); if(PQresetStart(sql)) { @@ -992,7 +992,7 @@ bool SQLConn::Reconnect() } else { - log(DEBUG, "Failed to initiate reconnect...fun"); + ilog(Instance,DEBUG, "Failed to initiate reconnect...fun"); return false; } } @@ -1017,13 +1017,13 @@ bool SQLConn::DoEvent() switch(PQflush(sql)) { case -1: - log(DEBUG, "Error flushing write queue: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "Error flushing write queue: %s", PQerrorMessage(sql)); break; case 0: - log(DEBUG, "Successfully flushed write queue (or there was nothing to write)"); + ilog(Instance,DEBUG, "Successfully flushed write queue (or there was nothing to write)"); break; case 1: - log(DEBUG, "Not all of the write queue written, triggering write event so we can have another go"); + ilog(Instance,DEBUG, "Not all of the write queue written, triggering write event so we can have another go"); WantWrite(); break; } @@ -1124,10 +1124,10 @@ SQLerror SQLConn::DoQuery(SQLrequest &req) #endif if(error) { - log(DEBUG, "Apparently PQescapeStringConn() failed somehow...don't know how or what to do..."); + ilog(Instance,DEBUG, "Apparently PQescapeStringConn() failed somehow...don't know how or what to do..."); } - log(DEBUG, "Appended %d bytes of escaped string onto the query", len); + ilog(Instance,DEBUG, "Appended %d bytes of escaped string onto the query", len); /* Incremenet queryend to the end of the newly escaped parameter */ queryend += len; @@ -1137,7 +1137,7 @@ SQLerror SQLConn::DoQuery(SQLrequest &req) } else { - log(DEBUG, "Found a substitution location but no parameter to substitute :|"); + ilog(Instance,DEBUG, "Found a substitution location but no parameter to substitute :|"); break; } } @@ -1151,27 +1151,27 @@ SQLerror SQLConn::DoQuery(SQLrequest &req) /* Null-terminate the query */ *queryend = 0; - log(DEBUG, "Attempting to dispatch query: %s", query); + ilog(Instance,DEBUG, "Attempting to dispatch query: %s", query); req.query.q = query; if(PQsendQuery(sql, query)) { - log(DEBUG, "Dispatched query successfully"); + ilog(Instance,DEBUG, "Dispatched query successfully"); qinprog = true; DELETE(query); return SQLerror(); } else { - log(DEBUG, "Failed to dispatch query: %s", PQerrorMessage(sql)); + ilog(Instance,DEBUG, "Failed to dispatch query: %s", PQerrorMessage(sql)); DELETE(query); return SQLerror(QSEND_FAIL, PQerrorMessage(sql)); } } } - log(DEBUG, "Can't query until connection is complete"); + ilog(Instance,DEBUG, "Can't query until connection is complete"); return SQLerror(BAD_CONN, "Can't query until connection is complete"); } diff --git a/src/modules/extra/m_sqllog.cpp b/src/modules/extra/m_sqllog.cpp index 4779e3cb2..4db8fe6f0 100644 --- a/src/modules/extra/m_sqllog.cpp +++ b/src/modules/extra/m_sqllog.cpp @@ -66,8 +66,6 @@ class QueryInfo // Nothing here and not sent yet SQLrequest req = SQLreq(MyMod, SQLModule, dbid, "", ""); - log(DEBUG,"State: %d",qs); - switch (qs) { case FIND_SOURCE: @@ -99,7 +97,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; } @@ -116,7 +114,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; @@ -148,7 +146,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; } @@ -164,7 +162,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; case FIND_HOST: @@ -196,7 +194,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; } @@ -213,7 +211,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } break; case INSERT_LOGENTRY: @@ -239,7 +237,7 @@ class QueryInfo } else { - log(DEBUG, "SQLrequest failed: %s", req.error.Str()); + //log(DEBUG, "SQLrequest failed: %s", req.error.Str()); } } break; diff --git a/src/modules/extra/m_sqlv2.h b/src/modules/extra/m_sqlv2.h index fbacb99f7..bce437858 100644 --- a/src/modules/extra/m_sqlv2.h +++ b/src/modules/extra/m_sqlv2.h @@ -149,7 +149,6 @@ public: SQLquery(const std::string &query) : q(query) { - log(DEBUG, "SQLquery constructor: %s", q.c_str()); } /** Initialize an SQLquery with a format string and parameters. @@ -159,7 +158,6 @@ public: SQLquery(const std::string &query, const ParamL ¶ms) : q(query), p(params) { - log(DEBUG, "SQLquery constructor with %d params: %s", p.size(), q.c_str()); } /** An overloaded operator for pushing parameters onto the parameter list diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 6e5ddd514..761ea2d9c 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -51,7 +51,7 @@ class HttpSocket : public InspSocket HttpSocket(InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, FileReader* index_page) : InspSocket(SI, host, port, listening, maxtime), index(index_page) { - log(DEBUG,"HttpSocket constructor"); + ilog(SI,DEBUG,"HttpSocket constructor"); InternalState = HTTP_LISTEN; } @@ -225,7 +225,7 @@ class HttpSocket : public InspSocket if (!claimed) { SendHeaders(0, 404, ""); - log(DEBUG,"Page not claimed, 404"); + ilog(Instance,DEBUG,"Page not claimed, 404"); } } } @@ -245,7 +245,7 @@ class HttpSocket : public InspSocket void Page(std::stringstream* n, int response, std::string& extraheaders) { - log(DEBUG,"Sending page"); + ilog(Instance,DEBUG,"Sending page"); SendHeaders(n->str().length(), response, extraheaders); this->Write(n->str()); } diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 47266469d..d88778242 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -47,7 +47,6 @@ class RFC1413 : public InspSocket RFC1413(InspIRCd* SI, userrec* user, int maxtime) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), u(user), ufd(user->fd) { - log(DEBUG,"Ident: associated."); } virtual void OnTimeout() @@ -90,7 +89,7 @@ class RFC1413 : public InspSocket if (this->Instance->IsIdent(section)) { strlcpy(u->ident,section,IDENTMAX); - log(DEBUG,"IDENT SET: "+std::string(u->ident)); + ilog(Instance,DEBUG,"IDENT SET: "+std::string(u->ident)); u->WriteServ("NOTICE "+std::string(u->nick)+" :*** Found your ident: "+std::string(u->ident)); } } @@ -148,7 +147,7 @@ class RFC1413 : public InspSocket themlen = sizeof(sock_them); if ((getsockname(this->u->fd,(sockaddr*)&sock_us,&uslen) || getpeername(this->u->fd, (sockaddr*)&sock_them, &themlen))) { - log(DEBUG,"Ident: failed to get socket names, bailing"); + ilog(Instance,DEBUG,"Ident: failed to get socket names, bailing"); return false; } else @@ -160,7 +159,7 @@ class RFC1413 : public InspSocket snprintf(ident_request,127,"%d,%d\r\n",ntohs(sock_them.sin_port),ntohs(sock_us.sin_port)); #endif this->Write(ident_request); - log(DEBUG,"Sent ident request, waiting for reply"); + ilog(Instance,DEBUG,"Sent ident request, waiting for reply"); return true; } } diff --git a/src/modules/m_joinflood.cpp b/src/modules/m_joinflood.cpp index 34d39c8b6..9a49cf6b1 100644 --- a/src/modules/m_joinflood.cpp +++ b/src/modules/m_joinflood.cpp @@ -46,16 +46,13 @@ class joinfloodsettings : public classbase reset = time(NULL) + secs; counter = 0; locked = false; - log(DEBUG,"Create new joinfloodsettings: %lu %lu",time(NULL),reset); }; void addjoin() { counter++; - log(DEBUG,"joinflood counter is %d",counter); if (time(NULL) > reset) { - log(DEBUG,"joinflood counter reset"); counter = 0; reset = time(NULL) + secs; } @@ -68,7 +65,6 @@ class joinfloodsettings : public classbase void clear() { - log(DEBUG,"joinflood counter clear"); counter = 0; } @@ -91,7 +87,6 @@ class joinfloodsettings : public classbase void lock() { - log(DEBUG,"joinflood lock"); locked = true; unlocktime = time(NULL) + 60; } diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 776e1a16d..0f2bb23c6 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -41,7 +41,6 @@ class floodsettings : public classbase floodsettings(bool a, int b, int c) : ban(a), secs(b), lines(c) { reset = time(NULL) + secs; - log(DEBUG,"Create new floodsettings: %lu %lu",time(NULL),reset); }; void addmessage(userrec* who) @@ -50,16 +49,13 @@ class floodsettings : public classbase if (iter != counters.end()) { iter->second++; - log(DEBUG,"Count for %s is now %d",who->nick,iter->second); } else { counters[who] = 1; - log(DEBUG,"Count for %s is now *1*",who->nick); } if (time(NULL) > reset) { - log(DEBUG,"floodsettings timer Resetting."); counters.clear(); reset = time(NULL) + secs; } @@ -70,7 +66,6 @@ class floodsettings : public classbase std::map::iterator iter = counters.find(who); if (iter != counters.end()) { - log(DEBUG,"should kick? %d, %d",iter->second,this->lines); return (iter->second >= this->lines); } else return false; diff --git a/src/modules/m_operlevels.cpp b/src/modules/m_operlevels.cpp index a8f45d6f9..ba0235f6a 100644 --- a/src/modules/m_operlevels.cpp +++ b/src/modules/m_operlevels.cpp @@ -100,7 +100,6 @@ class ModuleOperLevelsFactory : public ModuleFactory virtual Module * CreateModule(InspIRCd* Me) { - log(DEBUG,"CreateModule"); return new ModuleOperLevels(Me); } diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 57c1ce406..ab0d62761 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -2187,23 +2187,23 @@ class TreeSocket : public InspSocket switch (*(params[0].c_str())) { case 'Z': - propogate = add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); + propogate = ServerInstance->XLines->add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + ServerInstance->XLines->zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'Q': - propogate = add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); + propogate = ServerInstance->XLines->add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + ServerInstance->XLines->qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'E': - propogate = add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - eline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); + propogate = ServerInstance->XLines->add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + ServerInstance->XLines->eline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'G': - propogate = add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); - gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); + propogate = ServerInstance->XLines->add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + ServerInstance->XLines->gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str())); break; case 'K': - propogate = add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); + propogate = ServerInstance->XLines->add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str()); break; default: /* Just in case... */ @@ -2229,7 +2229,7 @@ class TreeSocket : public InspSocket if (!this->bursting) { log(DEBUG,"Applying lines..."); - apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); + ServerInstance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); } return true; } @@ -2811,7 +2811,7 @@ class TreeSocket : public InspSocket if (this->bursting) { this->bursting = false; - apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); + ServerInstance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); } if (prefix == "") { @@ -2829,7 +2829,7 @@ class TreeSocket : public InspSocket if (this->bursting) { this->bursting = false; - apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); + ServerInstance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); } if (prefix == "") { @@ -2912,7 +2912,7 @@ class TreeSocket : public InspSocket else if (command == "ENDBURST") { this->bursting = false; - apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); + ServerInstance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES); std::string sourceserv = this->myhost; if (this->InboundServerName != "") { diff --git a/src/socket.cpp b/src/socket.cpp index 0509f4bf3..aa6f7a2bc 100644 --- a/src/socket.cpp +++ b/src/socket.cpp @@ -234,7 +234,7 @@ bool InspIRCd::BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server if ((*addr) && (insp_aton(addr,&addy) < 1)) { - log(DEBUG,"Invalid IP '%s' given to BindSocket()", addr); + ilog(this,DEBUG,"Invalid IP '%s' given to BindSocket()", addr); return false;; } @@ -270,10 +270,10 @@ bool InspIRCd::BindSocket(int sockfd, insp_sockaddr client, insp_sockaddr server } else { - log(DEBUG,"Bound port %s:%d",*addr ? addr : "*",port); + ilog(this,DEBUG,"Bound port %s:%d",*addr ? addr : "*",port); if (listen(sockfd, Config->MaxConn) == -1) { - log(DEFAULT,"ERROR in listen(): %s",strerror(errno)); + ilog(this,DEFAULT,"ERROR in listen(): %s",strerror(errno)); return false; } else @@ -294,8 +294,7 @@ int irc::sockets::OpenTCPSocket() if ((sockfd = socket (AF_FAMILY, SOCK_STREAM, 0)) < 0) { - log(DEFAULT,"Error creating TCP socket: %s",strerror(errno)); - return (ERROR); + return ERROR; } else { @@ -332,7 +331,7 @@ int InspIRCd::BindPorts(bool bail) if (!bail) { int InitialPortCount = stats->BoundPortCount; - log(DEBUG,"Initial port count: %d",InitialPortCount); + ilog(this,DEBUG,"Initial port count: %d",InitialPortCount); for (int count = 0; count < Config->ConfValueEnum(Config->config_data, "bind"); count++) { @@ -349,7 +348,7 @@ int InspIRCd::BindPorts(bool bail) strlcpy(Config->addrs[clientportcount+InitialPortCount],Addr,256); clientportcount++; - log(DEBUG,"NEW binding %s:%s [%s] from config",Addr,configToken, Type); + ilog(this,DEBUG,"NEW binding %s:%s [%s] from config",Addr,configToken, Type); } } int PortCount = clientportcount; @@ -359,13 +358,13 @@ int InspIRCd::BindPorts(bool bail) { if ((Config->openSockfd[count] = OpenTCPSocket()) == ERROR) { - log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[count],Config->addrs[count],Config->ports[count]); + ilog(this,DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[count],Config->addrs[count],Config->ports[count]); } else { if (!BindSocket(Config->openSockfd[count],client,server,Config->ports[count],Config->addrs[count])) { - log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); + ilog(this,DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); } else { @@ -374,7 +373,7 @@ int InspIRCd::BindPorts(bool bail) { if (!SE->AddFd(Config->openSockfd[count],true,X_LISTEN)) { - log(DEFAULT,"ERK! Failed to add listening port to socket engine!"); + ilog(this,DEFAULT,"ERK! Failed to add listening port to socket engine!"); shutdown(Config->openSockfd[count],2); close(Config->openSockfd[count]); } @@ -388,7 +387,7 @@ int InspIRCd::BindPorts(bool bail) } else { - log(DEBUG,"There is nothing new to bind!"); + ilog(this,DEBUG,"There is nothing new to bind!"); } return InitialPortCount; } @@ -413,7 +412,7 @@ int InspIRCd::BindPorts(bool bail) strlcpy(Config->addrs[clientportcount],Addr,256); clientportcount++; - log(DEBUG,"Binding %s:%s [%s] from config",Addr,configToken, Type); + ilog(this,DEBUG,"Binding %s:%s [%s] from config",Addr,configToken, Type); } } @@ -423,13 +422,13 @@ int InspIRCd::BindPorts(bool bail) { if ((Config->openSockfd[BoundPortCount] = OpenTCPSocket()) == ERROR) { - log(DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]); + ilog(this,DEBUG,"Bad fd %d binding port [%s:%d]",Config->openSockfd[BoundPortCount],Config->addrs[count],Config->ports[count]); } else { if (!BindSocket(Config->openSockfd[BoundPortCount],client,server,Config->ports[count],Config->addrs[count])) { - log(DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); + ilog(this,DEFAULT,"Failed to bind port [%s:%d]: %s",Config->addrs[count],Config->ports[count],strerror(errno)); } else { diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 2e4814b36..834fe9e0b 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -29,14 +29,14 @@ #include #include "socketengine.h" #include "helperfuncs.h" +#include "inspircd.h" -SocketEngine::SocketEngine() +SocketEngine::SocketEngine(InspIRCd* Instance) : ServerInstance(Instance) { } SocketEngine::~SocketEngine() { - log(DEBUG,"SocketEngine::~SocketEngine()"); } char SocketEngine::GetType(int fd) diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp index 05513290b..8e1f72bc7 100644 --- a/src/socketengine_epoll.cpp +++ b/src/socketengine_epoll.cpp @@ -22,8 +22,9 @@ #include #include "socketengine_epoll.h" #include "helperfuncs.h" +#include "inspircd.h" -EPollEngine::EPollEngine() +EPollEngine::EPollEngine(InspIRCd* Instance) : SocketEngine(Instance) { EngineHandle = epoll_create(MAX_DESCRIPTORS); diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp index 3287ea780..5c6519339 100644 --- a/src/socketengine_kqueue.cpp +++ b/src/socketengine_kqueue.cpp @@ -25,7 +25,7 @@ #include "socketengine_kqueue.h" #include "helperfuncs.h" -KQueueEngine::KQueueEngine() +KQueueEngine::KQueueEngine(InspIRCd* Instance) : SocketEngine(Instance) { EngineHandle = kqueue(); if (EngineHandle == -1) diff --git a/src/socketengine_select.cpp b/src/socketengine_select.cpp index a57da4a31..4f10fa85f 100644 --- a/src/socketengine_select.cpp +++ b/src/socketengine_select.cpp @@ -23,7 +23,7 @@ #include "socketengine_select.h" #include "helperfuncs.h" -SelectEngine::SelectEngine() +SelectEngine::SelectEngine(InspIRCd* Instance) : SocketEngine(Instance) { log(DEBUG,"SelectEngine::SelectEngine()"); EngineHandle = 0; diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 2a4f57b93..fb362fe45 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -58,7 +58,7 @@ void InspIRCd::ProcessUser(userrec* cu) if (cu->fd == FD_MAGIC_NUMBER) return; - log(DEBUG,"Processing user with fd %d",cu->fd); + ilog(this,DEBUG,"Processing user with fd %d",cu->fd); if (this->Config->GetIOHook(cu->GetPort())) { @@ -68,11 +68,11 @@ void InspIRCd::ProcessUser(userrec* cu) try { MOD_RESULT = this->Config->GetIOHook(cu->GetPort())->OnRawSocketRead(cu->fd,ReadBuffer,sizeof(ReadBuffer),result2); - log(DEBUG,"Data result returned by module: %d",MOD_RESULT); + ilog(this,DEBUG,"Data result returned by module: %d",MOD_RESULT); } catch (ModuleException& modexcept) { - log(DEBUG,"Module exception caught: %s",modexcept.GetReason()); + ilog(this,DEBUG,"Module exception caught: %s",modexcept.GetReason()); } if (MOD_RESULT < 0) @@ -89,7 +89,7 @@ void InspIRCd::ProcessUser(userrec* cu) result = cu->ReadData(ReadBuffer, sizeof(ReadBuffer)); } - log(DEBUG,"Read result: %d",result); + ilog(this,DEBUG,"Read result: %d",result); if ((result) && (result != -EAGAIN)) { @@ -136,7 +136,7 @@ void InspIRCd::ProcessUser(userrec* cu) if (current->lines_in > current->flood) { - log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); + ilog(this,DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); this->WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); userrec::QuitUser(this, current,"Excess flood"); return; @@ -150,7 +150,7 @@ void InspIRCd::ProcessUser(userrec* cu) else { this->WriteOpers("*** Excess flood from %s",current->GetIPString()); - log(DEFAULT,"Excess flood from: %s",current->GetIPString()); + ilog(this,DEFAULT,"Excess flood from: %s",current->GetIPString()); XLines->add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString()); XLines->apply_lines(APPLY_ZLINES); } @@ -167,7 +167,7 @@ void InspIRCd::ProcessUser(userrec* cu) else { this->WriteOpers("*** Excess flood from %s",current->GetIPString()); - log(DEFAULT,"Excess flood from: %s",current->GetIPString()); + ilog(this,DEFAULT,"Excess flood from: %s",current->GetIPString()); XLines->add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString()); XLines->apply_lines(APPLY_ZLINES); } @@ -186,7 +186,7 @@ void InspIRCd::ProcessUser(userrec* cu) if (++current->lines_in > current->flood) { - log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); + ilog(this,DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); userrec::QuitUser(this, current,"Excess flood"); return; @@ -196,7 +196,7 @@ void InspIRCd::ProcessUser(userrec* cu) { if (current->registered == REG_ALL) { - log(DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); + ilog(this,DEFAULT,"Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); WriteOpers("*** Excess flood from: %s!%s@%s",current->nick,current->ident,current->host); userrec::QuitUser(this, current,"Excess flood"); } @@ -242,7 +242,7 @@ void InspIRCd::ProcessUser(userrec* cu) if ((result == -1) && (errno != EAGAIN) && (errno != EINTR)) { - log(DEBUG,"killing: %s",cu->nick); + ilog(this,DEBUG,"killing: %s",cu->nick); userrec::QuitUser(this,cu,strerror(errno)); return; } @@ -255,9 +255,9 @@ void InspIRCd::ProcessUser(userrec* cu) } else if (result == 0) { - log(DEBUG,"InspIRCd: Exited: %s",cu->nick); + ilog(this,DEBUG,"InspIRCd: Exited: %s",cu->nick); userrec::QuitUser(this,cu,"Client exited"); - log(DEBUG,"Bailing from client exit"); + ilog(this,DEBUG,"Bailing from client exit"); return; } } @@ -272,7 +272,7 @@ void InspIRCd::DoSocketTimeouts(time_t TIME) InspSocket* s = (InspSocket*)*a; if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (this->socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME))) { - log(DEBUG,"userprocess.cpp: Socket poll returned false, close and bail"); + ilog(this,DEBUG,"userprocess.cpp: Socket poll returned false, close and bail"); this->socket_ref[s->GetFd()] = NULL; SE->DelFd(s->GetFd()); this->module_sockets.erase(a); @@ -312,7 +312,7 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME) */ if (((unsigned)TIME > (unsigned)curr->timeout) && (curr->registered != REG_ALL)) { - log(DEBUG,"InspIRCd: registration timeout: %s",curr->nick); + ilog(this,DEBUG,"InspIRCd: registration timeout: %s",curr->nick); //ZapThisDns(curr->fd); GlobalGoners.AddItem(curr,"Registration timeout"); continue; @@ -331,7 +331,7 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME) } if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr))) { - log(DEBUG,"dns done, registered=3, and modules ready, OK"); + ilog(this,DEBUG,"dns done, registered=3, and modules ready, OK"); curr->FullConnect(&GlobalGoners); //ZapThisDns(curr->fd); continue; diff --git a/src/users.cpp b/src/users.cpp index 938557b59..f6adb85cf 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -73,7 +73,7 @@ bool DoType(ServerConfig* conf, const char* tag, char** entries, void** values, char* Classes = (char*)values[1]; opertypes[TypeName] = strdup(Classes); - log(DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes); + ilog(conf->GetInstance(),DEBUG,"Read oper TYPE '%s' with classes '%s'",TypeName,Classes); return true; } @@ -83,7 +83,7 @@ bool DoClass(ServerConfig* conf, const char* tag, char** entries, void** values, char* CommandList = (char*)values[1]; operclass[ClassName] = strdup(CommandList); - log(DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList); + ilog(conf->GetInstance(),DEBUG,"Read oper CLASS '%s' with commands '%s'",ClassName,CommandList); return true; } @@ -676,7 +676,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit } catch (ModuleException& modexcept) { - log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); + ilog(Instance,DEBUG,"Module exception cought: %s",modexcept.GetReason()); } } @@ -701,7 +701,7 @@ void userrec::QuitUser(InspIRCd* Instance, userrec *user,const std::string &quit if (iter != Instance->clientlist.end()) { - log(DEBUG,"deleting user hash value %lx",(unsigned long)user); + ilog(Instance,DEBUG,"deleting user hash value %lx",(unsigned long)user); if (IS_LOCAL(user)) { Instance->fd_ref_table[user->fd] = NULL; @@ -812,7 +812,7 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, Instance->clientlist.erase(iter); } - log(DEBUG,"AddClient: %d %d %s",socket,port,ipaddr); + ilog(Instance,DEBUG,"AddClient: %d %d %s",socket,port,ipaddr); _new = new userrec(Instance); Instance->clientlist[tempnick] = _new; @@ -827,9 +827,9 @@ void userrec::AddClient(InspIRCd* Instance, int socket, int port, bool iscached, _new->signon = Instance->Time() + Instance->Config->dns_timeout; _new->lastping = 1; - log(DEBUG,"Setting socket addresses"); + ilog(Instance,DEBUG,"Setting socket addresses"); _new->SetSockAddr(AF_FAMILY, ipaddr, port); - log(DEBUG,"Socket addresses set."); + ilog(Instance,DEBUG,"Socket addresses set."); /* Smarter than your average bear^H^H^H^Hset of strlcpys. */ for (const char* temp = _new->GetIPString(); *temp && j < 64; temp++, j++) diff --git a/src/xline.cpp b/src/xline.cpp index 99b6fecf9..215a270c5 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -73,7 +73,7 @@ bool DoZLine(ServerConfig* conf, const char* tag, char** entries, void** values, char* ipmask = (char*)values[1]; conf->GetInstance()->XLines->add_zline(0,"",reason,ipmask); - log(DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason); + ilog(conf->GetInstance(),DEBUG,"Read Z line (badip tag): ipmask=%s reason=%s",ipmask,reason); return true; } @@ -83,7 +83,7 @@ bool DoQLine(ServerConfig* conf, const char* tag, char** entries, void** values, char* nick = (char*)values[1]; conf->GetInstance()->XLines->add_qline(0,"",reason,nick); - log(DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason); + ilog(conf->GetInstance(),DEBUG,"Read Q line (badnick tag): nick=%s reason=%s",nick,reason); return true; } @@ -93,7 +93,7 @@ bool DoKLine(ServerConfig* conf, const char* tag, char** entries, void** values, char* host = (char*)values[1]; conf->GetInstance()->XLines->add_kline(0,"",reason,host); - log(DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason); + ilog(conf->GetInstance(),DEBUG,"Read K line (badhost tag): host=%s reason=%s",host,reason); return true; } @@ -103,7 +103,7 @@ bool DoELine(ServerConfig* conf, const char* tag, char** entries, void** values, char* host = (char*)values[1]; conf->GetInstance()->XLines->add_eline(0,"",reason,host); - log(DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason); + ilog(conf->GetInstance(),DEBUG,"Read E line (exception tag): host=%s reason=%s",host,reason); return true; } -- 2.39.5