diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2012-05-10 15:49:30 -0700 |
---|---|---|
committer | Roland McGrath <roland@hack.frob.com> | 2012-05-10 15:57:28 -0700 |
commit | f34d6f840eaba45a82fa8d20922fc2d678968fb7 (patch) | |
tree | 263eed914faf5b86ac1400644df8040186d92483 /sysdeps/mach/hurd | |
parent | 674cdbc7a3d022764e83b75e73b2767a36823c91 (diff) | |
download | glibc-f34d6f840eaba45a82fa8d20922fc2d678968fb7.tar.gz glibc-f34d6f840eaba45a82fa8d20922fc2d678968fb7.tar.xz glibc-f34d6f840eaba45a82fa8d20922fc2d678968fb7.zip |
Hurd: Fix __dup3 _hurd_dtable_lock usage.
Diffstat (limited to 'sysdeps/mach/hurd')
-rw-r--r-- | sysdeps/mach/hurd/dup3.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/sysdeps/mach/hurd/dup3.c b/sysdeps/mach/hurd/dup3.c index 8a38caf080..523ca42285 100644 --- a/sysdeps/mach/hurd/dup3.c +++ b/sysdeps/mach/hurd/dup3.c @@ -71,15 +71,14 @@ __dup3 (int fd, int fd2, int flags) /* Get a hold of the destination descriptor. */ struct hurd_fd *d2; + __mutex_lock (&_hurd_dtable_lock); + if (fd2 >= _hurd_dtablesize) { /* The table is not large enough to hold the destination descriptor. Enlarge it as necessary to allocate this descriptor. */ __mutex_unlock (&_hurd_dtable_lock); - /* We still hold FD1's lock, but this is safe because - _hurd_alloc_fd will only examine the cells starting - at FD2. */ d2 = _hurd_alloc_fd (NULL, fd2); if (d2) __spin_unlock (&d2->port.lock); @@ -99,6 +98,7 @@ __dup3 (int fd, int fd2, int flags) MACH_PORT_NULL); } } + __mutex_unlock (&_hurd_dtable_lock); if (d2 == NULL) { @@ -126,7 +126,6 @@ __dup3 (int fd, int fd2, int flags) _hurd_port_locked_set (&d2->port, port); /* Unlocks D2. */ } } - __mutex_unlock (&_hurd_dtable_lock); _hurd_port_free (&d->port, &ulink, port); if (ctty != MACH_PORT_NULL) |