[OpenWrt-Devel] [PATCH 1/3] ustream: add function ustream_read().

Yousong Zhou yszhou4tech at gmail.com
Tue Dec 23 23:58:19 EST 2014

On 22 December 2014 at 22:46, Felix Fietkau <nbd at openwrt.org> wrote:
> On 2014-12-16 22:15, Yousong Zhou wrote:
>> It can be used to fill caller specified buffer area with data already in
>> ustream read buffer. Useful in the following use pattern.
>> int available = ustream_pending_data(s, false);
>> if (available >= sizeof(struct msghdr)) {
>> struct msghdr h;
>> ustream_read(s, &h, sizeof(h));
>> }


>> +
> I'd expect ustream_read() to consume the data it has read.
> It should also probably just use ustream_get_read_buf() and
> ustream_consume() instead of open-coding its functionality.

I tend to peek inside the msghdr to get the total length then consume
them as a whole if there is enough available in the read buffer.  But
I am fine with either way.


openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list