diff options
author | Richard Braun <rbraun@sceen.net> | 2013-10-18 01:16:07 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-10-18 01:16:07 +0200 |
commit | 4660ac02b9723380b4581b4c6a46e54861b95059 (patch) | |
tree | 0db9e3bb2dd4758eb7decdb9eedb1e1b0d9bd0c6 /pflocal | |
parent | 1cfdceba98c380ad1cebb3a6b3d1f141d852c691 (diff) |
pflocal: fix destruction of explicitely bound sockets
Sockets must have a weak reference on the address they're bound to so
that addr_unbind is properly called before addr_clean. For sockets that
are automatically bound, this weak reference is created in ensure_addr.
Do the same in sock_bind.
* pflocal/sock.c (sock_bind): Handle weak reference on addr.
Diffstat (limited to 'pflocal')
-rw-r--r-- | pflocal/sock.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/pflocal/sock.c b/pflocal/sock.c index 2641e1c5..8076dd36 100644 --- a/pflocal/sock.c +++ b/pflocal/sock.c @@ -294,12 +294,16 @@ sock_bind (struct sock *sock, struct addr *addr) { sock->addr = addr; if (addr) - sock->refs++; + { + sock->refs++; + ports_port_ref_weak (addr); + } if (old_addr) { /* Note that we don't have to worry about SOCK's ref count going to zero because whoever's calling us should be holding a ref. */ sock->refs--; + ports_port_deref_weak (addr); assert (sock->refs > 0); /* But make sure... */ } } |