fixed ssl.c bug when ssl backend returns IO_BLOCKED but IO engine doesn't get informe...
[ircu2.10.12-pk.git] / ircd / send.c
index 9be66519077b8088da5cd011afb386a8e21275ab..cdd5de8adc87bff3d9ba78cfc7237cb6f72c0da5 100644 (file)
@@ -191,7 +191,7 @@ void send_queued(struct Client *to)
       msgq_delete(&(cli_sendQ(to)), len);
       cli_lastsq(to) = MsgQLength(&(cli_sendQ(to))) / 1024;
       if (IsBlocked(to)) {
-       update_write(to);
+        update_write(to);
         return;
       }
     }
@@ -201,6 +201,8 @@ void send_queued(struct Client *to)
         sprintf(tmp,"Write error: %s",(strerror(cli_error(to))) ? (strerror(cli_error(to))) : "Unknown error" );
         dead_link(to, tmp);
       }
+      if (IsBlocked(to))
+        update_write(to);
       return;
     }
   }
@@ -514,6 +516,60 @@ void sendcmdto_common_channels_butone(struct Client *from, const char *cmd,
   msgq_clean(mb);
 }
 
+/** Send a (prefixed) command to all channels that \a from is on. (Check audit)
+ * @param[in] from Client originating the command.
+ * @param[in] cmd Long name of command.
+ * @param[in] tok Short name of command.
+ * @param[in] one Client direction to skip (or NULL).
+ * @param[in] pattern Format string for command arguments.
+ */
+void sendcmdto_common_channels_butone_audit(struct Client *from, const char *cmd,
+                                     const char *tok, struct Client *one,
+                                     const char *pattern, ...)
+{
+  struct VarData vd;
+  struct MsgBuf *mb;
+  struct Membership *chan;
+  struct Membership *member;
+
+  assert(0 != from);
+  assert(0 != cli_from(from));
+  assert(0 != pattern);
+  assert(!IsServer(from) && !IsMe(from));
+
+  vd.vd_format = pattern; /* set up the struct VarData for %v */
+
+  va_start(vd.vd_args, pattern);
+
+  /* build the buffer */
+  mb = msgq_make(0, "%:#C %s %v", from, cmd, &vd);
+  va_end(vd.vd_args);
+
+  bump_sentalong(from);
+  /*
+   * loop through from's channels, and the members on their channels
+   */
+  for (chan = cli_user(from)->channel; chan; chan = chan->next_channel) {
+    if (IsZombie(chan) || IsDelayedJoin(chan))
+      continue;
+    for (member = chan->channel->members; member;
+        member = member->next_member)
+      if (MyConnect(member->user)
+          && -1 < cli_fd(cli_from(member->user))
+          && member->user != one
+          && cli_sentalong(member->user) != sentalong_marker
+          && (!(chan->channel->mode.mode & MODE_AUDITORIUM) || IsVoicedOrOpped(chan) || IsChanOp(member))) {
+       cli_sentalong(member->user) = sentalong_marker;
+       send_buffer(member->user, mb, 0);
+      }
+  }
+
+  if (MyConnect(from) && from != one)
+    send_buffer(from, mb, 0);
+
+  msgq_clean(mb);
+}
+
 /** Send a (prefixed) command to all local users on a channel.
  * @param[in] from Client originating the command.
  * @param[in] cmd Long name of command.
@@ -546,6 +602,7 @@ void sendcmdto_channel_butserv_butone(struct Client *from, const char *cmd,
         || IsZombie(member)
         || (skip & SKIP_DEAF && IsDeaf(member->user))
         || (skip & SKIP_NONOPS && !IsChanOp(member))
+               || (skip & SKIP_OPS && IsChanOp(member))
         || (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)))
         continue;
       send_buffer(member->user, mb, 0);
@@ -588,6 +645,7 @@ void sendcmdto_channel_servers_butone(struct Client *from, const char *cmd,
         || cli_fd(cli_from(member->user)) < 0
         || cli_sentalong(member->user) == sentalong_marker
         || (skip & SKIP_NONOPS && !IsChanOp(member))
+               || (skip & SKIP_OPS && IsChanOp(member))
         || (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)))
       continue;
     cli_sentalong(member->user) = sentalong_marker;
@@ -639,6 +697,7 @@ void sendcmdto_channel_butone(struct Client *from, const char *cmd,
     if (IsZombie(member) ||
         (skip & SKIP_DEAF && IsDeaf(member->user)) ||
         (skip & SKIP_NONOPS && !IsChanOp(member)) ||
+               (skip & SKIP_OPS && IsChanOp(member)) ||
         (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member)) ||
         (skip & SKIP_BURST && IsBurstOrBurstAck(cli_from(member->user))) ||
         cli_fd(cli_from(member->user)) < 0 ||