]> git.ipfire.org Git - thirdparty/haproxy.git/commit
[MINOR] buffers: provide buffer_si_putchar() to send a char from a stream interface
authorWilly Tarreau <w@1wt.eu>
Thu, 3 Sep 2009 05:13:50 +0000 (07:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 19 Sep 2009 12:53:47 +0000 (14:53 +0200)
commit36a5c5389d2073126813ed834a7aca4810389bc0
tree6f9ccadca99bff141bf15c556d47f488304f26da
parent4fe7a2ec6c75266cf961537c362f14d2e9814a58
[MINOR] buffers: provide buffer_si_putchar() to send a char from a stream interface

This function works like a traditional putchar() except that it
can return 0 if the output buffer is full.

Now a basic character-based echo function would look like this, from
a stream interface :

while (1) {
c = buffer_si_peekchar(req);
if (c < 0)
break;
if (!buffer_si_putchar(res, c)) {
si->flags |= SI_FL_WAIT_ROOM;
break;
}
buffer_skip(req, 1);
req->flags |= BF_WRITE_PARTIAL;
res->flags |= BF_READ_PARTIAL;
}
include/proto/buffers.h
src/buffers.c