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/trunk/src/send.c (file contents):
Revision 3189 by michael, Fri Mar 21 18:18:00 2014 UTC vs.
Revision 3312 by michael, Tue Apr 15 12:13:07 2014 UTC

# Line 99 | Line 99 | send_message(struct Client *to, struct d
99                             get_sendq(&to->localClient->confs));
100      if (IsClient(to))
101        SetSendQExceeded(to);
102 +
103      dead_link_on_write(to, 0);
104      return;
105    }
# Line 106 | Line 107 | send_message(struct Client *to, struct d
107    dbuf_add(&to->localClient->buf_sendq, buf);
108  
109    /*
110 <   ** Update statistics. The following is slightly incorrect
111 <   ** because it counts messages even if queued, but bytes
112 <   ** only really sent. Queued bytes get updated in SendQueued.
110 >   * Update statistics. The following is slightly incorrect because
111 >   * it counts messages even if queued, but bytes only really sent.
112 >   * Queued bytes get updated in send_queued_write().
113     */
114    ++to->localClient->send.messages;
115    ++me.localClient->send.messages;
# Line 184 | Line 185 | void
185   sendq_unblocked(fde_t *fd, struct Client *client_p)
186   {
187    assert(fd == &client_p->localClient->fd);
188 +
189 +  DelFlag(client_p, FLAGS_BLOCKED);
190    send_queued_write(client_p);
191   }
192  
# Line 202 | Line 205 | send_queued_write(struct Client *to)
205     ** Once socket is marked dead, we cannot start writing to it,
206     ** even if the error is removed...
207     */
208 <  if (IsDead(to))
208 >  if (IsDead(to) || HasFlag(to, FLAGS_BLOCKED))
209      return;  /* no use calling send() now */
210  
211    /* Next, lets try to write some data */
# Line 252 | Line 255 | send_queued_write(struct Client *to)
255  
256      if ((retlen < 0) && (ignoreErrno(errno)))
257      {
258 +      AddFlag(to, FLAGS_BLOCKED);
259        /* we have a non-fatal error, reschedule a write */
260        comm_setselect(&to->localClient->fd, COMM_SELECT_WRITE,
261                       (PF *)sendq_unblocked, to, 0);
# Line 426 | Line 430 | sendto_channel_butone(struct Client *one
430          (one && target_p->from == one->from))
431        continue;
432  
433 <    if (type != 0 && (ms->flags & type) == 0)
433 >    if (type && (ms->flags & type) == 0)
434        continue;
435  
436      if (MyConnect(target_p))
# Line 482 | Line 486 | sendto_server(struct Client *one,
486      if (IsDead(client_p))
487        continue;
488      /* check against 'one' */
489 <    if (one != NULL && (client_p == one->from))
489 >    if (one && (client_p == one->from))
490        continue;
491      /* check we have required capabs */
492      if ((client_p->localClient->caps & caps) != caps)
493        continue;
494      /* check we don't have any forbidden capabs */
495 <    if ((client_p->localClient->caps & nocaps) != 0)
495 >    if ((client_p->localClient->caps & nocaps))
496        continue;
497  
498      send_message(client_p, buffer);
# Line 529 | Line 533 | sendto_common_channels_local(struct Clie
533    DLINK_FOREACH(cptr, user->channel.head)
534    {
535      chptr = ((struct Membership *)cptr->data)->chptr;
532    assert(chptr != NULL);
536  
537      DLINK_FOREACH(uptr, chptr->members.head)
538      {
539        ms = uptr->data;
540        target_p = ms->client_p;
538      assert(target_p != NULL);
541  
542        if (!MyConnect(target_p) || target_p == user || IsDefunct(target_p) ||
543            target_p->localClient->serial == current_serial)
# Line 586 | Line 588 | sendto_channel_local(unsigned int type,
588      struct Membership *ms = ptr->data;
589      struct Client *target_p = ms->client_p;
590  
591 <    if (type != 0 && (ms->flags & type) == 0)
591 >    if (type && (ms->flags & type) == 0)
592        continue;
593  
594      if (!MyConnect(target_p) || IsDefunct(target_p) ||
# Line 630 | Line 632 | sendto_channel_local_butone(struct Clien
632      struct Membership *ms = ptr->data;
633      struct Client *target_p = ms->client_p;
634  
635 <    if (type != 0 && (ms->flags & type) == 0)
635 >    if (type && (ms->flags & type) == 0)
636        continue;
637  
638      if (!MyConnect(target_p) || (one && target_p == one->from))
# Line 857 | Line 859 | sendto_realops_flags(unsigned int flags,
859   {
860    const char *ntype = NULL;
861    dlink_node *ptr = NULL;
862 <  char nbuf[IRCD_BUFSIZE];
862 >  char nbuf[IRCD_BUFSIZE] = "";
863    va_list args;
864  
865    va_start(args, pattern);
# Line 898 | Line 900 | sendto_realops_flags(unsigned int flags,
900    }
901   }
902  
903 + /* ts_warn()
904 + *
905 + * inputs       - var args message
906 + * output       - NONE
907 + * side effects - Call sendto_realops_flags, with some flood checking
908 + *                (at most 5 warnings every 5 seconds)
909 + */
910 + void
911 + sendto_realops_flags_ratelimited(const char *pattern, ...)
912 + {
913 +  va_list args;
914 +  char buffer[IRCD_BUFSIZE] = "";
915 +  static time_t last = 0;
916 +  static int warnings = 0;
917 +
918 +  /*
919 +   ** if we're running with TS_WARNINGS enabled and someone does
920 +   ** something silly like (remotely) connecting a nonTS server,
921 +   ** we'll get a ton of warnings, so we make sure we don't send
922 +   ** more than 5 every 5 seconds.  -orabidoo
923 +   */
924 +
925 +  if (CurrentTime - last < 5)
926 +  {
927 +    if (++warnings > 5)
928 +      return;
929 +  }
930 +  else
931 +  {
932 +    last = CurrentTime;
933 +    warnings = 0;
934 +  }
935 +
936 +  va_start(args, pattern);
937 +  vsnprintf(buffer, sizeof(buffer), pattern, args);
938 +  va_end(args);
939 +
940 +  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer);
941 +  ilog(LOG_TYPE_IRCD, "%s", buffer);
942 + }
943 +
944   /* sendto_wallops_flags()
945   *
946   * inputs       - flag types of messages to show to real opers
# Line 936 | Line 979 | sendto_wallops_flags(unsigned int flags,
979  
980    dbuf_ref_free(buffer);
981   }
939
940 /* ts_warn()
941 *
942 * inputs       - var args message
943 * output       - NONE
944 * side effects - Call sendto_realops_flags, with some flood checking
945 *                (at most 5 warnings every 5 seconds)
946 */
947 void
948 sendto_realops_flags_ratelimited(const char *pattern, ...)
949 {
950  va_list args;
951  char buffer[IRCD_BUFSIZE];
952  static time_t last = 0;
953  static int warnings = 0;
954
955  /*
956   ** if we're running with TS_WARNINGS enabled and someone does
957   ** something silly like (remotely) connecting a nonTS server,
958   ** we'll get a ton of warnings, so we make sure we don't send
959   ** more than 5 every 5 seconds.  -orabidoo
960   */
961
962  if (CurrentTime - last < 5)
963  {
964    if (++warnings > 5)
965      return;
966  }
967  else
968  {
969    last = CurrentTime;
970    warnings = 0;
971  }
972
973  va_start(args, pattern);
974  vsnprintf(buffer, sizeof(buffer), pattern, args);
975  va_end(args);
976
977  sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE, "%s", buffer);
978  ilog(LOG_TYPE_IRCD, "%s", buffer);
979 }

Diff Legend

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