[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 24/30: Fix closure of local server sockets
From: |
Samuel Thibault |
Subject: |
[hurd] 24/30: Fix closure of local server sockets |
Date: |
Tue, 22 Sep 2015 21:52:00 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit df2b1fb2caed423b22f6d59d22f087100dd1b7d8
Author: Samuel Thibault <address@hidden>
Date: Fri Sep 11 02:05:06 2015 +0200
Fix closure of local server sockets
Since bound socks always have a ref for their address, they would never get
freed. Thanks Svante Signell for the investigation.
* pflocal/sock.h (sock_deref): When `sock' has one ref left and is bound to
an address, unbound it, and thus shut it down.
---
pflocal/sock.h | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/pflocal/sock.h b/pflocal/sock.h
index 5800420..f827c6f 100644
--- a/pflocal/sock.h
+++ b/pflocal/sock.h
@@ -118,9 +118,32 @@ void _sock_norefs (struct sock *sock);
static inline void __attribute__ ((unused))
sock_deref (struct sock *sock)
{
+ error_t err;
pthread_mutex_lock (&sock->lock);
- if (--sock->refs == 0)
+
+ sock->refs--;
+
+ if (sock->refs == 0)
_sock_norefs (sock);
+ else if (sock->refs == 1 && sock->addr)
+ {
+ /* Last ref is the address, there won't be any more port for this socket,
+ unbind SOCK from its addr, and they will all die. */
+
+ /* Keep another ref while unbinding. */
+ sock->refs++;
+ pthread_mutex_unlock (&sock->lock);
+
+ /* Unbind */
+ err = sock_bind (sock, NULL);
+ assert (!err);
+
+ /* And release the ref, and thus kill SOCK. */
+ pthread_mutex_lock (&sock->lock);
+ sock->refs--;
+ assert(sock->refs == 0);
+ _sock_norefs (sock);
+ }
else
pthread_mutex_unlock (&sock->lock);
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 16/30: Make procfs accept none or proc as "device", (continued)
- [hurd] 16/30: Make procfs accept none or proc as "device", Samuel Thibault, 2015/09/22
- [hurd] 15/30: Fix opening a fifo with O_RDWR, Samuel Thibault, 2015/09/22
- [hurd] 09/30: libdiskfs: fix parent lookup in the name cache, Samuel Thibault, 2015/09/22
- [hurd] 17/30: Also do not realpath "proc" pseudo-device, Samuel Thibault, 2015/09/22
- [hurd] 13/30: Fix build against glibc 2.21, Samuel Thibault, 2015/09/22
- [hurd] 18/30: umount: Do not report errors on making the device go away, Samuel Thibault, 2015/09/22
- [hurd] 20/30: libshouldbeinlibc/maptime: use memory fences, Samuel Thibault, 2015/09/22
- [hurd] 21/30: Do not install libtrivfs mig stub headers, Samuel Thibault, 2015/09/22
- [hurd] 22/30: Install port-deref-deferred.h header for ports.h, Samuel Thibault, 2015/09/22
- [hurd] 19/30: pflocal: avoid nested function, Samuel Thibault, 2015/09/22
- [hurd] 24/30: Fix closure of local server sockets,
Samuel Thibault <=
- [hurd] 23/30: Fix sock_bind(sock,NULL) support, Samuel Thibault, 2015/09/22
- [hurd] 29/30: Define TIME_VALUE_TO_TIMESPEC only when not defined already, Samuel Thibault, 2015/09/22
- [hurd] 25/30: Fix detection of terminated dgram pflocal server, Samuel Thibault, 2015/09/22
- [hurd] 01/30: exec: fix setting the name of early servers, Samuel Thibault, 2015/09/22
- [hurd] 12/30: libdiskfs: rename `error' variable, Samuel Thibault, 2015/09/22
- [hurd] 26/30: Add support for ANSI.SYS SCP/RCP escape codes, Samuel Thibault, 2015/09/22
- [hurd] 27/30: Fix build warning, Samuel Thibault, 2015/09/22
- [hurd] 14/30: Fix race condition in ext2fs when remounting, Samuel Thibault, 2015/09/22
- [hurd] 30/30: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2015/09/22
- [hurd] 28/30: Turn EADDRNOTAVAIL to more commonly-understood ECONNREFUSED, Samuel Thibault, 2015/09/22