-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[catnip] Memory Pool Abstraction #84
Conversation
Is the title meant to say "[canip]" or "[catnip]"? |
unsafe { | ||
rte_pktmbuf_free(self.ptr); | ||
} | ||
MemoryPool::free_mbuf(self.ptr); | ||
self.ptr = ptr::null_mut(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems very un-Rustian. Now that the unsafe code is contained inside MemoryPool::free_mbuf(), it seems strange to be nullifying self.ptr here. I would expect free_mbuf() to be doing this for us, so we don't have access to a bogus pointer upon return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somehow we should make the raw pointer null, because it is not managed by Rust. I did not get what you are suggesting. Could you clarify it further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was suggesting that free_mbuf() null out self.ptr itself. To really do this right, we (or rather, the MemoryPool) would hide the "*mut rte_mbuf" inside a Rust type of our own creation. We'd pass that type into free_mbuf(), it would take ownership, etc.
But don't worry about it, this is probably good enough for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I got it and agree. I'm refactoring Mbuf
so as to make this interface cleaner too. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
17a4cd0
to
f36af86
Compare
Description
In this PR, I mostly introduce the enhancement that is described in #83.
Here is a digest of the commits:
mbufs
.MemoryPool
abstraction.MemoryPool
abstractionmbufs
(rte_pktmbuf_clone
does the job) and it was causing interdependency between several modules.