// by an integer, meaning there is no need for a scan/search operation.
userrec* fd_ref_table[65536];
+int statsAccept = 0, statsRefused = 0, statsUnknown = 0, statsCollisions = 0, statsDns = 0, statsDnsGood = 0, statsDnsBad = 0, statsConnects = 0, statsSent= 0, statsRecv = 0;
+
serverrec* me[32];
FILE *log_file;
std::vector<userrec*> all_opers;
+static char already_sent[65536];
+
void AddOper(userrec* user)
{
log(DEBUG,"Oper added to optimization list");
fd_ref_table[sock]->bytes_out += (bytes > 512 ? 512 : bytes);
fd_ref_table[sock]->cmds_out++;
}
+ statsSent += (bytes > 512 ? 512 : bytes);
}
}
fd_ref_table[sock]->bytes_out += (bytes > 512 ? 512 : bytes);
fd_ref_table[sock]->cmds_out++;
}
+ statsSent += (bytes > 512 ? 512 : bytes);
}
}
fd_ref_table[sock]->bytes_out += (bytes > 512 ? 512 : bytes);
fd_ref_table[sock]->cmds_out++;
}
+ statsSent += (bytes > 512 ? 512 : bytes);
}
}
va_end(argsPtr);
// FIX: Stops a message going to the same person more than once
- std::vector<int> already_sent;
+ bzero(&already_sent,65536);
+
+ bool sent_to_at_least_one = false;
for (int i = 0; i < MAXCHANS; i++)
{
{
char* o = (*ulist)[j];
userrec* otheruser = (userrec*)o;
- bool do_send = true;
- for (int t = 0; t < already_sent.size(); t++)
+ if (!already_sent[otheruser->fd])
{
- if (already_sent[t] == otheruser->fd)
- {
- do_send = false;
- break;
- }
- }
- if (do_send)
- {
- already_sent.push_back(otheruser->fd);
+ already_sent[otheruser->fd] = 1;
WriteFrom(otheruser->fd,u,"%s",textbuffer);
+ sent_to_at_least_one = true;
}
}
}
}
// if the user was not in any channels, no users will receive the text. Make sure the user
// receives their OWN message for WriteCommon
- if (!already_sent.size())
+ if (!sent_to_at_least_one)
{
WriteFrom(u->fd,u,"%s",textbuffer);
}
vsnprintf(textbuffer, MAXBUF, text, argsPtr);
va_end(argsPtr);
- std::vector<int> already_sent;
+ bzero(&already_sent,65536);
for (int i = 0; i < MAXCHANS; i++)
{
userrec* otheruser = (userrec*)o;
if (u != otheruser)
{
- bool do_send = true;
- for (int t = 0; t < already_sent.size(); t++)
- {
- if (already_sent[t] == otheruser->fd)
- {
- do_send = false;
- break;
- }
- }
- if (do_send)
+ if (!already_sent[otheruser->fd])
{
- already_sent.push_back(otheruser->fd);
+ already_sent[otheruser->fd] = 1;
WriteFrom(otheruser->fd,u,"%s",textbuffer);
}
}
WholeMOTD = WholeMOTD + std::string(":") + std::string(ServerName) + std::string(" 376 ") + std::string(user->nick) + std::string(" :End of message of the day.\r\n");
// only one write operation
send(user->fd,WholeMOTD.c_str(),WholeMOTD.length(),0);
-
+ statsSent += WholeMOTD.length();
}
void ShowRULES(userrec *user)
/* shows the message of the day, and any other on-logon stuff */
void FullConnectUser(userrec* user)
{
+ statsConnects++;
user->registered = 7;
user->idle_lastmsg = TIME;
log(DEBUG,"ConnectUser: %s",user->nick);
FOREACH_RESULT(OnUserPreNick(user,newnick));
if (MOD_RESULT) {
+ statsCollisions++;
kill_link(user,"Nickname collision");
return;
}
if (matches_qline(newnick))
{
+ statsCollisions++;
kill_link(user,"Nickname collision");
return;
}
{
if (strchr("@!\"$%^&*(){}[]_=+;:'#~,<>/?\\|`",command[x]))
{
+ statsUnknown++;
WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
return;
}
}
if ((!cmd_found) && (user))
{
+ statsUnknown++;
WriteServ(user->fd,"421 %s %s :Unknown command",user->nick,command);
}
}
if ((curr) && (curr->fd != 0))
{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+#endif
// assemble up to 64 sockets into an fd_set
// to implement a pooling mechanism.
//
{
log(DEBUG,"signon exceed, registered=3, and modules ready, OK");
curr->dns_done = true;
+ statsDnsBad++;
FullConnectUser(curr);
goto label;
}
}
else result = result2;
log(DEBUG,"Read result: %d",result);
-
if (result)
{
+ statsRecv += result;
// perform a check on the raw buffer as an array (not a string!) to remove
// characters 0 and 7 which are illegal in the RFC - replace them with spaces.
// hopefully this should stop even more people whining about "Unknown command: *"
{
WriteOpers("*** WARNING: Accept failed on port %lu (%s)",(unsigned long)ports[count],target);
log(DEBUG,"InspIRCd: accept failed: %lu",(unsigned long)ports[count]);
+ statsRefused++;
}
else
{
FOREACH_MOD OnRawSocketAccept(incomingSockfd, resolved, ports[count]);
+ statsAccept++;
AddClient(incomingSockfd, resolved, ports[count], false, inet_ntoa (client.sin_addr));
log(DEBUG,"InspIRCd: adding client on port %lu fd=%lu",(unsigned long)ports[count],(unsigned long)incomingSockfd);
}
if (0) {};
#ifdef _POSIX_PRIORITY_SCHEDULING
sched_yield();
+ sched_yield();
#endif
}
/* not reached */