static void tcp_flush_with_flags(ChannelTCP * c, int flags) { unsigned char * p = c->obuf; assert(is_dispatch_thread()); assert(c->magic == CHANNEL_MAGIC); assert(c->chan.out.end == p + sizeof(c->obuf)); assert(c->out_bin_block == NULL); assert(c->chan.out.cur >= p); assert(c->chan.out.cur <= p + sizeof(c->obuf)); if (c->chan.out.cur == p) return; if (c->chan.state != ChannelStateDisconnected && c->out_errno == 0) { #if ENABLE_OutputQueue c->out_queue.post_io_request = post_write_request; output_queue_add(&c->out_queue, p, c->chan.out.cur - p); #else assert(c->ssl == NULL); while (p < c->chan.out.cur) { size_t sz = c->chan.out.cur - p; ssize_t wr = send(c->socket, p, sz, flags); if (wr < 0) { int err = errno; trace(LOG_PROTOCOL, "Can't send() on channel %#lx: %s", c, errno_to_str(err)); c->out_errno = err; c->chan.out.cur = c->obuf; return; } p += wr; } assert(p == c->chan.out.cur); #endif } c->chan.out.cur = c->obuf; }
static void create_write_request(ChannelPIPE * c, const void * buf, size_t size) { if (c->chan->state == ChannelStateDisconnected) return; c->out_queue.post_io_request = post_write_request; output_queue_add(&c->out_queue, buf, size); }