diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-11-10 11:20:12 +0000 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-11-10 11:20:12 +0000 |
commit | 7fa495cdf750c257ed897eca189aabc3a62d5f2b (patch) | |
tree | 12ecb16594bec98161c7517953ecbf2dba071aff /hurd | |
parent | Hurd: Implement chdir support in posix_spawn (diff) | |
download | glibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.tar.gz glibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.tar.bz2 glibc-7fa495cdf750c257ed897eca189aabc3a62d5f2b.zip |
Hurd: Fix ulinks in fd table reallocation
* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
* hurd/hurd/port.h (_hurd_port_move): New function.
* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.
Diffstat (limited to 'hurd')
-rw-r--r-- | hurd/hurd/port.h | 25 | ||||
-rw-r--r-- | hurd/hurd/userlink.h | 24 |
2 files changed, 49 insertions, 0 deletions
diff --git a/hurd/hurd/port.h b/hurd/hurd/port.h index 0779578d03..769e44b5cc 100644 --- a/hurd/hurd/port.h +++ b/hurd/hurd/port.h @@ -127,6 +127,31 @@ _hurd_port_get (struct hurd_port *port, #endif +/* Relocate LINK to NEW_LINK. + To be used when e.g. reallocating a link array. */ + +extern void +_hurd_port_move (struct hurd_port *port, + struct hurd_userlink *new_link, + struct hurd_userlink *link); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) +_HURD_PORT_H_EXTERN_INLINE void +_hurd_port_move (struct hurd_port *port, + struct hurd_userlink *new_link, + struct hurd_userlink *link) +{ + HURD_CRITICAL_BEGIN; + __spin_lock (&port->lock); + _hurd_userlink_move (new_link, link); + __spin_unlock (&port->lock); + HURD_CRITICAL_END; +} +# endif +#endif + + /* Free a reference gotten with `USED_PORT = _hurd_port_get (PORT, LINK);' */ extern void diff --git a/hurd/hurd/userlink.h b/hurd/hurd/userlink.h index f9362557cb..484706a67a 100644 --- a/hurd/hurd/userlink.h +++ b/hurd/hurd/userlink.h @@ -142,6 +142,30 @@ _hurd_userlink_unlink (struct hurd_userlink *link) # endif #endif +/* Relocate LINK to NEW_LINK. + To be used when e.g. reallocating a link array. */ + +extern void _hurd_userlink_move (struct hurd_userlink *new_link, + struct hurd_userlink *link); + +#if defined __USE_EXTERN_INLINES && defined _LIBC +# if IS_IN (libc) +_HURD_USERLINK_H_EXTERN_INLINE void +_hurd_userlink_move (struct hurd_userlink *new_link, + struct hurd_userlink *link) +{ + *new_link = *link; + + if (new_link->resource.next != NULL) + new_link->resource.next->resource.prevp = &new_link->resource.next; + *new_link->resource.prevp = link; + + if (new_link->thread.next != NULL) + new_link->thread.next->thread.prevp = &new_link->thread.next; + *new_link->thread.prevp = link; +} +# endif +#endif /* Clear all users from *CHAINP. Call this when the resource *CHAINP protects is changing. If the return value is nonzero, no users are on |