std::vector<userrec*> all_opers;
+static char already_sent[65536];
+
void AddOper(userrec* user)
{
log(DEBUG,"Oper added to optimization list");
va_end(argsPtr);
int bytes = snprintf(tb,MAXBUF,"%s\r\n",textbuffer);
chop(tb);
- if (sock != -1)
+ if ((sock != -1) && (sock != FD_MAGIC_NUMBER))
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes > 512 ? 512 : bytes));
va_end(argsPtr);
int bytes = snprintf(tb,MAXBUF,":%s %s\r\n",ServerName,textbuffer);
chop(tb);
- if (sock != -1)
+ if ((sock != -1) && (sock != FD_MAGIC_NUMBER))
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes > 512 ? 512 : bytes));
va_end(argsPtr);
int bytes = snprintf(tb,MAXBUF,":%s!%s@%s %s\r\n",user->nick,user->ident,user->dhost,textbuffer);
chop(tb);
- if (sock != -1)
+ if ((sock != -1) && (sock != FD_MAGIC_NUMBER))
{
int MOD_RESULT = 0;
FOREACH_RESULT(OnRawSocketWrite(sock,tb,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 ((otheruser->fd > 0) && (!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 ((otheruser->fd > 0) && (!already_sent[otheruser->fd]))
{
- already_sent.push_back(otheruser->fd);
+ already_sent[otheruser->fd] = 1;
WriteFrom(otheruser->fd,u,"%s",textbuffer);
}
}
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.
//
}
else result = result2;
log(DEBUG,"Read result: %d",result);
-
if (result)
{
statsRecv += result;
if (0) {};
#ifdef _POSIX_PRIORITY_SCHEDULING
sched_yield();
+ sched_yield();
#endif
}
/* not reached */