Re: m_dup
Re: m_dup
- Subject: Re: m_dup
- From: Justin Walker <email@hidden>
- Date: Sat, 16 Apr 2005 17:26:43 -0700
On Apr 16, 2005, at 15:38, Carl Smith wrote:
I was not attacking you directly I was more expressing my feelings and
thoughts, and yes we all have other duties and pressures and I am under
mine so I was getting frustrated at the same time.
I didn't feel attacked (that's what those silly puncticons mean).
As what I could see in the m_dup source code, if the passed in mbuf,
that is to be duplicated is small then m_dup does a m_pkthdr on the
mbuf, then moves the data from the original mbuf to the resulting m_buf
from the return of m_pkthdr,
m_gethdr(), but you've got the idea...
if the passed in mbuf is large/chained, the
there is a while loop doing m_get until the data is all copied from the
passed in mbuf. Now my question arises that according to Stevens's
book,
volume two, that m_get 'allocates an mbuf'. Now Stevens is basing all
his writing on BSD/Sun OS/AIX. When I look through the code,
documentation of the Darwin code, I can not find any reference to
m_dup.
That's because I wrote it.
If you look at any of the above OS stacks today, they would differ from
what Stevens has (his is 10 years old, and based on a very old BSD
drop). Also, Sun OS hasn't used the BSD stack for a while; it's based
on different stuff.
I do see comments that 'MGET' "allocates an mbuf and initializes it to
contain internal data". But as you even said, Apple took some time to
get this right, so I am assuming that Apple wrote there own version of
m_dup. I was just looking for confirmation that Darwin's m_dup behaves
the same as BSD's m_dup and if my assumption that m_dup will give me an
allocated\new mbuf, for me to do with as I see fit, is correct.
If BSD has m_dup, they wrote it (or, perhaps, snitched it :-}).
As for the effect of m_dup, it's not clear to me what you mean, but:
- m_dup really copies the input mbuf, so you end up with two mbufs,
the one you start with, and the one you get from m_dup. Each
has the same data.
- your code owns the mbuf you get back from m_dup, so either you
have to free it at some point, or you have to hand it off to code
that takes ownership (generally, handing it to a lower or higher
"layer" suffices). I assume that's what you mean by "do with as
I see fit".
The Darwin/Apple question as whole then is, if Apple re-wrote the
kernel, does everything, work the same as BSD/Unix? If I read some
behavior from another UNIX book, i.e. Stevens, can I then assume
Darwin's api will behave exactly the same?
You can't really assume that (which is why the source is your best
reference, with this list for clarification). In the first place, non
of the developers working on this stuff stand still. As time passes,
code is improved, fixed, screwed up, and otherwise messed with. Read
code. It's good for the soul.
And I see I am not the only working on weekends?
This ain't work :-}
Hope that helps.
Cheers,
Justin
--
Justin C. Walker, Curmudgeon at Large
Institute for General Semantics
-----------
My wife 'n kids 'n dog are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
-----------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >RE: m_dup (From: "Carl Smith" <email@hidden>) |