예제 #1
0
/* 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;
            }
예제 #2
0
파일: helper.c 프로젝트: awilfox/charybdis
static void
rb_helper_write_sendq(rb_fde_t *F, void *helper_ptr)
{
	rb_helper *helper = helper_ptr;
	int retlen;

	if(rb_linebuf_len(&helper->sendq) > 0)
	{
		while((retlen = rb_linebuf_flush(F, &helper->sendq)) > 0)
			;
		if(retlen == 0 || (retlen < 0 && !rb_ignore_errno(errno)))
		{
			rb_helper_restart(helper);
			return;
		}
	}

	if(rb_linebuf_len(&helper->sendq) > 0)
		rb_setselect(helper->ofd, RB_SELECT_WRITE, rb_helper_write_sendq, helper);
}
예제 #3
0
파일: send.c 프로젝트: kamilion/charybdis
/* 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;
			}