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

Comparing ircd-hybrid-7.2/src/send.c (file contents):
Revision 285 by adx, Sat Dec 3 10:57:47 2005 UTC vs.
Revision 1011 by michael, Fri Sep 18 10:14:09 2009 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
26 > #include "list.h"
27   #include "send.h"
28   #include "channel.h"
29   #include "client.h"
# Line 38 | Line 38
38   #include "s_serv.h"
39   #include "sprintf_irc.h"
40   #include "s_conf.h"
41 #include "list.h"
41   #include "s_log.h"
42   #include "memory.h"
43   #include "hook.h"
# Line 53 | Line 52 | struct Callback *iosendctrl_cb = NULL;
52   static void send_message(struct Client *, char *, int);
53   static void send_message_remote(struct Client *, struct Client *, char *, int);
54  
55 < static unsigned long current_serial = 0L;
55 > static unsigned int current_serial = 0;
56  
57   /* send_format()
58   *
# Line 112 | Line 111 | iosend_default(va_list args)
111   static void
112   send_message(struct Client *to, char *buf, int len)
113   {
114 < #ifdef INVARIANTS
115 <  if (IsMe(to))
117 <  {
118 <    sendto_realops_flags(UMODE_ALL, L_ALL,
119 <                         "Trying to send message to myself!");
120 <    return;
121 <  }
122 < #endif
114 >  assert(!IsMe(to));
115 >  assert(to != &me);
116  
117    if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to))
118    {
# Line 173 | Line 166 | send_message_remote(struct Client *to, s
166      return;
167    }
168  
176  if (ServerInfo.hub && IsCapable(to, CAP_LL))
177  {
178    if (((from->lazyLinkClientExists &
179          to->localClient->serverMask) == 0))
180      client_burst_if_needed(to, from);
181  }
182
169    /* Optimize by checking if (from && to) before everything */
170    /* we set to->from up there.. */
171  
# Line 199 | Line 185 | send_message_remote(struct Client *to, s
185                           from->name, from->username, from->host,
186                           to->from->name);
187  
188 <    sendto_server(NULL, to, NULL, CAP_TS6, NOCAPS, NOFLAGS,
188 >    sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
189                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
190                    me.id, to->name, me.name, to->name,
191                    to->username, to->host, to->from->name);
192 <    sendto_server(NULL, to, NULL, NOCAPS, CAP_TS6, NOFLAGS,
192 >    sendto_server(NULL, NULL, NOCAPS, CAP_TS6,
193                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
194                    me.name, to->name, me.name, to->name,
195                    to->username, to->host, to->from->name);
# Line 295 | Line 281 | send_queued_write(struct Client *to)
281                errno = EWOULDBLOCK;
282              case SSL_ERROR_SYSCALL:
283                break;
284 <
284 >            case SSL_ERROR_SSL:
285 >              if (errno == EAGAIN)
286 >                break;
287              default:
288                retlen = errno = 0;  /* either an SSL-specific error or EOF */
289            }
# Line 305 | Line 293 | send_queued_write(struct Client *to)
293          retlen = send(to->localClient->fd.fd, first->data, first->size, 0);
294  
295        if (retlen <= 0)
308      {
309 #ifdef _WIN32
310        errno = WSAGetLastError();
311 #endif
296          break;
313      }
297  
298        dbuf_delete(&to->localClient->buf_sendq, retlen);
299  
# Line 545 | Line 528 | sendto_channel_butone(struct Client *one
528   /* sendto_server()
529   *
530   * inputs       - pointer to client to NOT send to
531 < *              - pointer to source client required by LL (if any)
549 < *              - pointer to channel required by LL (if any)
531 > *              - pointer to channel
532   *              - caps or'd together which must ALL be present
533   *              - caps or'd together which must ALL NOT be present
552 *              - LL flags: LL_ICLIENT | LL_ICHAN
534   *              - printf style format string
535   *              - args to format string
536   * output       - NONE
537   * side effects - Send a message to all connected servers, except the
538   *                client 'one' (if non-NULL), as long as the servers
539   *                support ALL capabs in 'caps', and NO capabs in 'nocaps'.
559 *                If the server is a lazylink client, then it must know
560 *                about source_p if non-NULL (unless LL_ICLIENT is specified,
561 *                when source_p will be introduced where required) and
562 *                chptr if non-NULL (unless LL_ICHANNEL is specified, when
563 *                chptr will be introduced where required).
564 *                Note: nothing will be introduced to a LazyLeaf unless
565 *                the message is actually sent.
540   *            
541   * This function was written in an attempt to merge together the other
542   * billion sendto_*serv*() functions, which sprung up with capabs,
# Line 570 | Line 544 | sendto_channel_butone(struct Client *one
544   * -davidt
545   */
546   void
547 < sendto_server(struct Client *one, struct Client *source_p,
547 > sendto_server(struct Client *one,
548                struct Channel *chptr, unsigned long caps,
549 <              unsigned long nocaps, unsigned long llflags,
549 >              unsigned long nocaps,
550                const char *format, ...)
551   {
552    va_list args;
553 <  struct Client *client_p;
580 <  dlink_node *ptr;
553 >  dlink_node *ptr = NULL;
554    char buffer[IRCD_BUFSIZE];
555 <  int len;
555 >  int len = 0;
556  
557 <  if (chptr != NULL)
558 <  {
586 <    if (chptr->chname[0] != '#')
587 <      return;
588 <  }
557 >  if (chptr && chptr->chname[0] != '#')
558 >    return;
559  
560    va_start(args, format);
561    len = send_format(buffer, IRCD_BUFSIZE, format, args);
# Line 593 | Line 563 | sendto_server(struct Client *one, struct
563  
564    DLINK_FOREACH(ptr, serv_list.head)
565    {
566 <    client_p = ptr->data;
566 >    struct Client *client_p = ptr->data;
567  
568      /* If dead already skip */
569      if (IsDead(client_p))
# Line 608 | Line 578 | sendto_server(struct Client *one, struct
578      if ((client_p->localClient->caps & nocaps) != 0)
579        continue;
580  
611    if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
612    {
613      /* check LL channel */
614      if (chptr != NULL &&
615          ((chptr->lazyLinkChannelExists &
616            client_p->localClient->serverMask) == 0))
617      {
618        /* Only introduce the channel if we really will send this message */
619        if (!(llflags & LL_ICLIENT) && source_p &&
620            ((source_p->lazyLinkClientExists &
621              client_p->localClient->serverMask) == 0))
622          continue; /* we can't introduce the unknown source_p, skip */
623
624        if (llflags & LL_ICHAN)
625          burst_channel(client_p, chptr);
626        else
627          continue; /* we can't introduce the unknown chptr, skip */
628      }
629      /* check LL client */
630      if (source_p &&
631          ((source_p->lazyLinkClientExists &
632            client_p->localClient->serverMask) == 0))
633      {
634        if (llflags & LL_ICLIENT)
635          client_burst_if_needed(client_p,source_p);
636        else
637          continue; /* we can't introduce the unknown source_p, skip */
638      }
639    }
581      send_message(client_p, buffer, len);
582    }
583   }
# Line 674 | Line 615 | sendto_common_channels_local(struct Clie
615      chptr = ((struct Membership *) cptr->data)->chptr;
616      assert(chptr != NULL);
617  
618 <    DLINK_FOREACH(uptr, chptr->locmembers.head)
618 >    DLINK_FOREACH(uptr, chptr->members.head)
619      {
620        ms = uptr->data;
621        target_p = ms->client_p;
622        assert(target_p != NULL);
623  
624 <      if (target_p == user || IsDefunct(target_p) ||
624 >      if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
625            target_p->serial == current_serial)
626          continue;
627  
# Line 719 | Line 660 | sendto_channel_local(int type, int nodea
660    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
661    va_end(args);
662  
663 <  DLINK_FOREACH(ptr, chptr->locmembers.head)
663 >  DLINK_FOREACH(ptr, chptr->members.head)
664    {
665      ms = ptr->data;
666      target_p = ms->client_p;
# Line 727 | Line 668 | sendto_channel_local(int type, int nodea
668      if (type != 0 && (ms->flags & type) == 0)
669        continue;
670  
671 <    if (IsDefunct(target_p) || (nodeaf && IsDeaf(target_p)))
671 >    if (!MyConnect(target_p) || IsDefunct(target_p) ||
672 >        (nodeaf && IsDeaf(target_p)))
673        continue;
674  
675      send_message(target_p, buffer, len);
# Line 761 | Line 703 | sendto_channel_local_butone(struct Clien
703    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
704    va_end(args);
705  
706 <  DLINK_FOREACH(ptr, chptr->locmembers.head)      
706 >  DLINK_FOREACH(ptr, chptr->members.head)      
707    {  
708      ms = ptr->data;
709      target_p = ms->client_p;
# Line 769 | Line 711 | sendto_channel_local_butone(struct Clien
711      if (type != 0 && (ms->flags & type) == 0)
712        continue;
713  
714 <    if (target_p == one || IsDefunct(target_p) || IsDeaf(target_p))
714 >    if (!MyConnect(target_p) || target_p == one ||
715 >        IsDefunct(target_p) || IsDeaf(target_p))
716        continue;
717      send_message(target_p, buffer, len);
718    }
# Line 949 | Line 892 | sendto_match_servs(struct Client *source
892    vsnprintf(buffer, sizeof(buffer), pattern, args);
893    va_end(args);
894  
895 <  current_serial++;
895 >  ++current_serial;
896  
897    DLINK_FOREACH(ptr, global_serv_list.head)
898    {
# Line 1189 | Line 1132 | kill_client_ll_serv_butone(struct Client
1132   {
1133    va_list args;
1134    int have_uid = 0;
1135 <  struct Client *client_p;
1193 <  dlink_node *ptr;
1135 >  dlink_node *ptr = NULL;
1136    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1137 <  int len_uid = 0, len_nick;
1137 >  int len_uid = 0, len_nick = 0;
1138  
1139    if (HasID(source_p) && (me.id[0] != '\0'))
1140    {
# Line 1212 | Line 1154 | kill_client_ll_serv_butone(struct Client
1154  
1155    DLINK_FOREACH(ptr, serv_list.head)
1156    {
1157 <    client_p = ptr->data;
1157 >    struct Client *client_p = ptr->data;
1158  
1159      if (one != NULL && (client_p == one->from))
1160        continue;
1161      if (IsDefunct(client_p))
1162        continue;
1163  
1164 <    /* XXX perhaps IsCapable should test for localClient itself ? -db */
1165 <    if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) ||
1166 <        !ServerInfo.hub ||
1167 <        (source_p->lazyLinkClientExists & client_p->localClient->serverMask))
1226 <    {
1227 <      if (have_uid && IsCapable(client_p, CAP_TS6))
1228 <        send_message(client_p, buf_uid, len_uid);
1229 <      else
1230 <        send_message(client_p, buf_nick, len_nick);
1231 <    }
1164 >    if (have_uid && IsCapable(client_p, CAP_TS6))
1165 >      send_message(client_p, buf_uid, len_uid);
1166 >    else
1167 >      send_message(client_p, buf_nick, len_nick);
1168    }
1169   }

Diff Legend

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