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/src/send.c (file contents), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-7.2/src/send.c (file contents), Revision 939 by db, Sat May 2 01:41:47 2009 UTC

# Line 91 | Line 91 | send_format(char *lsendbuf, int bufsize,
91   }
92  
93   /*
94 + * iosend_default - append a packet to the client's sendq.
95 + */
96 + void *
97 + iosend_default(va_list args)
98 + {
99 +  struct Client *to = va_arg(args, struct Client *);
100 +  int length = va_arg(args, int);
101 +  char *buf = va_arg(args, char *);
102 +
103 +  dbuf_put(&to->localClient->buf_sendq, buf, length);
104 +  return NULL;
105 + }
106 +
107 + /*
108   ** send_message
109   **      Internal utility which appends given buffer to the sockets
110   **      sendq.
# Line 98 | Line 112 | send_format(char *lsendbuf, int bufsize,
112   static void
113   send_message(struct Client *to, char *buf, int len)
114   {
115 < #ifdef INVARIANTS
116 <  if (IsMe(to))
103 <  {
104 <    sendto_realops_flags(UMODE_ALL, L_ALL,
105 <                         "Trying to send message to myself!");
106 <    return;
107 <  }
108 < #endif
115 >  assert(!IsMe(to));
116 >  assert(to != &me);
117  
118    if (dbuf_length(&to->localClient->buf_sendq) + len > get_sendq(to))
119    {
# Line 121 | Line 129 | send_message(struct Client *to, char *bu
129      return;
130    }
131  
132 <  dbuf_put(&to->localClient->buf_sendq, buf, len);
132 >  execute_callback(iosend_cb, to, len, buf);
133  
134    /*
135     ** Update statistics. The following is slightly incorrect
# Line 159 | Line 167 | send_message_remote(struct Client *to, s
167      return;
168    }
169  
162 –  if (ServerInfo.hub && IsCapable(to, CAP_LL))
163 –  {
164 –    if (((from->lazyLinkClientExists &
165 –          to->localClient->serverMask) == 0))
166 –      client_burst_if_needed(to, from);
167 –  }
168 –
170    /* Optimize by checking if (from && to) before everything */
171    /* we set to->from up there.. */
172  
# Line 185 | Line 186 | send_message_remote(struct Client *to, s
186                           from->name, from->username, from->host,
187                           to->from->name);
188  
189 <    sendto_server(NULL, to, NULL, CAP_TS6, NOCAPS, NOFLAGS,
189 >    sendto_server(NULL, NULL, CAP_TS6, NOCAPS,
190                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
191                    me.id, to->name, me.name, to->name,
192                    to->username, to->host, to->from->name);
193 <    sendto_server(NULL, to, NULL, NOCAPS, CAP_TS6, NOFLAGS,
193 >    sendto_server(NULL, NULL, NOCAPS, CAP_TS6,
194                    ":%s KILL %s :%s (%s[%s@%s] Ghosted %s)",
195                    me.name, to->name, me.name, to->name,
196                    to->username, to->host, to->from->name);
# Line 281 | Line 282 | send_queued_write(struct Client *to)
282                errno = EWOULDBLOCK;
283              case SSL_ERROR_SYSCALL:
284                break;
285 <
285 >            case SSL_ERROR_SSL:
286 >              if (errno == EAGAIN)
287 >                break;
288              default:
289                retlen = errno = 0;  /* either an SSL-specific error or EOF */
290            }
# Line 298 | Line 301 | send_queued_write(struct Client *to)
301          break;
302        }
303  
301 –      execute_callback(iosend_cb, to, retlen, first->data);
304        dbuf_delete(&to->localClient->buf_sendq, retlen);
305  
306        /* We have some data written .. update counters */
# Line 460 | Line 462 | sendto_channel_butone(struct Client *one
462                        struct Channel *chptr, const char *command,
463                        const char *pattern, ...)
464   {
465 <  va_list args;
465 >  va_list alocal, aremote, auid;
466    char local_buf[IRCD_BUFSIZE];
467    char remote_buf[IRCD_BUFSIZE];
468    char uid_buf[IRCD_BUFSIZE];
# Line 481 | Line 483 | sendto_channel_butone(struct Client *one
483    uid_len = ircsprintf(uid_buf, ":%s %s %s ",
484                         ID(from), command, chptr->chname);
485  
486 <  va_start(args, pattern);
486 >  va_start(alocal, pattern);
487 >  va_start(aremote, pattern);
488 >  va_start(auid, pattern);
489    local_len += send_format(&local_buf[local_len], IRCD_BUFSIZE - local_len,
490 <                           pattern, args);
490 >                           pattern, alocal);
491    remote_len += send_format(&remote_buf[remote_len], IRCD_BUFSIZE - remote_len,
492 <                            pattern, args);
492 >                            pattern, aremote);
493    uid_len += send_format(&uid_buf[uid_len], IRCD_BUFSIZE - uid_len, pattern,
494 <                         args);
495 <  va_end(args);
494 >                         auid);
495 >  va_end(auid);
496 >  va_end(aremote);
497 >  va_end(alocal);
498  
499    ++current_serial;
500  
# Line 528 | Line 534 | sendto_channel_butone(struct Client *one
534   /* sendto_server()
535   *
536   * inputs       - pointer to client to NOT send to
537 < *              - pointer to source client required by LL (if any)
532 < *              - pointer to channel required by LL (if any)
537 > *              - pointer to channel
538   *              - caps or'd together which must ALL be present
539   *              - caps or'd together which must ALL NOT be present
535 – *              - LL flags: LL_ICLIENT | LL_ICHAN
540   *              - printf style format string
541   *              - args to format string
542   * output       - NONE
543   * side effects - Send a message to all connected servers, except the
544   *                client 'one' (if non-NULL), as long as the servers
545   *                support ALL capabs in 'caps', and NO capabs in 'nocaps'.
542 – *                If the server is a lazylink client, then it must know
543 – *                about source_p if non-NULL (unless LL_ICLIENT is specified,
544 – *                when source_p will be introduced where required) and
545 – *                chptr if non-NULL (unless LL_ICHANNEL is specified, when
546 – *                chptr will be introduced where required).
547 – *                Note: nothing will be introduced to a LazyLeaf unless
548 – *                the message is actually sent.
546   *            
547   * This function was written in an attempt to merge together the other
548   * billion sendto_*serv*() functions, which sprung up with capabs,
# Line 553 | Line 550 | sendto_channel_butone(struct Client *one
550   * -davidt
551   */
552   void
553 < sendto_server(struct Client *one, struct Client *source_p,
553 > sendto_server(struct Client *one,
554                struct Channel *chptr, unsigned long caps,
555 <              unsigned long nocaps, unsigned long llflags,
555 >              unsigned long nocaps,
556                const char *format, ...)
557   {
558    va_list args;
559 <  struct Client *client_p;
563 <  dlink_node *ptr;
559 >  dlink_node *ptr = NULL;
560    char buffer[IRCD_BUFSIZE];
561 <  int len;
561 >  int len = 0;
562  
563 <  if (chptr != NULL)
564 <  {
569 <    if (chptr->chname[0] != '#')
570 <      return;
571 <  }
563 >  if (chptr && chptr->chname[0] != '#')
564 >    return;
565  
566    va_start(args, format);
567    len = send_format(buffer, IRCD_BUFSIZE, format, args);
# Line 576 | Line 569 | sendto_server(struct Client *one, struct
569  
570    DLINK_FOREACH(ptr, serv_list.head)
571    {
572 <    client_p = ptr->data;
572 >    struct Client *client_p = ptr->data;
573  
574      /* If dead already skip */
575      if (IsDead(client_p))
# Line 591 | Line 584 | sendto_server(struct Client *one, struct
584      if ((client_p->localClient->caps & nocaps) != 0)
585        continue;
586  
594 –    if (ServerInfo.hub && IsCapable(client_p, CAP_LL))
595 –    {
596 –      /* check LL channel */
597 –      if (chptr != NULL &&
598 –          ((chptr->lazyLinkChannelExists &
599 –            client_p->localClient->serverMask) == 0))
600 –      {
601 –        /* Only introduce the channel if we really will send this message */
602 –        if (!(llflags & LL_ICLIENT) && source_p &&
603 –            ((source_p->lazyLinkClientExists &
604 –              client_p->localClient->serverMask) == 0))
605 –          continue; /* we can't introduce the unknown source_p, skip */
606 –
607 –        if (llflags & LL_ICHAN)
608 –          burst_channel(client_p, chptr);
609 –        else
610 –          continue; /* we can't introduce the unknown chptr, skip */
611 –      }
612 –      /* check LL client */
613 –      if (source_p &&
614 –          ((source_p->lazyLinkClientExists &
615 –            client_p->localClient->serverMask) == 0))
616 –      {
617 –        if (llflags & LL_ICLIENT)
618 –          client_burst_if_needed(client_p,source_p);
619 –        else
620 –          continue; /* we can't introduce the unknown source_p, skip */
621 –      }
622 –    }
587      send_message(client_p, buffer, len);
588    }
589   }
# Line 657 | Line 621 | sendto_common_channels_local(struct Clie
621      chptr = ((struct Membership *) cptr->data)->chptr;
622      assert(chptr != NULL);
623  
624 <    DLINK_FOREACH(uptr, chptr->locmembers.head)
624 >    DLINK_FOREACH(uptr, chptr->members.head)
625      {
626        ms = uptr->data;
627        target_p = ms->client_p;
628        assert(target_p != NULL);
629  
630 <      if (target_p == user || IsDefunct(target_p) ||
630 >      if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
631            target_p->serial == current_serial)
632          continue;
633  
# Line 702 | Line 666 | sendto_channel_local(int type, int nodea
666    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
667    va_end(args);
668  
669 <  DLINK_FOREACH(ptr, chptr->locmembers.head)
669 >  DLINK_FOREACH(ptr, chptr->members.head)
670    {
671      ms = ptr->data;
672      target_p = ms->client_p;
# Line 710 | Line 674 | sendto_channel_local(int type, int nodea
674      if (type != 0 && (ms->flags & type) == 0)
675        continue;
676  
677 <    if (IsDefunct(target_p) || (nodeaf && IsDeaf(target_p)))
677 >    if (!MyConnect(target_p) || IsDefunct(target_p) ||
678 >        (nodeaf && IsDeaf(target_p)))
679        continue;
680  
681      send_message(target_p, buffer, len);
# Line 744 | Line 709 | sendto_channel_local_butone(struct Clien
709    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
710    va_end(args);
711  
712 <  DLINK_FOREACH(ptr, chptr->locmembers.head)      
712 >  DLINK_FOREACH(ptr, chptr->members.head)      
713    {  
714      ms = ptr->data;
715      target_p = ms->client_p;
# Line 752 | Line 717 | sendto_channel_local_butone(struct Clien
717      if (type != 0 && (ms->flags & type) == 0)
718        continue;
719  
720 <    if (target_p == one || IsDefunct(target_p) || IsDeaf(target_p))
720 >    if (!MyConnect(target_p) || target_p == one ||
721 >        IsDefunct(target_p) || IsDeaf(target_p))
722        continue;
723      send_message(target_p, buffer, len);
724    }
# Line 785 | Line 751 | sendto_channel_remote(struct Client *one
751    len = send_format(buffer, IRCD_BUFSIZE, pattern, args);
752    va_end(args);
753  
754 +  ++current_serial;
755 +
756    DLINK_FOREACH(ptr, chptr->members.head)
757    {
758      ms = ptr->data;
# Line 801 | Line 769 | sendto_channel_remote(struct Client *one
769          ((target_p->from->localClient->caps & caps) != caps) ||
770          ((target_p->from->localClient->caps & nocaps) != 0))
771        continue;
772 <
773 <    send_message(target_p, buffer, len);
772 >    if (target_p->from->serial != current_serial)
773 >    {
774 >      send_message(target_p, buffer, len);
775 >      target_p->from->serial = current_serial;
776 >    }
777    }
778   }
779  
# Line 843 | Line 814 | void
814   sendto_match_butone(struct Client *one, struct Client *from, char *mask,
815                      int what, const char *pattern, ...)
816   {
817 <  va_list args;
817 >  va_list alocal, aremote;
818    struct Client *client_p;
819    dlink_node *ptr, *ptr_next;
820    char local_buf[IRCD_BUFSIZE], remote_buf[IRCD_BUFSIZE];
# Line 851 | Line 822 | sendto_match_butone(struct Client *one,
822                               from->username, from->host);
823    int remote_len = ircsprintf(remote_buf, ":%s ", from->name);
824  
825 <  va_start(args, pattern);
825 >  va_start(alocal, pattern);
826 >  va_start(aremote, pattern);
827    local_len += send_format(&local_buf[local_len], IRCD_BUFSIZE - local_len,
828 <                           pattern, args);
828 >                           pattern, alocal);
829    remote_len += send_format(&remote_buf[remote_len], IRCD_BUFSIZE - remote_len,
830 <                            pattern, args);
831 <  va_end(args);
830 >                            pattern, aremote);
831 >  va_end(aremote);
832 >  va_end(alocal);
833  
834    /* scan the local clients */
835    DLINK_FOREACH(ptr, local_client_list.head)
# Line 1165 | Line 1138 | kill_client_ll_serv_butone(struct Client
1138   {
1139    va_list args;
1140    int have_uid = 0;
1141 <  struct Client *client_p;
1169 <  dlink_node *ptr;
1141 >  dlink_node *ptr = NULL;
1142    char buf_uid[IRCD_BUFSIZE], buf_nick[IRCD_BUFSIZE];
1143 <  int len_uid = 0, len_nick;
1143 >  int len_uid = 0, len_nick = 0;
1144  
1173 –  va_start(args, pattern);
1145    if (HasID(source_p) && (me.id[0] != '\0'))
1146    {
1147      have_uid = 1;
1148 +    va_start(args, pattern);
1149      len_uid = ircsprintf(buf_uid, ":%s KILL %s :", me.id, ID(source_p));
1150      len_uid += send_format(&buf_uid[len_uid], IRCD_BUFSIZE - len_uid, pattern,
1151                             args);
1152 +    va_end(args);
1153    }
1154 +
1155 +  va_start(args, pattern);
1156    len_nick = ircsprintf(buf_nick, ":%s KILL %s :", me.name, source_p->name);
1157    len_nick += send_format(&buf_nick[len_nick], IRCD_BUFSIZE - len_nick, pattern,
1158                            args);
# Line 1185 | Line 1160 | kill_client_ll_serv_butone(struct Client
1160  
1161    DLINK_FOREACH(ptr, serv_list.head)
1162    {
1163 <    client_p = ptr->data;
1163 >    struct Client *client_p = ptr->data;
1164  
1165      if (one != NULL && (client_p == one->from))
1166        continue;
1167      if (IsDefunct(client_p))
1168        continue;
1169  
1170 <    /* XXX perhaps IsCapable should test for localClient itself ? -db */
1171 <    if (client_p->localClient == NULL || !IsCapable(client_p, CAP_LL) ||
1172 <        !ServerInfo.hub ||
1173 <        (source_p->lazyLinkClientExists & client_p->localClient->serverMask))
1199 <    {
1200 <      if (have_uid && IsCapable(client_p, CAP_TS6))
1201 <        send_message(client_p, buf_uid, len_uid);
1202 <      else
1203 <        send_message(client_p, buf_nick, len_nick);
1204 <    }
1170 >    if (have_uid && IsCapable(client_p, CAP_TS6))
1171 >      send_message(client_p, buf_uid, len_uid);
1172 >    else
1173 >      send_message(client_p, buf_nick, len_nick);
1174    }
1175   }

Comparing:
ircd-hybrid/src/send.c (property svn:keywords), Revision 32 by knight, Sun Oct 2 20:41:23 2005 UTC vs.
ircd-hybrid-7.2/src/send.c (property svn:keywords), Revision 939 by db, Sat May 2 01:41:47 2009 UTC

# Line 1 | Line 1
1 < Revision
1 > Id Revision

Diff Legend

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