Extending sbufs with a drain, take 2

mdf at FreeBSD.org mdf at FreeBSD.org
Wed Sep 8 23:15:00 UTC 2010


After the discussion here with phk, I have reworked my patches.  If
I've misunderstood the intent, I welcome corrections.  Do these
patches seem reasonable?

---

Refactor sbuf code so that most uses of sbuf_extend() are in a new
sbuf_put_byte().  This makes it easier to add drain functionality when a
buffer would overflow as there are fewer code points.

http://people.freebsd.org/~mdf/0001-Refactor-sbuf-code-so-that-most-uses-of-sbuf_extend-.patch

---

Fix small errors in the sbuf(9) man page.

http://people.freebsd.org/~mdf/0002-Fix-small-errors-in-the-sbuf-9-man-page.patch

---

Add drain functionality to sbufs.  The drain is a function that is
called when the sbuf internal buffer is filled.  For kernel sbufs with a
drain, the internal buffer will never be expanded.  For userland sbufs
with a drain, the internal buffer may still be expanded by
sbuf_[v]printf(3).

http://people.freebsd.org/~mdf/0003-Add-drain-functionality-to-sbufs.-The-drain-is-a-fun.patch

---

Add a drain function for struct sysctl_req, and use it for a variety
of handlers that had to do awkward things to get a large enough
FIXEDLEN buffer.

http://people.freebsd.org/~mdf/0004-Add-a-drain-function-for-struct-sysctl_req-and-use-i.patch

---

Fix an incorrect use of sbuf_overflowed() after a call to sbuf_finish().

http://people.freebsd.org/~mdf/0005-Fix-an-incorrect-use-of-sbuf_overflowed-after-a-call.patch

---

Replace sbuf_overflowed() with sbuf_error(), which returns any error
code associated with overflow or with the drain function.

http://people.freebsd.org/~mdf/0006-Replace-sbuf_overflowed-with-sbuf_error-which-return.patch

Thanks,
matthew


More information about the freebsd-arch mailing list