[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 23/30: Fix sock_bind(sock,NULL) support
From: |
Samuel Thibault |
Subject: |
[hurd] 23/30: Fix sock_bind(sock,NULL) support |
Date: |
Tue, 22 Sep 2015 21:51:59 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 280e26f17906c2c2fb39c33bee797e90f5cf0c40
Author: Samuel Thibault <address@hidden>
Date: Fri Sep 11 01:39:08 2015 +0200
Fix sock_bind(sock,NULL) support
* pflocal/sock.c (sock_bind): When addr is NULL, do not take/release its
mutex. When old_addr is also NULL, return EINVAL. When old_addr is not NULL,
deref old_addr instead of addr.
---
pflocal/sock.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pflocal/sock.c b/pflocal/sock.c
index 8076dd3..ef70d2c 100644
--- a/pflocal/sock.c
+++ b/pflocal/sock.c
@@ -277,12 +277,15 @@ sock_bind (struct sock *sock, struct addr *addr)
error_t err = 0;
struct addr *old_addr;
- pthread_mutex_lock (&addr->lock);
+ if (addr)
+ pthread_mutex_lock (&addr->lock);
pthread_mutex_lock (&sock->lock);
old_addr = sock->addr;
if (addr && old_addr)
err = EINVAL; /* SOCK already bound. */
+ else if (!addr && !old_addr)
+ err = EINVAL; /* SOCK already bound. */
else if (addr && addr->sock)
err = EADDRINUSE; /* Something else already bound ADDR. */
else if (addr)
@@ -303,13 +306,14 @@ sock_bind (struct sock *sock, struct addr *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);
+ ports_port_deref_weak (old_addr);
assert (sock->refs > 0); /* But make sure... */
}
}
pthread_mutex_unlock (&sock->lock);
- pthread_mutex_unlock (&addr->lock);
+ if (addr)
+ pthread_mutex_unlock (&addr->lock);
return err;
}
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 15/30: Fix opening a fifo with O_RDWR, (continued)
- [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, 2015/09/22
- [hurd] 23/30: Fix sock_bind(sock,NULL) support,
Samuel Thibault <=
- [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