Re: 5.3-RELEASE TODO

From: Dag-Erling Smørgrav <des_at_des.no>
Date: Fri, 17 Sep 2004 19:57:32 +0200
Brooks Davis <brooks_at_one-eyed-alien.net> writes:
> I've got a patch for this one.  If someone will review it, I will commit
> it to HEAD for further testing.

you shouldn't call malloc() with M_NOWAIT unless you absolutely must,
and in this case you don't.

there's nothing to prevent the ifconf data from growing between the
first and second pass, since you're not holding the lock.  you'd end
up overflowing ifrbuf.

what I suggest you do is:

    struct sbuf *sb = sbuf_new(NULL, NULL, size, ifc->ifc_len + 1);
    acquire(lock);
    sbuf_bcat(sb, foo, foo_len);
    sbuf_bcat(sb, bar, bar_len);
    sbuf_bcat(sb, baz, baz_len);
    release(lock);
    sbuf_finish(sb);
    ifc->ifc_len = sbuf_len();
    copyout(sbuf_data(), ifc->ifc_req, ifc->ifc_len);
    sbuf_delete(sb);

DES
-- 
Dag-Erling Smørgrav - des_at_des.no
Received on Fri Sep 17 2004 - 15:57:33 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:12 UTC