/* send_queued_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(struct Client *to) { int retlen; #ifdef USE_IODEBUG_HOOKS hook_data_int hd; #endif rb_fde_t *F = to->localClient->F; if (!F) return; /* cant write anything to a dead socket. */ 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) hd.arg1 = ((buf_line_t *) to->localClient->buf_sendq.list.head->data)->buf + to->localClient->buf_sendq.writeofs; #endif if(rb_linebuf_len(&to->localClient->buf_sendq)) { while ((retlen = rb_linebuf_flush(F, &to->localClient->buf_sendq)) > 0) { /* We have some data written .. update counters */ #ifdef USE_IODEBUG_HOOKS hd.arg2 = retlen; call_hook(h_iosend_id, &hd); if(to->localClient->buf_sendq.list.head) hd.arg1 = ((buf_line_t *) to->localClient->buf_sendq.list.head-> data)->buf + to->localClient->buf_sendq.writeofs; #endif ClearFlush(to); to->localClient->sendB += retlen; me.localClient->sendB += retlen; if(to->localClient->sendB > 1023) { to->localClient->sendK += (to->localClient->sendB >> 10); to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ } else if(me.localClient->sendB > 1023) { me.localClient->sendK += (me.localClient->sendB >> 10); me.localClient->sendB &= 0x03ff; }
/* send_queued_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(struct Client *to) { int retlen; rb_fde_t *F = to->localClient->F; if (!F) return; /* cant write anything to a dead socket. */ if(IsIOError(to)) return; /* try to flush later when the write event resets this */ if(IsFlush(to)) return; if(rb_linebuf_len(&to->localClient->buf_sendq)) { while ((retlen = rb_linebuf_flush(F, &to->localClient->buf_sendq)) > 0) { /* We have some data written .. update counters */ ClearFlush(to); to->localClient->sendB += retlen; me.localClient->sendB += retlen; if(to->localClient->sendB > 1023) { to->localClient->sendK += (to->localClient->sendB >> 10); to->localClient->sendB &= 0x03ff; /* 2^10 = 1024, 3ff = 1023 */ } else if(me.localClient->sendB > 1023) { me.localClient->sendK += (me.localClient->sendB >> 10); me.localClient->sendB &= 0x03ff; }