#include <errno.h>
#include <deque>
#include <errno.h>
+#include <unistd.h>
+#include <sched.h>
#include "connection.h"
#include "users.h"
#include "servers.h"
}
}
+void DoSplitEveryone()
+{
+ bool go_again = true;
+ while (go_again)
+ {
+ go_again = false;
+ for (int i = 0; i < 32; i++)
+ {
+ if (me[i] != NULL)
+ {
+ for (vector<ircd_connector>::iterator j = me[i]->connectors.begin(); j != me[i]->connectors.end(); j++)
+ {
+ if (strcasecmp(j->GetServerName().c_str(),ServerName))
+ {
+ j->routes.clear();
+ j->CloseConnection();
+ me[i]->connectors.erase(j);
+ go_again = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ log(DEBUG,"Removed server. Will remove clients...");
+ // iterate through the userlist and remove all users on this server.
+ // because we're dealing with a mesh, we dont have to deal with anything
+ // "down-route" from this server (nice huh)
+ go_again = true;
+ char reason[MAXBUF];
+ while (go_again)
+ {
+ go_again = false;
+ for (user_hash::const_iterator u = clientlist.begin(); u != clientlist.end(); u++)
+ {
+ if (strcasecmp(u->second->server,ServerName))
+ {
+ snprintf(reason,MAXBUF,"%s %s",ServerName,u->second->server);
+ kill_link(u->second,reason);
+ go_again = true;
+ break;
+ }
+ }
+ }
+}
+
+
+
void handle_squit(char **parameters, int pcnt, userrec *user)
{
// send out an squit across the mesh and then clear the server list (for local squit)
+ if (!pcnt)
+ {
+ WriteOpers("SQUIT command issued by %s",user->nick);
+ char buffer[MAXBUF];
+ snprintf(buffer,MAXBUF,"& %s",ServerName);
+ NetSendToAll(buffer);
+ DoSplitEveryone();
+ }
+ else
+ {
+ WriteServ(user->fd,"NOTICE :*** Remote SQUIT not supported yet.");
+ }
}
char islast(const char* s)
{
if (((command[x] < '0') || (command[x]> '9')) && (command[x] != '-'))
{
- if (strchr("@!\"$%^&*(){}[]_-=+;:'#~,.<>/?\\|`",command[x]))
+ if (!strchr("@!\"$%^&*(){}[]_-=+;:'#~,.<>/?\\|`",command[x]))
{
kill_link(user,"Protocol violation (3)");
return;
createcommand("TRACE",handle_trace,'o',0);
createcommand("WHOWAS",handle_whowas,0,1);
createcommand("CONNECT",handle_connect,'o',1);
- createcommand("SQUIT",handle_squit,'o',1);
+ createcommand("SQUIT",handle_squit,'o',0);
createcommand("MODULES",handle_modules,'o',0);
createcommand("LINKS",handle_links,0,0);
createcommand("MAP",handle_map,0,0);
/* main loop, this never returns */
for (;;)
{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+#endif
fd_set sfd;
timeval tval;
// *FIX* Instead of closing sockets in kill_link when they receive the ERROR :blah line, we should queue
// them in a list, then reap the list every second or so.
- if (reap_counter>2500)
+ if (reap_counter>300)
{
if (fd_reap.size() > 0)
{
//if (selectResult2 > 0)
for (user_hash::iterator count2a = xcount; count2a != endingiter; count2a++)
{
+
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+#endif
+
result = EAGAIN;
if ((count2a->second->fd != -1) && (FD_ISSET (count2a->second->fd, &sfd)))
{