]> jfr.im git - irc/rqf/shadowircd.git/blobdiff - src/send.c
Remote d:lines implementation (based on ircd-seven's r230 by spb, Stephen Bennett...
[irc/rqf/shadowircd.git] / src / send.c
index 745f157c5d58fb25dae17053ad2c114500fbade0..a3154c3a0b0387262c9894b0ad50c4e679d334ce 100644 (file)
 #include "class.h"
 #include "client.h"
 #include "common.h"
-#include "irc_string.h"
+#include "match.h"
 #include "ircd.h"
 #include "numeric.h"
 #include "s_serv.h"
-#include "sprintf_irc.h"
 #include "s_conf.h"
 #include "s_newconf.h"
-#include "s_log.h"
+#include "logger.h"
 #include "hook.h"
 #include "monitor.h"
 
@@ -149,6 +148,14 @@ send_queued(struct Client *to)
        if(IsIOError(to))
                return;
 
+       /* Something wants us to not send anything currently */
+       /* if(IsCork(to))
+               return; */
+
+       /* try to flush later when the write event resets this */
+       if(IsFlush(to))
+               return;
+
 #ifdef USE_IODEBUG_HOOKS
        hd.client = to;
        if(to->localClient->buf_sendq.list.head)
@@ -173,6 +180,8 @@ send_queued(struct Client *to)
 #endif
      
 
+                       ClearFlush(to);
+
                        to->localClient->sendB += retlen;
                        me.localClient->sendB += retlen;
                        if(to->localClient->sendB > 1023)
@@ -193,9 +202,26 @@ send_queued(struct Client *to)
                        return;
                }
        }
+
        if(rb_linebuf_len(&to->localClient->buf_sendq))
-       rb_setselect(to->localClient->F, RB_SELECT_WRITE,
+       {
+               SetFlush(to);
+               rb_setselect(to->localClient->F, RB_SELECT_WRITE,
                               send_queued_write, to);
+       }
+       else
+               ClearFlush(to);
+}
+
+void
+send_pop_queue(struct Client *to)
+{
+       if(to->from != NULL)
+               to = to->from;
+       if(!MyConnect(to) || IsIOError(to))
+               return;
+       if(rb_linebuf_len(&to->localClient->buf_sendq) > 0)
+               send_queued(to);
 }
 
 /* send_queued_write()
@@ -208,73 +234,10 @@ static void
 send_queued_write(rb_fde_t *F, void *data)
 {
        struct Client *to = data;
-       /*ClearFlush(to);*/
+       ClearFlush(to);
        send_queued(to);
 }
 
-/* send_queued_slink_write()
- *
- * inputs      - fd to have queue sent, client we're sending to
- * outputs     - contents of queue
- * side effects - write is rescheduled if queue isnt emptied
- */
-void
-send_queued_slink_write(int fd, void *data)
-{
-       struct Client *to = data;
-       int retlen;
-
-       /*
-        ** Once socket is marked dead, we cannot start writing to it,
-        ** even if the error is removed...
-        */
-       if(IsIOError(to))
-               return;
-
-       /* Next, lets try to write some data */
-       if(to->localClient->slinkq)
-       {
-               retlen = write(to->localClient->ctrlfd,
-                             to->localClient->slinkq + to->localClient->slinkq_ofs,
-                             to->localClient->slinkq_len);
-
-               if(retlen < 0)
-               {
-                       /* If we have a fatal error */
-                       if(!rb_ignore_errno(errno))
-                       {
-                               dead_link(to);
-                               return;
-                       }
-               }
-               /* 0 bytes is an EOF .. */
-               else if(retlen == 0)
-               {
-                       dead_link(to);
-                       return;
-               }
-               else
-               {
-                       to->localClient->slinkq_len -= retlen;
-
-                       s_assert(to->localClient->slinkq_len >= 0);
-                       if(to->localClient->slinkq_len)
-                               to->localClient->slinkq_ofs += retlen;
-                       else
-                       {
-                               to->localClient->slinkq_ofs = 0;
-                               MyFree(to->localClient->slinkq);
-                               to->localClient->slinkq = NULL;
-                       }
-               }
-       }
-
-       /* if we have any more data, reschedule a write */
-       if(to->localClient->slinkq_len)
-               rb_setselect(to->localClient->ctrlfd,
-                              RB_SELECT_WRITE, send_queued_slink_write, to);
-}
-
 /* sendto_one()
  *
  * inputs      - client to send to, va_args
@@ -994,46 +957,6 @@ sendto_anywhere(struct Client *target_p, struct Client *source_p,
        rb_linebuf_donebuf(&linebuf);
 }
 
-/* sendto_realops_flags()
- *
- * inputs      - umode needed, level (opers/admin), va_args
- * output      -
- * side effects - message is sent to opers with matching umodes
- */
-void
-sendto_realops_flags(int flags, int level, const char *pattern, ...)
-{
-       struct Client *client_p;
-       rb_dlink_node *ptr;
-       rb_dlink_node *next_ptr;
-       va_list args;
-       buf_head_t linebuf;
-
-       rb_linebuf_newbuf(&linebuf);
-
-       va_start(args, pattern);
-       rb_linebuf_putmsg(&linebuf, pattern, &args, 
-                      ":%s NOTICE * :*** Notice -- ", me.name);
-       va_end(args);
-
-       RB_DLINK_FOREACH_SAFE(ptr, next_ptr, local_oper_list.head)
-       {
-               client_p = ptr->data;
-
-               /* If we're sending it to opers and theyre an admin, skip.
-                * If we're sending it to admins, and theyre not, skip.
-                */
-               if(((level == L_ADMIN) && !IsOperAdmin(client_p)) ||
-                  ((level == L_OPER) && IsOperAdmin(client_p)))
-                       continue;
-
-               if(client_p->umodes & flags)
-                       _send_linebuf(client_p, &linebuf);
-       }
-
-       rb_linebuf_donebuf(&linebuf);
-}
-
 /* sendto_realops_snomask()
  *
  * inputs      - snomask needed, level (opers/admin), va_args