Closed dankamongmen closed 5 years ago
Delete callbacks could then do the same -- a certain return code indicates "unshare this". The only thing I don't like about that is that there is no feedback to the client (i.e. I can't see whether I've tried to unshare something I wasn't thought to have a hold on).
I've added the unit tests for this, and the declarations:
const struct netstack_iface* netstack_iface_share(const struct netstack_iface* ni);
struct netstack_iface* netstack_iface_copy(const struct netstack_iface* ni);
I think this is just about done, although the unit tests won't be reliable until #17 is complete :/.
Nevermind, figured out a way around the unit test flakiness, I think...
I've committed this. We sometimes lock up in the unit tests, only (so far as I can tell) from these "internal" copy/share (I've seen both deadlock) tests, not the "external" ones. The lockup is in shutdown, while joining on rx/tx threads, as we've seen before.
Right now, the callbacks can't perform a copy/share on the object they're given, as it's not yet been added to the netstack lookups. We could change that ordering, or perhaps it'd be better to allow some return code to indicate a sharing, and thus save a function call (while still requiring positive affirmation that a share is desired)? Yeah, I think that might be better.