tech-net archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: reference counts on sockets?



> I have an in-kernel consumer of the socket API, which uses a very
> large number of sockets.  I don't want to maintain file structures
> associated with all these sockets unless I absolutely must -- they're
> wasteful, and kernel memory is at a premium.

> The problem is that some of the code in the socket layer assumes that
> if SS_NOFDREF is set, a socket's not long for this world and can be
> killed off.

Is it reasonable to just not set SS_NOFDREF, even though there truly is
no fd referring to the socket?  That's what I think I did last time I
had to work with kernel-owned sockets.  (Admittedly, that "last time"
was (a) years ago and (b) under NetBSD much older than what I assume
you are working with.)

> This seems like a poor substitute for a real reference counter, and
> mingles the semantics "has no associated file descriptor" and "is
> being deallocated" besides.

I suspect it does not have the former semantics except to humans; I
think the actual semantics are more like "not referrable-to any
longer", and the NOFDREF name is (at least now) a bit of a misnomer.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index