Commit Graph

6 Commits

Author SHA1 Message Date
nick
cac6e7698b Fix a multiple-sockets-in-one-process issue.
"pid" is not "process id" in netlink, but rather, "port id". If you bind to a
sockaddr == 0 then Linux automatically assigns your socket a port id - which
happens to be the same as the process ID for the first one concurrently open.

For the second and subsequent concurrently-open sockets, binding 0 (as most
users of this library will do) gets you back a random high-numbered port id.

This change preserves the existing use case (one port open in the process,
binding to 0) while fixing multiple-ports-open-in-the-same-process, socket-is-
passed-in-and-pid-is-not-specified, and specific-pid-is-requested-but-could-
not-bind-to-it.

We're probably still not thread-safe - the seq handling looks dodgy - but at
least now we can use multiple sockets in separate threads and have them all
work.

Using the same socket from multiple threads is a slightly niche use case, and
it's tempting to say "don't do this" instead...
2014-04-15 15:10:39 +01:00
Patrick J Cherry
e0aae9c67c re-tidied up warnings. 2014-01-21 09:51:37 +00:00
Patrick J Cherry
e96601981b Tidied up warnings in nlsocket 2014-01-18 07:08:19 +00:00
mbloch
cd58b64499 Added working NLSocket.open and scope handling. 2011-05-18 15:26:53 +01:00
Brian Candler
da2db43c8a Implement sendmsg/recvmsg for 1.8 using ffi 2011-05-06 13:41:42 +01:00
Brian Candler
e07af9a315 Reorganise under Linux:: 2011-05-06 09:49:47 +01:00