ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/send.c
(Generate patch)

Comparing:
ircd-hybrid-7.3/src/send.c (file contents), Revision 1078 by michael, Sun Mar 7 22:55:05 2010 UTC vs.
ircd-hybrid-8/src/send.c (file contents), Revision 1474 by michael, Sun Jul 22 14:44:07 2012 UTC

# Line 27 | Line 27
27   #include "send.h"
28   #include "channel.h"
29   #include "client.h"
30 #include "common.h"
30   #include "dbuf.h"
31   #include "irc_string.h"
32   #include "ircd.h"
34 #include "handlers.h"
33   #include "numeric.h"
34   #include "fdlist.h"
35   #include "s_bsd.h"
36   #include "s_serv.h"
37   #include "sprintf_irc.h"
38 < #include "s_conf.h"
39 < #include "s_log.h"
38 > #include "conf.h"
39 > #include "log.h"
40   #include "memory.h"
41   #include "hook.h"
44 #include "irc_getnameinfo.h"
42   #include "packet.h"
43  
44  
45   struct Callback *iosend_cb = NULL;
49 struct Callback *iosendctrl_cb = NULL;
46   static unsigned int current_serial = 0;
47  
48  
# Line 181 | Line 177 | send_message_remote(struct Client *to, s
177                           from->name, from->username, from->host,
178                           to->from->name);
179  
180 <    sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
180 >    sendto_server(NULL, CAP_TS6, NOCAPS,
181                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
182                    me.id, to->name, me.name, to->name,
183                    to->username, to->host, to->from->name);
184 <    sendto_server(NULL, NULL, NOCAPS, CAP_TS6,
184 >    sendto_server(NULL, NOCAPS, CAP_TS6,
185                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
186                    me.name, to->name, me.name, to->name,
187                    to->username, to->host, to->from->name);
188  
189 <    SetKilled(to);
189 >    AddFlag(to, FLAGS_KILLED);
190  
191      if (IsClient(from))
192        sendto_one(from, form_str(ERR_GHOSTEDCLIENT),
# Line 225 | Line 221 | sendq_unblocked(fde_t *fd, struct Client
221   }
222  
223   /*
228 ** slinkq_unblocked
229 **      Called when a server control socket is ready for writing.
230 */
231 static void
232 slinkq_unblocked(fde_t *fd, struct Client *client_p)
233 {
234  ClearSlinkqBlocked(client_p);
235  send_queued_slink_write(client_p);
236 }
237
238 /*
224   ** send_queued_write
225   **      This is called when there is a chance that some output would
226   **      be possible. This attempts to empty the send queue as far as
# Line 313 | Line 298 | send_queued_write(struct Client *to)
298    }
299   }
300  
316 /*
317 ** send_queued_slink_write
318 **      This is called when there is a chance the some output would
319 **      be possible. This attempts to empty the send queue as far as
320 **      possible, and then if any data is left, a write is rescheduled.
321 */
322 void
323 send_queued_slink_write(struct Client *to)
324 {
325  int retlen;
326
327  /*
328   ** Once socket is marked dead, we cannot start writing to it,
329   ** even if the error is removed...
330   */
331  if (IsDead(to) || IsSlinkqBlocked(to))
332    return;  /* no use calling send() now */
333
334  /* Next, lets try to write some data */
335  if (to->localClient->slinkq != NULL)
336  {
337    retlen = send(to->localClient->ctrlfd.fd,
338                   to->localClient->slinkq + to->localClient->slinkq_ofs,
339                   to->localClient->slinkq_len, 0);
340    if (retlen < 0)
341    {
342      /* If we have a fatal error */
343      if (!ignoreErrno(errno))
344      {
345        dead_link_on_write(to, errno);
346        return;
347      }
348    }
349    else if (retlen == 0)
350    {
351      /* 0 bytes is an EOF .. */
352      dead_link_on_write(to, 0);
353      return;
354    }
355    else
356    {
357      execute_callback(iosendctrl_cb, to, retlen,
358        to->localClient->slinkq + to->localClient->slinkq_ofs);
359      to->localClient->slinkq_len -= retlen;
360
361      assert(to->localClient->slinkq_len >= 0);
362      if (to->localClient->slinkq_len)
363        to->localClient->slinkq_ofs += retlen;
364      else
365      {
366        to->localClient->slinkq_ofs = 0;
367        MyFree(to->localClient->slinkq);
368        to->localClient->slinkq = NULL;
369      }
370    }
371
372    /* Finally, if we have any more data, reschedule a write */
373    if (to->localClient->slinkq_len)
374    {
375      SetSlinkqBlocked(to);
376      comm_setselect(&to->localClient->ctrlfd, COMM_SELECT_WRITE,
377                     (PF *)slinkq_unblocked, (void *)to, 0);
378    }
379  }
380 }
381
301   /* send_queued_all()
302   *
303   * input        - NONE
# Line 492 | Line 411 | sendto_channel_butone(struct Client *one
411  
412      assert(IsClient(target_p));
413  
414 <    if (IsDefunct(target_p) || IsDeaf(target_p) || target_p->from == one)
414 >    if (IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF) || target_p->from == one)
415        continue;
416  
417      if (MyConnect(target_p))
# Line 539 | Line 458 | sendto_channel_butone(struct Client *one
458   * -davidt
459   */
460   void
461 < sendto_server(struct Client *one, const struct Channel *chptr,
461 > sendto_server(struct Client *one,
462                const unsigned int caps,
463                const unsigned int nocaps,
464                const char *format, ...)
# Line 549 | Line 468 | sendto_server(struct Client *one, const
468    char buffer[IRCD_BUFSIZE];
469    int len = 0;
470  
552  if (chptr && chptr->chname[0] != '#')
553    return;
554
471    va_start(args, format);
472    len = send_format(buffer, IRCD_BUFSIZE, format, args);
473    va_end(args);
# Line 664 | Line 580 | sendto_channel_local(int type, int nodea
580        continue;
581  
582      if (!MyConnect(target_p) || IsDefunct(target_p) ||
583 <        (nodeaf && IsDeaf(target_p)))
583 >        (nodeaf && HasUMode(target_p, UMODE_DEAF)))
584        continue;
585  
586      send_message(target_p, buffer, len);
# Line 707 | Line 623 | sendto_channel_local_butone(struct Clien
623        continue;
624  
625      if (!MyConnect(target_p) || target_p == one ||
626 <        IsDefunct(target_p) || IsDeaf(target_p))
626 >        IsDefunct(target_p) || HasUMode(target_p, UMODE_DEAF))
627        continue;
628      send_message(target_p, buffer, len);
629    }
# Line 986 | Line 902 | sendto_realops_flags(unsigned int flags,
902    DLINK_FOREACH(ptr, oper_list.head)
903    {
904      struct Client *client_p = ptr->data;
905 <    assert(client_p->umodes & UMODE_OPER);
905 >    assert(HasUMode(client_p, UMODE_OPER));
906  
907      /* If we're sending it to opers and theyre an admin, skip.
908       * If we're sending it to admins, and theyre not, skip.
909       */
910 <    if (((level == L_ADMIN) && !IsAdmin(client_p)) ||
911 <        ((level == L_OPER) && IsAdmin(client_p)))
910 >    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
911 >        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
912        continue;
913  
914 <    if (client_p->umodes & flags)
914 >    if (HasUMode(client_p, flags))
915        sendto_one(client_p, ":%s NOTICE %s :*** Notice -- %s",
916                   me.name, client_p->name, nbuf);
917    }
918   }
919  
920 + void
921 + sendto_globops_flags(unsigned int flags, int level, const char *pattern, ...)
922 + {
923 +  dlink_node *ptr = NULL;
924 +  char nbuf[IRCD_BUFSIZE];
925 +  va_list args;
926 +
927 +  va_start(args, pattern);
928 +  vsnprintf(nbuf, IRCD_BUFSIZE, pattern, args);
929 +  va_end(args);
930 +
931 +  DLINK_FOREACH(ptr, oper_list.head)
932 +  {
933 +    struct Client *client_p = ptr->data;
934 +    assert(client_p->umodes & UMODE_OPER);
935 +
936 +    /* If we're sending it to opers and theyre an admin, skip.
937 +     * If we're sending it to admins, and theyre not, skip.
938 +     */
939 +    if (((level == L_ADMIN) && !HasUMode(client_p, UMODE_ADMIN)) ||
940 +        ((level == L_OPER) && HasUMode(client_p, UMODE_ADMIN)))
941 +      continue;
942 +
943 +    if (HasUMode(client_p, flags))
944 +      sendto_one(client_p, ":%s NOTICE %s :*** Global -- %s",
945 +                 me.name, client_p->name, nbuf);
946 +  }
947 + }
948 +
949   /* sendto_wallops_flags()
950   *
951   * inputs       - flag types of messages to show to real opers
# Line 1033 | Line 978 | sendto_wallops_flags(unsigned int flags,
978      struct Client *client_p = ptr->data;
979      assert(client_p->umodes & UMODE_OPER);
980  
981 <    if ((client_p->umodes & flags) && !IsDefunct(client_p))
981 >    if (HasUMode(client_p, flags) && !IsDefunct(client_p))
982        send_message(client_p, buffer, len);
983    }
984   }
# Line 1072 | Line 1017 | ts_warn(const char *pattern, ...)
1017    }
1018  
1019    va_start(args, pattern);
1020 <  vsprintf_irc(buffer, pattern, args);
1020 >  vsnprintf(buffer, sizeof(buffer), pattern, args);
1021    va_end(args);
1022  
1023    sendto_realops_flags(UMODE_ALL, L_ALL, "%s", buffer);
1024 <  ilog(L_CRIT, "%s", buffer);
1024 >  ilog(LOG_TYPE_IRCD, "%s", buffer);
1025   }
1026  
1027   /* kill_client()
# Line 1130 | Line 1075 | kill_client_ll_serv_butone(struct Client
1075    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1076    int len_uid = 0, len_nick = 0;
1077  
1078 <  if (HasID(source_p) && (me.id[0] != '\0'))
1078 >  if (HasID(source_p))
1079    {
1080      have_uid = 1;
1081      va_start(args, pattern);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)